Skip to content

Commit 4a1d86b

Browse files
authored
Added isAutoReply() method to InboundEmail
1 parent 154cfe7 commit 4a1d86b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/InboundEmail.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,43 @@ public function isValid(): bool
185185
{
186186
return $this->from() !== '' && ($this->isText() || $this->isHtml());
187187
}
188+
189+
public function isAutoReply($checkCommonSubjects = true): bool
190+
{
191+
if ($this->headerValue('x-autorespond')) {
192+
return true;
193+
}
194+
195+
if (in_array($this->headerValue('precedence'), ['auto_reply', 'bulk', 'junk'])) {
196+
return true;
197+
}
198+
199+
if (in_array($this->headerValue('x-precedence'), ['auto_reply', 'bulk', 'junk'])) {
200+
return true;
201+
}
202+
if (in_array($this->headerValue('auto-submitted'), ['auto-replied', 'auto-generated'])) {
203+
return true;
204+
}
205+
206+
if ($checkCommonSubjects) {
207+
return Str::startsWith($this->subject(), [
208+
'Auto:',
209+
'Automatic reply',
210+
'Autosvar',
211+
'Automatisk svar',
212+
'Automatisch antwoord',
213+
'Abwesenheitsnotiz',
214+
'Risposta Non al computer',
215+
'Automatisch antwoord',
216+
'Auto Response',
217+
'Respuesta automática',
218+
'Fuori sede',
219+
'Out of Office',
220+
'Frånvaro',
221+
'Réponse automatique',
222+
]);
223+
}
224+
225+
return false;
226+
}
188227
}

0 commit comments

Comments
 (0)