PHP-Bounce-Handler
PHP-Bounce-Handler copied to clipboard
Boundary parsing
In bounce_driver.class.php on line 417 in function parse_body_into_mime_sections there occurs a problem with boundaries ending with == because =\r\n gets stripped away at line 309. An easy fix (maybe not the best) is to rtrim the = from $boundary.
function parse_body_into_mime_sections($body, $boundary){
if(!$boundary) return array();
if(is_array($body)) $body = implode("\r\n", $body);
$body = explode(rtrim($boundary, '='), $body);
$mime_sections['first_body_part'] = @$body[1];
$mime_sections['machine_parsable_body_part'] = @$body[2];
$mime_sections['returned_message_body_part'] = @$body[3];
return $mime_sections;
}
Sample bounce message:
Return-path: <>
Envelope-to: [email protected]
Delivery-date: Thu, 20 Mar 2014 12:03:05 +0100
Received: from mail2.bemta5.messagelabs.com ([195.245.231.131])
by mailserver.domain.domain with esmtps (TLSv1:AES256-SHA:256)
(Exim 4.73 (FreeBSD))
id 1WQakY-0006Ke-3E
for [email protected]; Thu, 20 Mar 2014 12:03:05 +0100
Received: from [85.158.136.35:12059] by server-10.bemta-5.messagelabs.com id 57/A5-27081-4EACA235; Thu, 20 Mar 2014 11:03:00 +0000
X-Msg-Ref: server-16.tower-125.messagelabs.com!1395313183!33967189!1
X-Originating-IP: [195.245.231.134]
X-StarScan-Received:
X-StarScan-Version: 6.11.1; banners=-,-,-
X-VirusChecked: Checked
Received: (qmail 11713 invoked from network); 20 Mar 2014 10:59:43 -0000
Received: from mail5.bemta5.messagelabs.com (HELO mail5.bemta5.messagelabs.com) (195.245.231.134)
by server-16.tower-125.messagelabs.com with DHE-RSA-AES256-SHA encrypted SMTP; 20 Mar 2014 10:59:43 -0000
Received: by server-14.bemta-5.messagelabs.com id DD/21-15696-F1ACA235; Thu, 20 Mar 2014 10:59:43 +0000
From: Mail Delivery System <[email protected]>
To: <[email protected]>
Subject: Mail Delivery Failure
Date: Thu, 20 Mar 2014 10:59:43 +0000
Content-Type: multipart/report; report-type=delivery-status;
boundary="ONHrN715MUZyqWppCw12MuNjL3IsvuuVQXcdmQ=="
X-Exim-Version: 4.73 (build at 17-Jan-2011 14:55:22)
X-Date: 2014-03-20 12:03:05
X-Connected-IP: 195.245.231.131:39383
X-Spam-Threshold: 5
X-Spam-Score: -4.1
X-Spam-Score-Int: -40
X-Spam-Bar: ----
X-Spam-Flag: NO
X-Delivered-To: [email protected]
X-Message-Age: 3
--ONHrN715MUZyqWppCw12MuNjL3IsvuuVQXcdmQ==
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
This is the mail delivery agent at messagelabs.com.
I was unable to deliver your message to the following addresses:
[email protected]
Reason: 550 5.1.1 <[email protected]>... User unknown
The message subject was: Diabetes Nieuwsbrief maart 2014
The message date was: Thu, 20 Mar 2014 11:59:43 +0100
The message identifier was: 4B/21-15696-F1ACA235
The message reference was: server-9.tower-125.messagelabs.com!1395313182!24=
402582!1
Please do not reply to this email as it is sent from an unattended mailbox.
Please visit www.messagelabs.com/support for more details
about this error message and instructions to resolve this issue.
--ONHrN715MUZyqWppCw12MuNjL3IsvuuVQXcdmQ==
Content-Type: message/delivery-status
Arrival-Date: Thu, 20 Mar 2014 10:59:43 +0000
Reporting-MTA: dns; server-14.bemta-5.messagelabs.com
Remote-MTA: dns; 194.151.80.130
Diagnostic-Code: smtp; 550 5.1.1 <[email protected]>... User unknown
Last-Attempt-Date: Thu, 20 Mar 2014 10:59:43 +0000
Final-Recipient: rfc822; [email protected]
Status: 5.1.1
Action: failed
--ONHrN715MUZyqWppCw12MuNjL3IsvuuVQXcdmQ==
Content-Type: text/rfc822-headers
Return-Path: <[email protected]>
Received: from [85.158.136.35:41051] by server-14.bemta-5.messagelabs.com id 4B/21-15696-F1ACA235; Thu, 20 Mar 2014 10:59:43 +0000
X-Env-Sender: [email protected]
X-Msg-Ref: server-9.tower-125.messagelabs.com!1395313182!24402582!1
X-Originating-IP: [33.33.33.33]
X-SpamReason: No, hits=0.8 required=7.0 tests=HTML_MESSAGE,
MIME_HTML_MOSTLY,MPART_ALT_DIFF
X-StarScan-Received:
X-StarScan-Version: 6.11.1; banners=-,-,viecuri.nl
X-VirusChecked: Checked
Received: (qmail 4698 invoked from network); 20 Mar 2014 10:59:42 -0000
Received: from mailserver.domain.domain (HELO mailserver.domain.domain) (33.33.33.33)
by server-9.tower-125.messagelabs.com with DHE-RSA-AES256-SHA encrypted SMTP; 20 Mar 2014 10:59:42 -0000
Received: from localhost ([127.0.0.1] helo=www.domain.domain)
by mailserver.domain.domain with esmtpa (Exim 4.73 (FreeBSD))
(envelope-from <[email protected]>)
id 1WQahL-0004m2-FT
for [email protected]; Thu, 20 Mar 2014 11:59:43 +0100
MIME-Version: 1.0
Message-ID: <[email protected]>
From: "Domain domain" <[email protected]>
Subject: Something 2014
Content-Type: multipart/alternative;
boundary="=_216b93cd925b7803b4c52bca98a3ee3c"
To: [email protected]
Date: Thu, 20 Mar 2014 11:59:43 +0100
X-Date: 2014-03-20 11:59:43
X-Connected-IP: 127.0.0.1:50595
--ONHrN715MUZyqWppCw12MuNjL3IsvuuVQXcdmQ==--