print_r($bouncehandler->fbl_hash); echo "</TEXTAREA>"; } } else { print "<h2><font color=red>Not an RFC1892 multipart report</font></H2>"; echo "<TEXTAREA COLS=100 ROWS=100>"; print_r($body); echo "</TEXTAREA>"; exit; } } echo "<h2>Here is the parsed report</h2>\n"; echo "<P>Postfix adds an appropriate X- header (X-Postfix-Sender:), so you do not need to create one via phpmailer. RFC's call for an optional Original-recipient field, but mandatory Final-recipient field is a fair substitute.</P>"; $boundary = $head_hash['Content-type']['boundary']; $mime_sections = $bouncehandler->parse_body_into_mime_sections($body, $boundary); $rpt_hash = $bouncehandler->parse_machine_parsable_body_part($mime_sections['machine_parsable_body_part']); echo "<TEXTAREA COLS=100 ROWS=" . count($rpt_hash) * 16 . ">"; print_r($rpt_hash); echo "</TEXTAREA>"; echo "<h2>Here is the error status code</h2>\n"; echo "<P>It's all in the status code, if you can find one.</P>"; for ($i = 0; $i < count($rpt_hash['per_recipient']); $i++) { echo "<P>Report #" . ($i + 1) . "<BR>\n"; echo $bouncehandler->find_recipient($rpt_hash['per_recipient'][$i]); $scode = $rpt_hash['per_recipient'][$i]['Status']; echo "<PRE>{$scode}</PRE>"; echo $bouncehandler->fetch_status_messages($scode); echo "</P>\n"; } echo "<h2>The Diagnostic-code</h2> <P>is not the same as the reported status code, but it seems to be more descriptive, so it should be extracted (if possible)."; for ($i = 0; $i < count($rpt_hash['per_recipient']); $i++) {
/** * Tests a single email. * * @param string $bounce Contents of the bounce email. * * @return void */ private function _testSingle($bounce) { $multiArray = $this->_bouncehandler->get_the_facts($bounce); echo "<TEXTAREA COLS=100 ROWS=" . count($multiArray) * 8 . ">"; print_r($multiArray); echo "</TEXTAREA>"; $bounce = $this->_bouncehandler->init_bouncehandler($bounce, 'string'); list($head, $body) = preg_split("/\r\n\r\n/", $bounce, 2); echo '<h2>Raw email:</h2><br />'; echo "<TEXTAREA COLS=100 ROWS=12>"; echo htmlspecialchars($bounce); echo "</TEXTAREA><br />"; echo "<h2>Parsed head</h2>\n"; $head_hash = $this->_bouncehandler->parse_head($head); echo "<TEXTAREA COLS=100 ROWS=" . count($head_hash) * 2.7 . ">"; print_r($head_hash); echo "</TEXTAREA><br />"; if ($this->_bouncehandler->is_RFC1892_multipart_report($head_hash)) { echo '<h2 style="color:red;">'; echo 'Looks like an RFC1892 multipart report'; echo '</h2>'; } else { if ($this->_bouncehandler->looks_like_an_FBL) { echo '<h2 style="color:red;">'; echo 'Looks like a feedback loop'; if ($this->_bouncehandler->is_hotmail_fbl) { echo ' in Hotmail Doofus Format (HDF?)'; } else { echo ' in Abuse Feedback Reporting format (ARF)'; } echo '</h2>'; echo "<TEXTAREA COLS=100 ROWS=12>"; print_r($this->_bouncehandler->fbl_hash); echo "</TEXTAREA>"; } else { echo "<h2 style='color:red;'>Not an RFC1892 multipart report</H2>"; echo "<TEXTAREA COLS=100 ROWS=100>"; print_r($body); echo "</TEXTAREA>"; exit; } } echo "<h2>Here is the parsed report</h2>\n"; echo '<p>Postfix adds an appropriate X- header (X-Postfix-Sender:), '; echo 'so you do not need to create one via phpmailer. RFC\'s call '; echo 'for an optional Original-recipient field, but mandatory '; echo 'Final-recipient field is a fair substitute.</p>'; $boundary = $head_hash['Content-type']['boundary']; $mime_sections = $this->_bouncehandler->parse_body_into_mime_sections($body, $boundary); $rpt_hash = $this->_bouncehandler->parse_machine_parsable_body_part($mime_sections['machine_parsable_body_part']); echo "<TEXTAREA COLS=100 ROWS=" . count($rpt_hash) * 16 . ">"; print_r($rpt_hash); echo "</TEXTAREA>"; echo "<h2>Here is the error status code</h2>\n"; echo "<P>It's all in the status code, if you can find one.</P>"; for ($i = 0; $i < count($rpt_hash['per_recipient']); $i++) { echo "<P>Report #" . ($i + 1) . "<BR>\n"; echo $this->_bouncehandler->find_recipient($rpt_hash['per_recipient'][$i]); $scode = $rpt_hash['per_recipient'][$i]['Status']; echo "<PRE>{$scode}</PRE>"; echo $this->_bouncehandler->fetch_status_messages($scode); echo "</P>\n"; } echo '<h2>The Diagnostic-code</h2>'; echo '<p>is not the same as the reported status code, but it seems '; echo 'to be more descriptive, so it should be extracted (if possible).'; for ($i = 0; $i < count($rpt_hash['per_recipient']); $i++) { echo "<P>Report #" . ($i + 1) . " <BR>\n"; echo $this->_bouncehandler->find_recipient($rpt_hash['per_recipient'][$i]); $dcode = $rpt_hash['per_recipient'][$i]['Diagnostic-code']['text']; if ($dcode) { echo "<PRE>{$dcode}</PRE>"; echo $this->_bouncehandler->fetch_status_messages($dcode); } else { echo "<PRE>couldn't decode</PRE>"; } echo "</P>\n"; } echo '<h2>Grab original To: and From:</h2>\\n'; echo '<p>Just in case we don\'t have an Original-recipient: field, or '; echo 'a X-Postfix-Sender: field, we can retrieve information from '; echo 'the (optional) returned message body part</p>' . PHP_EOL; $head = $this->_bouncehandler->get_head_from_returned_message_body_part($mime_sections); echo "<P>From: " . $head['From']; echo "<br>To: " . $head['To']; echo "<br>Subject: " . $head['Subject'] . "</P>"; echo "<h2>Here is the body in RFC1892 parts</h2>\n"; echo '<[>Three parts: [first_body_part], '; echo '[machine_parsable_body_part], and '; echo ' [returned_message_body_part]</p>'; echo "<TEXTAREA cols=100 rows=100>"; print_r($mime_sections); echo "</TEXTAREA>"; }