Skip to content

Commit

Permalink
Merge pull request #89 from io238/master
Browse files Browse the repository at this point in the history
Added isAutoReply() method to InboundEmail
  • Loading branch information
mechelon committed Apr 3, 2024
2 parents 57cb8a8 + f4eee16 commit 4a5de8c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/InboundEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,43 @@ public function isValid(): bool
{
return $this->from() !== '' && ($this->isText() || $this->isHtml());
}

public function isAutoReply($checkCommonSubjects = true): bool
{
if ($this->headerValue('x-autorespond')) {
return true;
}

if (in_array($this->headerValue('precedence'), ['auto_reply', 'bulk', 'junk'])) {
return true;
}

if (in_array($this->headerValue('x-precedence'), ['auto_reply', 'bulk', 'junk'])) {
return true;
}
if (in_array($this->headerValue('auto-submitted'), ['auto-replied', 'auto-generated'])) {
return true;
}

if ($checkCommonSubjects) {
return Str::startsWith($this->subject(), [
'Auto:',
'Automatic reply',
'Autosvar',
'Automatisk svar',
'Automatisch antwoord',
'Abwesenheitsnotiz',
'Risposta Non al computer',
'Automatisch antwoord',
'Auto Response',
'Respuesta automática',
'Fuori sede',
'Out of Office',
'Frånvaro',
'Réponse automatique',
]);
}

return false;
}
}

0 comments on commit 4a5de8c

Please sign in to comment.