I have summarized what I found in stackoverflow about this topic. The following code is a function that checks the object and title returned by imap_fetchheader or imap_headerinfo.
If only every email client would do the same: - | Usually they should send an empty return path that your script can identify to filter the automatic response. However, my tests showed that this header was not sent by the versions of Outlook that I used.
ID strings are stored in an array, making it easy to customize your needs.
/** * Function _MailIsAutoSubmitted * @return true|false * @category Mail * @author this->guy */ function _MailIsAutoSubmitted($Mailbox,$EmailID){ $Found = false; //Check Headers $Header = imap_fetchheader($Mailbox,$EmailID); $HeaderIdentifiers = array( '([X-]{0,2})Auto-Response-Suppress:([\s]*)([All|OOF])', 'Auto-Submitted:([\s]*)auto-([replied|notified|generated])', 'X-MS-Exchange-Inbox-Rules-Loop:', 'X-Autorespond', '([X-]{0,2})Precedence:([\s]*)([auto_reply|bulk|junk])' ); for($x=0;$x<count($HeaderIdentifiers);$x++){ if(preg_match('/'.$HeaderIdentifiers[$x].'/is',$Header)){ $Found = true; } } //Check Subject $Subject = trim(imap_headerinfo($Mailbox,$EmailID)->subject); $SubjectIdentifiers = array( 'Auto:', 'Automatic Reply:', 'Auto Response:' ); for($x=0;$x<count($SubjectIdentifiers);$x++){ if(preg_match('/^'.$SubjectIdentifiers[$x].'/is',$Subject)){ $Found = true; } } return $Found; }
source share