diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 97ef3cfee..1287deb54 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -447,12 +447,13 @@ class mailout_main_ui extends e_admin_ui $sendto = trim($_POST['testaddress']); $eml = array( - 'subject' => LAN_MAILOUT_113." ".$add, - 'body' => str_replace("[br]", "\n", LAN_MAILOUT_114), - 'template' => vartrue($_POST['testtemplate'],null) + 'subject' => LAN_MAILOUT_113." ".$add, + 'body' => str_replace("[br]", "\n", LAN_MAILOUT_114), + 'template' => vartrue($_POST['testtemplate'],null), + 'shortcodes' => array('USERID'=>555, 'USERNAME'=>'John Smith', 'LOGINNAME'=>'TestName', 'PASSWORD'=>'xxxxxxx', 'ACTIVATION_LINK'=>SITEURL."signup.php#activate") ); - if (!e107::getEmail()->sendEmail($sendto,LAN_MAILOUT_189,$eml)) + if (!e107::getEmail()->sendEmail($sendto, LAN_MAILOUT_189, $eml)) { $mes->addError(($pref['mailer'] == 'smtp') ? LAN_MAILOUT_67 : LAN_MAILOUT_106); } diff --git a/e107_handlers/bounce_handler.php b/e107_handlers/bounce_handler.php index caa92ad20..8386cdcc4 100644 --- a/e107_handlers/bounce_handler.php +++ b/e107_handlers/bounce_handler.php @@ -14,7 +14,6 @@ if (!defined('e107_INIT')) require_once($class2); } -echo "test"; $bnc = new e107Bounce; $process = (varset($_GET['eml']) && $_E107['debug']) ? $_GET['eml'].".eml" : FALSE; @@ -43,6 +42,8 @@ class e107Bounce $multiArray = Bouncehandler::get_the_facts($strEmail); $head = BounceHandler::parse_head($strEmail); + $message = null; + $e107_userid = (isset($head['X-e107-id'])) ? $head['X-e107-id'] : $this->getHeader($strEmail,'X-e107-id'); @@ -50,12 +51,16 @@ class e107Bounce { require_once(e_HANDLER."mail.php"); $message = "Your Bounce Handler is working. The data of the email you sent is displayed below.
"; + if($e107_userid) { $message .= "A user-id was detected in the email you sent: ".$e107_userid."
"; } - $message .= "
"; - $message .= "
".print_r($multiArray,TRUE). "
"; + + $message .= "

Head

"; + $message .= print_a($head,true); + $message .= "

Emails Found

".print_r($multiArray,TRUE). "
"; + $message .= "
".$strEmail. "
"; if(varset($_GET['eml'])) @@ -64,15 +69,26 @@ class e107Bounce } else { - sendemail($pref['siteadminemail'], SITENAME." :: Bounce-Handler.", $message, $pref['siteadmin'],$pref['siteadminemail'], $pref['siteadmin']); } } - if($e107_userid && ($this->setUser_Bounced($e107_userid)==true)) + + + if(!empty($e107_userid)) { - return; + if($errors = $this->setUser_Bounced($e107_userid)) + { + $mesage .= print_a($errors); + } + } - + + if(!empty($message)) + { + sendemail($pref['siteadminemail'], SITENAME." :: Bounce-Handler.", $message, $pref['siteadmin'],$pref['siteadminemail'], $pref['siteadmin']); + } + + return; /* echo "
";
 		print_r($multiArray);
 		echo "
"; @@ -126,7 +142,7 @@ class e107Bounce { if(strpos($val,$id.":")!== false) { - return intval(str_replace($id.":","",$val)); + return str_replace($id.":","",$val); } } } @@ -140,12 +156,12 @@ class e107Bounce require_once(e_HANDLER.'mail_manager_class.php'); $mailManager = new e107MailManager(); - if ($mailManager->markBounce($bounceString, $email)) - { // Success + if ($errors = $mailManager->markBounce($bounceString, $email)) + { + return $errors; // Failure } - // Failure - // $query = (is_numeric($id_or_email)) ? "user_ban = 3 WHERE user_id = ".intval($id_or_email)." LIMIT 1" : "user_ban = 3 WHERE user_email = '".$id_or_email."' "; - // return e107::getDb()->db_Update('user',$query); + + } diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index eb969cc4d..5095f1d5a 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -1243,6 +1243,8 @@ class e107MailManager public function markBounce($bounceString, $emailAddress = '') { + $bounceString = trim($bounceString); + $bounceInfo = array('mail_bounce_string' => $bounceString, 'mail_recipient_email' => $emailAddress); // Ready for event data $errors = array(); // Log all errors, at least until proven $vals = explode('/', $bounceString); // Should get one or four fields @@ -1261,10 +1263,6 @@ class e107MailManager if (count($vals) == 4) // Admin->Mailout format. { - if (md5($vals[0].'/'.$vals[1].'/'.$vals[2].'/') != $vals[3]) // 'Extended' ID has md5 validation - { - $errors[] = 'Bad md5'; - } if (!is_numeric($vals[1])) // Email body record number { @@ -1276,10 +1274,22 @@ class e107MailManager $errors[] = 'Bad recipient record: '.$vals[2]; } + $vals[0] = intval($vals[0]); $vals[1] = intval($vals[1]); $vals[2] = intval($vals[2]); + $vals[3] = trim($vals[3]); + + + $hash = ($vals[0].'/'.$vals[1].'/'.$vals[2].'/'); - if (count($errors) == 0) + if (md5($hash) != $vals[3]) // 'Extended' ID has md5 validation + { + $errors[] = 'Bad md5'; + $errors[] = print_r($vals,true); + $errors[] = 'hash:'.md5($hash); + } + + if (empty($errors)) { $this->checkDB(1); // Look up in mailer DB if no errors so far @@ -1374,21 +1384,23 @@ class e107MailManager } } - if (count($errors)) + if (!empty($errors)) { - $logString = $bounceString.' ('.$emailAddress.')[!br!]'.implode('[!br!]',$errors); + $logString = $bounceString.' ('.$emailAddress.')[!br!]'.implode('[!br!]',$errors).implode('[!br!]',$bounceInfo); // e107::getAdminLog()->e_log_event(10,-1,'BOUNCE','Bounce receive error',$logString, FALSE,LOG_TO_ROLLING); e107::getAdminLog()->add('Bounce receive error',$logString, E_LOG_WARNING, 'BOUNCE', LOG_TO_ROLLING); - return false; + return $errors; + } + else + { + // e107::getAdminLog()->e_log_event(10,-1,'BOUNCE','Bounce received/logged',$bounceInfo, FALSE,LOG_TO_ROLLING); + e107::getAdminLog()->add('Bounce received/logged',$bounceInfo, E_LOG_INFORMATIVE, 'BOUNCE',LOG_TO_ROLLING); } - // e107::getAdminLog()->e_log_event(10,-1,'BOUNCE','Bounce received/logged',$bounceInfo, FALSE,LOG_TO_ROLLING); - - e107::getAdminLog()->add('Bounce received/logged',$bounceInfo, E_LOG_INFORMATIVE, 'BOUNCE',LOG_TO_ROLLING); e107::getEvent()->trigger('mailbounce', $bounceInfo); - return true; + return false; }