From 1a4d92b6a25a220088d8a329e40c12eeb75ac574 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Fri, 17 May 2013 17:55:33 -0700 Subject: [PATCH] CRM-9855 ---------------------------------------- * CRM-9855: CiviMail sets X-header "X-CiviMail-Bounce" on outbound bulk email, but does not use it to identify an inbound bounce http://issues.civicrm.org/jira/browse/CRM-9855 --- CRM/Utils/Mail/EmailProcessor.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CRM/Utils/Mail/EmailProcessor.php b/CRM/Utils/Mail/EmailProcessor.php index 5826387873..a812b7b224 100644 --- a/CRM/Utils/Mail/EmailProcessor.php +++ b/CRM/Utils/Mail/EmailProcessor.php @@ -159,6 +159,9 @@ class CRM_Utils_Mail_EmailProcessor { // a tighter regex for finding bounce info in soft bounces’ mail bodies $rpRegex = '/Return-Path: ' . preg_quote($dao->localpart) . '(b)' . $twoDigitString . '([0-9a-f]{16})@' . preg_quote($dao->domain) . '/'; + // a regex for finding bound info X-Header + $rpXheaderRegex = '/X-CiviMail-Bounce: ' . preg_quote($dao->localpart) . '(b)' . $twoDigitString . '([0-9a-f]{16})@' . preg_quote($dao->domain) . '/'; + // retrieve the emails try { $store = CRM_Mailing_MailStore::getStore($dao->name); @@ -202,6 +205,12 @@ class CRM_Utils_Mail_EmailProcessor { list($match, $action, $job, $queue, $hash) = $matches; } + // if $matches is still empty, look for the X-CiviMail-Bounce header + // CRM-9855 + if (!$matches and preg_match($rpXheaderRegex, $mail->generateBody(), $matches)) { + list($match, $action, $job, $queue, $hash) = $matches; + } + // if all else fails, check Delivered-To for possible pattern if (!$matches and preg_match($regex, $mail->getHeader('Delivered-To'), $matches)) { list($match, $action, $job, $queue, $hash) = $matches; -- 2.25.1