From 4a1d86b7376b57284915b7930cdb35e0a5983c92 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 18 Sep 2021 20:05:42 +0200 Subject: [PATCH 1/2] Added isAutoReply() method to InboundEmail --- src/InboundEmail.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/InboundEmail.php b/src/InboundEmail.php index 9e7949f..74e5bf0 100644 --- a/src/InboundEmail.php +++ b/src/InboundEmail.php @@ -185,4 +185,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; + } } From f4eee1626883fb4c9ff87b80bf5bb54b9e3672fb Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 18 Sep 2021 20:27:30 +0200 Subject: [PATCH 2/2] Fixed code style --- src/InboundEmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/InboundEmail.php b/src/InboundEmail.php index 74e5bf0..a61e0c7 100644 --- a/src/InboundEmail.php +++ b/src/InboundEmail.php @@ -185,7 +185,7 @@ public function isValid(): bool { return $this->from() !== '' && ($this->isText() || $this->isHtml()); } - + public function isAutoReply($checkCommonSubjects = true): bool { if ($this->headerValue('x-autorespond')) {