Emails have a flag outside the office that can be read with PHP

I am making some improvements to the internal ticketing system. The system displays emails from our exchange server and converts them into tickets in the system. We already accept information from the header of each letter during this ticket generation process.

I would like to know if there is a way to know for sure if the email is a response outside the office and is automatically sent back. It will be from any system, not just from Outlook. This would be useful because these emails could be filtered out and not converted into tickets, which will reduce the amount of spam in our system and save the time of our agents.

However, it really should be in place, since we prefer to process these emails manually than skip an email that has not been automated. Another useful thing to discover is to bounce off invalid addresses, server messages, etc.

I am developing in PHP, but any pointers in the right direction will be appreciated.

+4
source share
3 answers

This is discussed in RFC 3834 Guidelines for Automatic Reply to Email . It defines an Auto-Submitted header field that indicates whether the message was sent automatically. Check if it is there and if so, then exclude this message.

+3
source

Besides reading the actual text of the letter and searching for patterns with regular expressions, you can take a look at the email headers and see if there are any specific headers set in any of these conditions. It's hard for me to understand how you will have to deal with rejection messages when your address book gets out of control.

0
source

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; } 
0
source

All Articles