mirror of
https://github.com/e107inc/e107.git
synced 2025-06-05 18:35:01 +02:00
Fixes altBody mailing issue.
This commit is contained in:
parent
e28997f420
commit
dd08c0f078
@ -109,7 +109,12 @@ class e107Bounce
|
||||
{
|
||||
if($errors = $this->setUser_Bounced($e107_userid))
|
||||
{
|
||||
// $message .= print_a($errors,true);
|
||||
if($this->debug)
|
||||
{
|
||||
echo "<h3>Errors</h3>";
|
||||
print_a($errors);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -194,13 +199,18 @@ class e107Bounce
|
||||
|
||||
function setUser_Bounced($bounceString = '', $email='' )
|
||||
{
|
||||
if(!$email && !$bounceString){ return; }
|
||||
if(!$email && !$bounceString)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// echo "Email bounced ID: ".$id_or_email;
|
||||
require_once(e_HANDLER.'mail_manager_class.php');
|
||||
|
||||
$mailManager = new e107MailManager();
|
||||
$mailManager = e107::getBulkEmail();
|
||||
|
||||
$mailManager->controlDebug($this->debug);
|
||||
|
||||
if ($errors = $mailManager->markBounce($bounceString, $email))
|
||||
{
|
||||
{
|
||||
return $errors; // Failure
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,7 @@ class e107Email extends PHPMailer
|
||||
|
||||
|
||||
$this->MsgHTML($message); // Theoretically this should do everything, including handling of inline images.
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{ // generate the plain text as the sole part of the email
|
||||
@ -781,8 +781,8 @@ class e107Email extends PHPMailer
|
||||
|
||||
if($this->debug)
|
||||
{
|
||||
echo "<h4>e107Email::arraySet() - line ".__LINE__."</h4>";
|
||||
print_a($tmpl);
|
||||
// echo "<h4>e107Email::arraySet() - line ".__LINE__."</h4>";
|
||||
// print_a($tmpl);
|
||||
}
|
||||
|
||||
unset($eml['add_html_header']); // disable other headers when template is used.
|
||||
@ -865,8 +865,9 @@ class e107Email extends PHPMailer
|
||||
|
||||
if($this->debug)
|
||||
{
|
||||
echo "<h4>e107Email::arraySet() - line ".__LINE__."</h4>";
|
||||
print_a($eml);
|
||||
// echo "<h4>e107Email::arraySet() - line ".__LINE__."</h4>";
|
||||
return 0;
|
||||
// print_a($eml);
|
||||
//$this->PreSend();
|
||||
//$debugEml = $this->GetSentMIMEMessage().
|
||||
//print_a($debugEml);
|
||||
@ -947,7 +948,7 @@ class e107Email extends PHPMailer
|
||||
$result = TRUE; // Temporary 'success' flag
|
||||
$this->SendCount++;
|
||||
|
||||
if (($this->logEnable == 0) || ($this->logEnable == 2))
|
||||
if ($this->debug == false && (($this->logEnable == 0) || ($this->logEnable == 2)) )
|
||||
{
|
||||
// prevent user/script details being exposed in X-PHP-Script header
|
||||
$oldphpself = $_SERVER['PHP_SELF'];
|
||||
@ -969,8 +970,11 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
else
|
||||
{ // Debug
|
||||
$result = TRUE;
|
||||
//print_a($this);
|
||||
$result = true;
|
||||
// echo "<h2>SendEmail()->Body</h2>";
|
||||
// print_a($this->Body);
|
||||
// echo "<h2>SendEmail()->AltBody</h2>";
|
||||
// print_a($this->AltBody);
|
||||
if (($this->logEnable == 3) && (($this->SendCount % 7) == 4)) $result = FALSE; // Fail one email in 7 for testing
|
||||
}
|
||||
|
||||
@ -1015,6 +1019,10 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
|
||||
|
||||
function setDebug($val)
|
||||
{
|
||||
$this->debug = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after a bulk mailing completed, to tidy up nicely
|
||||
@ -1126,18 +1134,30 @@ class e107Email extends PHPMailer
|
||||
$this->IsHTML(true);
|
||||
$this->Body = $message;
|
||||
//print_a($message);
|
||||
$textMsg = str_replace(array('<br />', '<br>'), "\n", $message); // Modified to make sure newlines carried through
|
||||
$textMsg = str_replace("\n", "", $message);
|
||||
$textMsg = str_replace(array('<br />', '<br>'), "\n", $textMsg); // Modified to make sure newlines carried through
|
||||
$textMsg = preg_replace('#^.*?<body.*?>#', '', $textMsg); // Knock off everything up to and including the body statement (if present)
|
||||
$textMsg = preg_replace('#</body.*?>.*$#', '', $textMsg); // Knock off everything after and including the </body> (if present)
|
||||
$textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$textMsg)));
|
||||
if (!empty($textMsg) && empty($this->AltBody))
|
||||
|
||||
if($this->debug)
|
||||
{
|
||||
echo "<h2>".__METHOD__.' $textMsg<small> Line: '.__LINE__.'</small></h2>';
|
||||
print_a($textMsg);
|
||||
}
|
||||
|
||||
if(!empty($textMsg)) // Always set it, even if AltBody is empty.
|
||||
{
|
||||
$this->AltBody = html_entity_decode($textMsg);
|
||||
|
||||
}
|
||||
if (empty($this->AltBody))
|
||||
|
||||
if(empty($this->AltBody))
|
||||
{
|
||||
$this->AltBody = 'To view this email message, enable HTML!' . "\n\n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // End of e107Mailer class
|
||||
|
@ -500,13 +500,13 @@ class e107MailManager
|
||||
*/
|
||||
protected function checkDB($which = 1)
|
||||
{
|
||||
if (($which == 1) && ($this->db == NULL))
|
||||
if (($which == 1) && ($this->db == null))
|
||||
{
|
||||
$this->db = new db;
|
||||
$this->db = e107::getDb('mail1');
|
||||
}
|
||||
if (($which == 2) && ($this->db2 == NULL))
|
||||
if (($which == 2) && ($this->db2 == null))
|
||||
{
|
||||
$this->db2 = new db;
|
||||
$this->db2 = e107::getDb('mail2');;
|
||||
}
|
||||
}
|
||||
|
||||
@ -621,17 +621,17 @@ class e107MailManager
|
||||
{
|
||||
if (!$this->queryActive)
|
||||
{
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
if ($result = $this->db->db_Fetch(MYSQL_ASSOC))
|
||||
if ($result = $this->db->fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$this->queryActive--;
|
||||
return $this->dbToBoth($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->queryActive = FALSE; // Make sure no further attempts to read emails
|
||||
return FALSE;
|
||||
$this->queryActive = false; // Make sure no further attempts to read emails
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -714,7 +714,8 @@ class e107MailManager
|
||||
}
|
||||
$this->currentTextBody = $email['mail_body_alt']; // May be null
|
||||
}
|
||||
|
||||
|
||||
|
||||
$mailToSend = $this->makeEmailBlock($email); // Substitute mail-specific variables, attachments etc
|
||||
|
||||
|
||||
@ -729,13 +730,30 @@ class e107MailManager
|
||||
print_a($preview);
|
||||
$logName = "mailout_simulation_".$email['mail_source_id'];
|
||||
e107::getLog()->addDebug("Sending Email to <".$email['mail_recipient_name']."> ".$email['mail_recipient_email'])->toFile($logName,'Mailout Simulation Log',true);
|
||||
$result = true;
|
||||
$result = true;
|
||||
|
||||
|
||||
$this->mailer->setDebug(true);
|
||||
echo "<h2>SendEmail()->Body</h2>";
|
||||
print_a($this->mailer->Body);
|
||||
echo "<h2>SendEmail()->AltBody</h2>";
|
||||
print_a($this->mailer->AltBody);
|
||||
echo "<h1>_________________________________________________________________________</h1>";
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
// else
|
||||
{
|
||||
$result = $this->mailer->sendEmail($email['mail_recipient_email'], $email['mail_recipient_name'], $mailToSend, TRUE);
|
||||
}
|
||||
|
||||
if($this->debugMode)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Try and send
|
||||
|
||||
|
||||
@ -973,7 +991,7 @@ class e107MailManager
|
||||
$result = array_merge($result, $email['mail_overrides']);
|
||||
}
|
||||
|
||||
$title = "<h4>".__METHOD__." Line: ".__LINE__."</h4>";
|
||||
// $title = "<h4>".__METHOD__." Line: ".__LINE__."</h4>";
|
||||
// e107::getAdminLog()->addDebug($title.print_a($email,true),true);
|
||||
|
||||
if(!empty($email['mail_media']))
|
||||
@ -981,7 +999,7 @@ class e107MailManager
|
||||
$result['media'] = $email['mail_media'];
|
||||
}
|
||||
|
||||
$title2 = "<h4>".__METHOD__." Line: ".__LINE__."</h4>";
|
||||
// $title2 = "<h4>".__METHOD__." Line: ".__LINE__."</h4>";
|
||||
// e107::getAdminLog()->addDebug($title2.print_a($result,true),true);
|
||||
|
||||
$result['shortcodes']['MAILREF'] = $email['mail_source_id'];
|
||||
@ -1368,11 +1386,14 @@ class e107MailManager
|
||||
$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
|
||||
|
||||
// echo "<h4>Bounce String</h4>";
|
||||
// print_a($bounceString);
|
||||
// echo "<h4>Vals</h4>";
|
||||
// print_a($vals);
|
||||
|
||||
if($this->debugMode)
|
||||
{
|
||||
echo "<h4>Bounce String</h4>";
|
||||
print_a($bounceString);
|
||||
echo "<h4>Vals</h4>";
|
||||
print_a($vals);
|
||||
}
|
||||
|
||||
if (!is_numeric($vals[0])) // Email recipient user id number (may be zero)
|
||||
{
|
||||
@ -1448,13 +1469,13 @@ class e107MailManager
|
||||
|
||||
if(!$this->db->update('mail_content', '`mail_bounce_count` = `mail_bounce_count` + 1 WHERE `mail_source_id` = '.$vals[1]))
|
||||
{
|
||||
e107::getAdminLog()->add('Unable to increment bounce-count on mail_source_id='.$vals[1],$bounceInfo, E_LOG_FATAL, 'BOUNCE',LOG_TO_ROLLING);
|
||||
e107::getAdminLog()->add('Unable to increment bounce-count on mail_source_id='.$vals[1],$bounceInfo, E_LOG_FATAL, 'BOUNCE', LOG_TO_ROLLING);
|
||||
}
|
||||
|
||||
|
||||
if(!$this->db->update('mail_recipients', '`mail_status` = '.MAIL_STATUS_BOUNCED.' WHERE `mail_target_id` = '.$vals[2]))
|
||||
{
|
||||
e107::getAdminLog()->add('Unable to update recipient mail_status to bounce on mail_target_id = '.$vals[2],$bounceInfo, E_LOG_FATAL, 'BOUNCE',LOG_TO_ROLLING);
|
||||
e107::getAdminLog()->add('Unable to update recipient mail_status to bounce on mail_target_id = '.$vals[2],$bounceInfo, E_LOG_FATAL, 'BOUNCE', LOG_TO_ROLLING);
|
||||
}
|
||||
|
||||
$addons = array_keys($row['mail_selectors']); // trigger e_mailout.php addons. 'bounce' method.
|
||||
@ -1503,12 +1524,19 @@ class e107MailManager
|
||||
$errors[] = $err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($errors))
|
||||
{
|
||||
$logErrors =$bounceInfo;
|
||||
$logErrors['user_id'] = $uid;
|
||||
$logErrors['mailshot'] = $vals[1];
|
||||
$logErrors['mailshot_recipient'] = $vals[2];
|
||||
$logErrors['errors'] = $errors;
|
||||
$logErrors['email'] = $emailAddress;
|
||||
$logErrors['bounceString'] = $bounceString;
|
||||
$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);
|
||||
e107::getAdminLog()->add('Bounce receive error',$logErrors, E_LOG_WARNING, 'BOUNCE', LOG_TO_ROLLING);
|
||||
return $errors;
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user