Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions bounce_driver.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ class BounceHandler{

/**** INSTANTIATION *******************************************************/
public function __construct(){
$this->output[0]['action'] = "";
$this->output[0]['status'] = "";
$this->output[0]['recipient'] = "";
$this->output[0]['action'] = '';
$this->output[0]['status'] = '';
$this->output[0]['recipient'] = '';
$this->output[0]['diagnostic'] = '';
require('bounce_responses.php');
$this->bouncelist = $bouncelist;
$this->autorespondlist = $autorespondlist;
Expand All @@ -107,7 +108,7 @@ public function get_the_facts($eml){
// parse the email into data structures
$boundary = isset($this->head_hash['Content-type']['boundary']) ? $this->head_hash['Content-type']['boundary'] : '';
$mime_sections = $this->parse_body_into_mime_sections($body, $boundary);
$this->body_hash = split("\r\n", $body);
$this->body_hash = explode("\r\n", $body);
$this->first_body_hash = isset($mime_sections['first_body_part']) ? $this->parse_head($mime_sections['first_body_part']) : array();

$this->looks_like_a_bounce = $this->is_a_bounce();
Expand Down Expand Up @@ -226,7 +227,7 @@ public function get_the_facts($eml){
// Busted Exim MTA
// Up to 50 email addresses can be listed on each header.
// There can be multiple X-Failed-Recipients: headers. - (not supported)
$arrFailed = split(',', $this->head_hash['X-failed-recipients']);
$arrFailed = explode(',', $this->head_hash['X-failed-recipients']);
for($j=0; $j<count($arrFailed); $j++){
$this->output[$j]['recipient'] = trim($arrFailed[$j]);
$this->output[$j]['status'] = $this->get_status_code_from_text($this->output[$j]['recipient'],0);
Expand Down Expand Up @@ -504,7 +505,7 @@ function standard_parser($content){ // associative array orstr
}
elseif (isset($line) && isset($entity) && preg_match('/^\s+(.+)\s*/', $line) && $entity) {
$line = trim($line);
if (strpos($array[2], '=?') !== FALSE)
if ((isset($array[2])) && (strpos($array[2], '=?') !== FALSE))
$line = iconv_mime_decode($array[2], ICONV_MIME_DECODE_CONTINUE_ON_ERROR, "UTF-8");
$hash[$entity] .= ' '. $line;
}
Expand Down Expand Up @@ -552,6 +553,7 @@ function parse_machine_parsable_body_part($str){
// temporary failure in this case.
$ddc=''; $judgement='';
$ddc = $this->decode_diagnostic_code($temp['Diagnostic-code']['text']);
$this->output[0]['diagnostic'] = $ddc;
$judgement = $this->get_action_from_status_code($ddc);
if($judgement == 'transient'){
if(stristr($temp['Action'],'failed')!==FALSE){
Expand Down Expand Up @@ -672,11 +674,11 @@ function get_action_from_status_code($code){
}

function decode_diagnostic_code($dcode){
if(preg_match("/(\d\.\d\.\d)\s/", $dcode, $array)){
return $array[1];
if(preg_match_all("/(\d\.\d\.\d)\s/", $dcode, $array)){
return end(end($array));
}
else if(preg_match("/(\d\d\d)\s/", $dcode, $array)){
return $array[1];
else if(preg_match_all("/(\d\d\d)\s/", $dcode, $array)){
return end(end($array));
}
}

Expand Down