电子邮件是否包含可以从 PHP 读取的外出标志

发布于 2024-11-29 17:04:50 字数 322 浏览 0 评论 0原文

我正在对内部票务系统进行一些改进。系统从我们的交换服务器中提取电子邮件并将其转换为系统中的门票。在票证生成过程中,我们已经从每封电子邮件的标题中获取信息。

我想知道是否有一种方法可以确定电子邮件是否是外出回复并已自动发回。这可以来自任何系统,而不仅仅是 Outlook。这将非常有用,因为这些电子邮件可以被过滤掉并且不会转换为票证,从而减少我们系统中的垃圾邮件并节省我们的代理时间。

然而,这确实必须准确,因为我们宁愿手动处理这些电子邮件,也不愿错过非自动化的电子邮件。另一个有用的检测是从无效地址、服务器消息等反弹。

我正在使用 PHP 进行开发,但任何正确方向的指示将不胜感激。

I'm making some improvements to an internal ticketing system. The system pulls emails from our exchange server and converts them into tickets in the system. We already take information from the header of each email during this process of ticket generation.

What I would like to know is if there is a way to know for certain if an email is an out-of-office reply and has been automatically sent back. This would be from any system and not just Outlook. This would be useful as these emails could be filtered out and not converted into tickets, reducing spam in our system and saving our agents time.

However this really has to be spot on as we would rather handle these emails manually than miss an email that wasn't automated. Another helpful thing to detect would be bounce backs from invalid addresses, server messages and the like.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

燕归巢 2024-12-06 17:04:51

我总结了我在 stackoverflow 上找到的有关该主题的内容。
以下代码是检查 imap_fetchheader 或 imap_headerinfo 返回的主题和标头的函数。

如果每个电子邮件客户端都这样做就好了:-|通常他们应该发送一个空的返回路径,您的脚本可以识别该路径以过滤自动回复。但是,在我的测试中表明,我使用的 Outlook 版本不会发送此标头。

标识符字符串存储在数组中,以便更轻松地根据您的需求进行调整。

 /**
 * 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;
}

I summarized what I have found on stackoverflow about this topic.
Following code is a function that checks the subject and header 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 can be identified by your script to filter an automatic reply. However, in my tests showed that this header were not send by the Outlook versions I have used.

The identifier strings are stored in an array to make it easier to adjust to 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;
}
樱花坊 2024-12-06 17:04:51

除了阅读电子邮件的实际文本并使用正则表达式查找模式之外,您可能还想查看电子邮件标头,看看是否有在这些情况下设置的任何特定标头。我很难理解当您的地址簿无法交换时您将如何处理退回邮件。

Aside from reading the actual text of the email and looking for patterns with regex, you might want to take a look at the email headers and see if there are any particular headers that are set in any of these circumstances. I'm having a hard time understanding how you would have to deal with bounce messages when your address book comes out of exchange.

箜明 2024-12-06 17:04:50

RFC 3834 自动回复电子邮件的建议对此进行了讨论。它定义了自动提交标头字段,指示消息是否自动发送。检查它是否存在,如果存在,则排除该消息。

This is discussed in RFC 3834 Recommendations for Automatic Responses to Electronic Mail. It defines the Auto-Submitted header field that indicates if the message was sent automatically. Check if it's there and if it is, then exclude that message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文