1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 13:11:52 +02:00

Mailout bounce handling fixes.

This commit is contained in:
Cameron 2014-10-22 17:58:20 -07:00
parent be970117ff
commit a3bb284031
9 changed files with 243 additions and 113 deletions

View File

@ -600,7 +600,7 @@ class mailout_main_ui extends e_admin_ui
'subject' => $data['mail_subject'],
'body' => $data['mail_body'],
'template' => $data['mail_send_style'],
'shortcodes' => array('USERNAME'=>'John Example', 'DISPLAYNAME'=> 'John Example', 'USERID'=>'555', 'UNSUBSCRIBE'=>SITEURL."unsubscribe/?id=example1234567"),
'shortcodes' => array('USERNAME'=>'John Example', 'DISPLAYNAME'=> 'John Example', 'USERID'=>'555', 'MAILREF'=>$_GET['id'], 'NEWSLETTER'=>SITEURL."newsletter/?id=example1234567", 'UNSUBSCRIBE'=>SITEURL."unsubscribe/?id=example1234567"),
'media' => $data['mail_media'],
);
@ -753,6 +753,11 @@ class mailout_main_ui extends e_admin_ui
$frm = e107::getForm();
$mes = e107::getMessage();
$ns = e107::getRender();
if($pref['mail_bounce'] == 'auto' && !empty($pref['mail_bounce_email']) && !is_executable(e_HANDLER."bounce_handler.php"))
{
$mes->addWarning('Your bounce_handler.php file is NOT executable');
}
e107::getCache()->CachePageMD5 = '_';
@ -782,7 +787,7 @@ class mailout_main_ui extends e_admin_ui
<tr>
<td style='vertical-align:top'>".LAN_MAILOUT_115."<br /></td>
<td>
<select class='tbox' name='mailer' onchange='disp(this.value)'>\n";
<select class='tbox input-xxlarge' name='mailer' onchange='disp(this.value)'>\n";
$mailers = array('php','smtp','sendmail');
foreach($mailers as $opt)
{
@ -886,17 +891,15 @@ class mailout_main_ui extends e_admin_ui
<tr>
<td>".LAN_MAILOUT_25."</td>
<td class='form-inline'> ".LAN_MAILOUT_26."
<input class='tbox e-spinner' size='3' type='text' name='mail_pause' value='".$pref['mail_pause']."' /> ".LAN_MAILOUT_27.
"<input class='tbox e-spinner' size='3' type='text' name='mail_pausetime' value='".$pref['mail_pausetime']."' /> ".LAN_MAILOUT_29.".<br />
<td class='form-inline'> ".LAN_MAILOUT_26." ".$frm->number('mail_pause', $pref['mail_pause'])." ".LAN_MAILOUT_27." ".
$frm->number('mail_pausetime', $pref['mail_pausetime'])." ".LAN_MAILOUT_29.".<br />
<span class='field-help'>".LAN_MAILOUT_30."</span>
</td>
</tr>\n
<tr>
<td>".LAN_MAILOUT_156."</td>
<td><input class='tbox e-spinner' size='3' type='text' name='mail_workpertick' value='".varset($pref['mail_workpertick'],5)."' />
<span class='field-help'>".LAN_MAILOUT_157."</span>
<td>".$frm->number('mail_workpertick',varset($pref['mail_workpertick'],5))."<span class='field-help'>".LAN_MAILOUT_157."</span>
</td>
</tr>\n";
@ -981,7 +984,10 @@ class mailout_main_ui extends e_admin_ui
<col class='col-control' />
</colgroup>
<tbody>
<tr><td>".LAN_MAILOUT_32."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_email2' value=\"".$pref['mail_bounce_email']."\" /></td></tr>
<tr>
<td>".LAN_MAILOUT_32."</td>
<td>".$frm->text('mail_bounce_email2', $pref['mail_bounce_email'], 40, 'size=xxlarge')."</td>
</tr>
<tr>
<td>".LAN_MAILOUT_233."</td><td><b>".(e_DOCROOT).e107::getFolder('handlers')."bounce_handler.php</b>";
@ -1006,11 +1012,25 @@ class mailout_main_ui extends e_admin_ui
<col class='col-label' />
<col class='col-control' />
</colgroup>
<tbody>
<tbody>";
$bouncePrefs = array('mail_bounce_email'=>LAN_MAILOUT_32, 'mail_bounce_pop3'=>LAN_MAILOUT_33, 'mail_bounce_user'=>LAN_MAILOUT_34, 'mail_bounce_pass'=>LAN_MAILOUT_35);
foreach($bouncePrefs as $key =>$label)
{
$text .= "<tr><td>".$label."</td><td>".$frm->text($key,$pref[$key],40,'size=xlarge')."</td></tr>";
}
/*
$text .= "
<tr><td>".LAN_MAILOUT_32."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_email' value=\"".$pref['mail_bounce_email']."\" /></td></tr>
<tr><td>".LAN_MAILOUT_33."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_pop3' value=\"".$pref['mail_bounce_pop3']."\" /></td></tr>
<tr><td>".LAN_MAILOUT_34."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_user' value=\"".$pref['mail_bounce_user']."\" /></td></tr>
<tr><td>".LAN_MAILOUT_35."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_pass' value=\"".$pref['mail_bounce_pass']."\" /></td></tr>
";
*/
$text .= "
<tr><td>".LAN_MAILOUT_120."</td><td><select class='tbox' name='mail_bounce_type'>\n
<option value=''>&nbsp;</option>\n
<option value='pop3'".(($pref['mail_bounce_type']=='pop3') ? " selected='selected'" : "").">".LAN_MAILOUT_121."</option>\n
@ -1450,8 +1470,8 @@ $mailAdmin = new mailoutAdminClass($action); // This decodes parts of the quer
e107::setRegistry('_mailout_admin', $mailAdmin);
if ($mailAdmin->loadMailHandlers() == 0)
{ // No mail handlers loaded
echo 'No mail handlers loaded!!';
exit;
// echo 'No mail handlers loaded!!';
//exit;
}
require_once(e_ADMIN.'auth.php');

View File

@ -4,7 +4,7 @@
// WARNING, any echoed output from this script will be returned to the sender as a bounce message.
$_E107['debug'] = FALSE;
$_E107['debug'] = true;
if (!defined('e107_INIT'))
@ -14,6 +14,7 @@ if (!defined('e107_INIT'))
require_once($class2);
}
echo "test";
$bnc = new e107Bounce;
$process = (varset($_GET['eml']) && $_E107['debug']) ? $_GET['eml'].".eml" : FALSE;
@ -33,13 +34,17 @@ class e107Bounce
if(!$strEmail)
{
if($_E107['debug'] === true)
{
echo "Couldn't get email data";
}
return;
}
$multiArray = Bouncehandler::get_the_facts($strEmail);
$head = BounceHandler::parse_head($strEmail);
$e107_userid = (isset($head['X-e107-id'])) ? intval($head['X-e107-id']) : $this->getHeader($strEmail,'X-e107-id');
$e107_userid = (isset($head['X-e107-id'])) ? $head['X-e107-id'] : $this->getHeader($strEmail,'X-e107-id');
if($_E107['debug'])
{
@ -51,11 +56,19 @@ class e107Bounce
}
$message .= "<br />";
$message .= "<pre>".print_r($multiArray,TRUE). "</pre>";
$message .= "<pre>".$strEmail. "</pre>";
sendemail($pref['siteadminemail'], SITENAME." :: Bounce-Handler.", $message, $pref['siteadmin'],$pref['siteadminemail'], $pref['siteadmin']);
$message .= "<pre>".$strEmail. "</pre>";
if(varset($_GET['eml']))
{
// echo $message;
}
else
{
sendemail($pref['siteadminemail'], SITENAME." :: Bounce-Handler.", $message, $pref['siteadmin'],$pref['siteadminemail'], $pref['siteadmin']);
}
}
if($e107_userid && ($this->setUser_Bounced($e107_userid)==TRUE))
if($e107_userid && ($this->setUser_Bounced($e107_userid)==true))
{
return;
}
@ -76,7 +89,7 @@ class e107Bounce
{
case 'failed':
e107::getEvent()->trigger('email-bounce-failed', $the);
$this->setUser_Bounced($the['user_email']);
$this->setUser_Bounced(null, $the['user_email']);
break;
case 'transient':
@ -85,7 +98,7 @@ class e107Bounce
e107::getEvent()->trigger('email-bounce-transient', $the);
if($num_attempts > 10)
{
$this->setUser_Bounced($the['user_email'], $the['user_id']);
$this->setUser_Bounced($the['user_id'], $the['user_email']);
}
else
{
@ -111,7 +124,7 @@ class e107Bounce
$tmp = explode("\n",$message);
foreach($tmp as $val)
{
if(strpos($val,$id.":")!==FALSE)
if(strpos($val,$id.":")!== false)
{
return intval(str_replace($id.":","",$val));
}
@ -120,12 +133,13 @@ class e107Bounce
function setUser_Bounced($email, $bounceString = '')
function setUser_Bounced($bounceString = '', $email='' )
{
if(!$email && !$bounceString){ return; }
// echo "Email bounced ID: ".$id_or_email;
require_once(e_HANDLER.'mail_manager_class.php');
$mailHandler = new e107MailManager();
$mailManager = new e107MailManager();
if ($mailManager->markBounce($bounceString, $email))
{ // Success
}

View File

@ -2961,7 +2961,7 @@ class e_parser
e107::getFile()->getRemoteFile($thumbSrc, $filename,'media');
}
return "<a href='".$url."'><img class='video-responsive video-thumbnail' src='".$filepath."' alt='Youtube Video' title='Click to view on Youtube' />
return "<a href='".$url."'><img class='video-responsive video-thumbnail' src='{e_MEDIA}".$filename."' alt='Youtube Video' title='Click to view on Youtube' />
<div class='video-thumbnail-caption'><small>Click to watch video</small></div></a>";
}

View File

@ -625,7 +625,7 @@ class e107Email extends PHPMailer
$eml['shortcodes']['BODY'] = $tp->toEmail($eml['body']);
$eml['shortcodes']['SUBJECT'] = $eml['subject'];
$eml['shortcodes']['THEME'] = e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
$eml['shortcodes']['THEME'] = ($this->previewMode == true) ? e_THEME_ABS.$this->pref['sitetheme'].'/' : e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
if(!empty($eml['media']) && is_array($eml['media']))
@ -642,7 +642,7 @@ class e107Email extends PHPMailer
}
else
{
$eml['shortcodes'][$id] = "<div class='media media-image'><img class='img-responsive' src='".$tp->replaceConstants($val['path'])."' alt='' /></div>";
$eml['shortcodes'][$id] = "<div class='media media-image'><img class='img-responsive' src='".$val['path']."' alt='' /></div>";
}
}
@ -687,9 +687,6 @@ class e107Email extends PHPMailer
if($tmpl = e107::getCoreTemplate('email', $eml['template'], 'front', true)) //FIXME - Core template is failing with template 'notify'. Works with theme template. Issue with core template registry?
{
// $eml['shortcodes']['BODY'] = $tp->toEmail($eml['body']);
// $eml['shortcodes']['SUBJECT'] = $eml['subject'];
// $eml['shortcodes']['THEME'] = e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
$eml['shortcodes'] = $this->processShortcodes($eml);
@ -697,7 +694,7 @@ class e107Email extends PHPMailer
$emailBody = $tmpl['header']. $tmpl['body'] . $tmpl['footer'];
$eml['body'] = $tp->parseTemplate($emailBody, true, varset($eml['shortcodes'],null));
$eml['body'] = $tp->parseTemplate($emailBody, true, $eml['shortcodes']);
// $eml['body'] = ($tp->toEmail($tmpl['header']). str_replace('{BODY}', $eml['body'], $tmpl['body']). $tp->toEmail($tmpl['footer']));
@ -717,7 +714,7 @@ class e107Email extends PHPMailer
{
echo "<h4>Couldn't find email template: ".$eml['template']."</h4>";
}
$emailBody = $eml['body'];
// $emailBody = $eml['body'];
if (vartrue($eml['subject'])) $this->Subject = $tp->parseTemplate($eml['subject'], true, varset($eml['shortcodes'],null));
e107::getMessage()->addDebug("Couldn't find email template: ".$eml['template']);
@ -855,8 +852,17 @@ class e107Email extends PHPMailer
if (($this->logEnable == 0) || ($this->logEnable == 2))
{
// prevent user/script details being exposed in X-PHP-Script header
$oldphpself = $_SERVER['PHP_SELF'];
$oldremoteaddr = $_SERVER['REMOTE_ADDR'];
$_SERVER['PHP_SELF'] = "/";
$_SERVER['REMOTE_ADDR'] = $_SERVER['SERVER_ADDR'];
$result = $this->Send(); // Actually send email
$_SERVER['PHP_SELF'] = $oldphpself;
$_SERVER['REMOTE_ADDR'] = $oldremoteaddr;
if (!$bulkmail && !$this->SMTPKeepAlive && ($this->Mailer == 'smtp')) $this->SmtpClose();
}
else
@ -867,6 +873,7 @@ class e107Email extends PHPMailer
}
$this->TotalSent++;
if (($this->pause_amount > 0) && ($this->SendCount >= $this->pause_amount))
{
if ($this->SMTPKeepAlive && ($this->Mailer == 'smtp')) $this->SmtpClose();
@ -931,8 +938,8 @@ class e107Email extends PHPMailer
*/
public function MsgHTML($message, $basedir = '')
{
$tp = e107::getParser();
preg_match_all("/(src|background)=([\"\'])(.*)\\2/Ui", $message, $images); // Modified to accept single quotes as well
if(isset($images[3]) && ($this->previewMode === false))
{
@ -943,10 +950,12 @@ class e107Email extends PHPMailer
print_a($images[3]);
}
$tp = e107::getParser();
foreach($images[3] as $i => $url)
{
// do not change urls for absolute images (thanks to corvuscorax)
if (!preg_match('#^[A-z]+://#',$url))
{
@ -999,6 +1008,11 @@ class e107Email extends PHPMailer
}
}
if($this->previewMode === true)
{
$message = $tp->replaceConstants($message, 'abs');
}
$this->IsHTML(true);
$this->Body = $message;

View File

@ -581,7 +581,8 @@ class e107MailManager
AND (ms.`mail_last_date` >= ".time()." OR ms.`mail_last_date`=0)
ORDER BY ms.`mail_e107_priority` DESC {$count}";
// echo $query.'<br />';
$result = $this->db->db_Select_gen($query);
$result = $this->db->gen($query);
if ($result !== FALSE)
{
$this->queryActive = $result; // Note number of emails to go
@ -766,9 +767,9 @@ class e107MailManager
if ($email['mail_notify_complete'] & 1)
{ // Notify email initiator
if ($this->db2->db_Select('user', 'user_name, user_email', '`user_id`='.intval($email['mail_creator'])))
if ($this->db2->select('user', 'user_name, user_email', '`user_id`='.intval($email['mail_creator'])))
{
$row = $this->db2->db_Fetch(MYSQL_ASSOC);
$row = $this->db2->fetch(MYSQL_ASSOC);
require_once(e_HANDLER.'mail.php');
$mailer = new e107Email();
$mailer->sendEmail($row['user_name'], $row['user_email'], $message,FALSE);
@ -777,6 +778,7 @@ class e107MailManager
if ($email['mail_notify_complete'] & 2)
{ // Do e107 notify
require_once(e_HANDLER."notify_class.php");
notify_maildone($message);
}
e107::getEvent()->trigger('maildone', $email);
@ -882,6 +884,8 @@ class e107MailManager
$title2 = "<h4>".__METHOD__." Line: ".__LINE__."</h4>";
e107::getAdminLog()->addDebug($title2.print_a($result,true),true);
$result['shortcodes']['MAILREF'] = $email['mail_source_id'];
return $result;
}
@ -934,14 +938,14 @@ class e107MailManager
if ($isNew === true)
{
unset($dbData['mail_source_id']); // Just in case - there are circumstances where might be set
$result = $this->db2->db_Insert('mail_content', array('data' => $dbData,
$result = $this->db2->insert('mail_content', array('data' => $dbData,
'_FIELD_TYPES' => $this->dbTypes['mail_content'], '_NOTNULL' => $this->dbNull['mail_content']));
}
else
{
if (isset($dbData['mail_source_id']))
{
$result = $this->db2->db_Update('mail_content', array('data' => $dbData,
$result = $this->db2->update('mail_content', array('data' => $dbData,
'_FIELD_TYPES' => $this->dbTypes['mail_content'],
'WHERE' => '`mail_source_id` = '.intval($dbData['mail_source_id'])));
if ($result !== FALSE) { $result = $dbData['mail_source_id']; }
@ -970,11 +974,11 @@ class e107MailManager
return FALSE;
}
$this->checkDB(2); // Make sure we have a DB object to use
if ($this->db2->db_Select('mail_content', '*', '`mail_source_id`='.$mailID) === FALSE)
if ($this->db2->select('mail_content', '*', '`mail_source_id`='.$mailID) === FALSE)
{
return FALSE;
}
$mailData = $this->db2->db_Fetch(MYSQL_ASSOC);
$mailData = $this->db2->fetch();
return $this->dbToMail($mailData, $addMissing); // Convert to 'flat array' format
}
@ -991,20 +995,23 @@ class e107MailManager
$result = array();
if ($actions == 'all') $actions = 'content,recipients';
$actArray = explode(',', $actions);
if (!is_numeric($mailID) || ($mailID == 0))
{
return FALSE;
}
$this->checkDB(2); // Make sure we have a DB object to use
if (isset($actArray['content']))
{
$result['content'] = $this->db2->db_Delete('mail_content', '`mail_source_id`='.$mailID);
$result['content'] = $this->db2->delete('mail_content', '`mail_source_id`='.$mailID);
}
if (isset($actArray['recipients']))
{
$result['recipients'] = $this->db2->db_Delete('mail_recipients', '`mail_detail_id`='.$mailID);
$result['recipients'] = $this->db2->delete('mail_recipients', '`mail_detail_id`='.$mailID);
}
return $result;
}
@ -1161,15 +1168,17 @@ class e107MailManager
$query .= '`mail_notify_complete`='.intval($notify).', `mail_content_status` = '.($hold ? MAIL_STATUS_HELD : MAIL_STATUS_PENDING).$lt.' WHERE `mail_source_id` = '.intval($handle);
// echo "Update mail body: {$query}<br />";
// Set status of email body first
if (!$this->db->db_Update('mail_content',$query))
if (!$this->db->update('mail_content',$query))
{
$this->e107->admin_log->e_log_event(10,-1,'MAIL','Activate/hold mail','mail_content: '.$query.'[!br!]Fail: '.$this->db->mySQLlastErrText,FALSE,LOG_TO_ROLLING);
return FALSE;
}
// Now set status of individual emails
$query = '`mail_status` = '.($hold ? MAIL_STATUS_HELD : (MAIL_STATUS_PENDING + e107MailManager::E107_EMAIL_MAX_TRIES)).$ft.' WHERE `mail_detail_id` = '.intval($handle);
// echo "Update individual emails: {$query}<br />";
if (FALSE === $this->db->db_Update('mail_recipients',$query))
if (FALSE === $this->db->update('mail_recipients',$query))
{
$this->e107->admin_log->e_log_event(10,-1,'MAIL','Activate/hold mail','mail_recipient: '.$query.'[!br!]Fail: '.$this->db->mySQLlastErrText,FALSE,LOG_TO_ROLLING);
return FALSE;
@ -1188,12 +1197,12 @@ class e107MailManager
if (($handle <= 0) || !is_numeric($handle)) return FALSE;
$this->checkDB(1); // Make sure DB object created
// Set status of individual emails first, so we can get a count
if (FALSE === ($count = $this->db->db_Update('mail_recipients','`mail_status` = '.MAIL_STATUS_CANCELLED.' WHERE `mail_detail_id` = '.intval($handle).' AND `mail_status` >'.MAIL_STATUS_FAILED)))
if (FALSE === ($count = $this->db->update('mail_recipients','`mail_status` = '.MAIL_STATUS_CANCELLED.' WHERE `mail_detail_id` = '.intval($handle).' AND `mail_status` >'.MAIL_STATUS_FAILED)))
{
return FALSE;
}
// Now do status of email body - no emails to go, add those not sent to fail count
if (!$this->db->db_Update('mail_content','`mail_content_status` = '.MAIL_STATUS_PARTIAL.', `mail_togo_count`=0, `mail_fail_count` = `mail_fail_count` + '.intval($count).' WHERE `mail_source_id` = '.intval($handle)))
if (!$this->db->update('mail_content','`mail_content_status` = '.MAIL_STATUS_PARTIAL.', `mail_togo_count`=0, `mail_fail_count` = `mail_fail_count` + '.intval($count).' WHERE `mail_source_id` = '.intval($handle)))
{
return FALSE;
}
@ -1211,13 +1220,13 @@ class e107MailManager
if (($handle <= 0) || !is_numeric($handle)) return FALSE;
$this->checkDB(1); // Make sure DB object created
// Set status of individual emails first, so we can get a count
if (FALSE === ($count = $this->db->db_Update('mail_recipients','`mail_status` = '.MAIL_STATUS_HELD.' WHERE `mail_detail_id` = '.intval($handle).' AND `mail_status` >'.MAIL_STATUS_FAILED)))
if (FALSE === ($count = $this->db->update('mail_recipients','`mail_status` = '.MAIL_STATUS_HELD.' WHERE `mail_detail_id` = '.intval($handle).' AND `mail_status` >'.MAIL_STATUS_FAILED)))
{
return FALSE;
}
if ($count == 0) return TRUE; // If zero count, must have held email just as queue being emptied, so don't touch main status
if (!$this->db->db_Update('mail_content','`mail_content_status` = '.MAIL_STATUS_HELD.' WHERE `mail_source_id` = '.intval($handle)))
if (!$this->db->update('mail_content','`mail_content_status` = '.MAIL_STATUS_HELD.' WHERE `mail_source_id` = '.intval($handle)))
{
return FALSE;
}
@ -1233,83 +1242,153 @@ class e107MailManager
*/
public function markBounce($bounceString, $emailAddress = '')
{
$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
$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 (!is_numeric($vals[0])) // Email recipient user id number (may be zero)
{
$errors[] = 'Bad user ID: '.$vals[0];
}
$uid = intval($vals[0]); // User ID (zero is valid)
if (count($vals) == 4)
if (count($vals) == 4) // Admin->Mailout format.
{
if (md5($vals[0].'/'.$vals[1].'/'.$vals[2].'/') != $vals[3])
{ // 'Extended' ID has md5 validation
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
{
$errors[] = 'Bad body record: '.$vals[1];
}
if (!is_numeric($vals[2])) // Email recipient table record number
{
$errors[] = 'Bad recipient record: '.$vals[2];
}
$vals[1] = intval($vals[1]);
$vals[2] = intval($vals[2]);
if (count($errors) == 0)
{ // Look up in mailer DB if no errors so far
$this->checkDB(1);
if (FALSE === ($this->db->db_Select_gen(
"SELECT mr.`mail_recipient_id`, mr.`mail_recipient_email`, mr.`mail_recipient_name` FROM `#mail_recipients` AS mr
LEFT JOIN `#mail_content` as mc ON mr.`mail_detail_id` = mc.`mail_source_id`
{
$this->checkDB(1); // Look up in mailer DB if no errors so far
if (false === ($this->db->gen(
"SELECT mr.`mail_recipient_id`, mr.`mail_recipient_email`, mr.`mail_recipient_name`, mr.mail_target_info,
mc.mail_create_date, mc.mail_start_send, mc.mail_end_send, mc.`mail_title`, mc.`mail_subject`, mc.`mail_creator`, mc.`mail_other` FROM `#mail_recipients` AS mr
LEFT JOIN `#mail_content` as mc ON mr.`mail_detail_id` = mc.`mail_source_id`
WHERE mr.`mail_target_id` = {$vals[2]} AND mc.`mail_source_id` = {$vals[1]}")))
{ // Invalid mailer record
$errors[] = 'Not found in DB: '.$vals[1].'/'.$vals[2];
}
$row = $this->db->db_Fetch(MYSQL_ASSOC);
if ($emailAddress && ($emailAddress != $row['mail_recipient_email']))
{ // Email address mismatch
$row = $this->db->fetch(MYSQL_ASSOC);
$row = $this->dbToBoth($row);
$bounceInfo = $row;
if ($emailAddress && ($emailAddress != $row['mail_recipient_email'])) // Email address mismatch
{
$errors[] = 'Email address mismatch: '.$emailAddress.'/'.$row['mail_recipient_email'];
}
if ($uid != $row['mail_recipient_id'])
{ // User ID mismatch
if ($uid != $row['mail_recipient_id']) // User ID mismatch
{
$errors[] = 'User ID mismatch: '.$uid.'/'.$row['mail_recipient_id'];
}
if (count($errors) == 0)
{ // All passed - can update mailout databases
$this->db->db_Update('mail_content', '`mail_bounce_count` = `mail_bounce_count` + 1 WHERE `mail_source_id` = '.$vals[1]);
$this->db->db_Update('mail_recipients', '`mail_status` = '.MAIL_STATUS_BOUNCED.' WHERE `mail_target_id` = '.$vals[2]);
$bounceInfo['mail_source_id'] = $vals[1];
$bounceInfo['mail_target_id'] = $vals[2];
$bounceInfo['mail_recipient_id'] = $uid;
$bounceInfo['mail_recipient_name'] = $row['mail_recipient_name'];
if (count($errors) == 0) // All passed - can update mailout databases
{
$bounceInfo['mail_source_id'] = $vals[1];
$bounceInfo['mail_target_id'] = $vals[2];
$bounceInfo['mail_recipient_id'] = $uid;
$bounceInfo['mail_recipient_name'] = $row['mail_recipient_name'];
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);
}
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);
}
$addons = array_keys($row['mail_selectors']); // trigger e_mailout.php addons. 'bounce' method.
foreach($addons as $plug)
{
if($plug == 'core')
{
require_once(e_HANDLER.'user_handler.php');
if($err = userHandler::userStatusUpdate('bounce', $uid, $emailAddress));
{
$errors[] = $err;
}
}
else
{
if($cls = e107::getAddon($plug,'e_mailout'))
{
if(e107::callMethod($cls, 'bounce', $bounceInfo)===false)
{
e107::getAdminLog()->add($plug.' bounce process failed',$bounceInfo, E_LOG_FATAL, 'BOUNCE',LOG_TO_ROLLING);
}
}
}
}
}
// echo e107::getMessage()->render();
// print_a($bounceInfo);
}
}
if ((count($vals) != 1) && (count($vals) != 4))
elseif ((count($vals) != 1) && (count($vals) != 4)) // invalid e107-id header.
{
$errors[] = 'Bad element count: '.count($vals);
}
elseif ($uid || $emailAddress)
{ // Now log the bounce against the user (user handler will do any required logging)
elseif ($uid || $emailAddress) // Not using admin->mailout, so just update the user table for user_id = $uid;
{
require_once(e_HANDLER.'user_handler.php');
$result = userHandler::userStatusUpdate('bounce', $uid, $emailAddress);
if ($result) // Returns FALSE if update successful
if($err = userHandler::userStatusUpdate('bounce', $uid, $emailAddress))
{
$errors[] = $result;
$errors[] = $err;
}
}
if (count($errors))
{
$logString = $bounceString.' ('.$emailAddress.')[!br!]'.implode('[!br!]',$errors);
$this->e107->admin_log->e_log_event(10,-1,'BOUNCE','Bounce receive error',$logString,FALSE,LOG_TO_ROLLING);
return FALSE;
// 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;
}
$this->e107->admin_log->e_log_event(10,-1,'BOUNCE','Bounce received/logged',$bounceString.' ('.$emailAddress.')',FALSE,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 true;
}

View File

@ -944,7 +944,6 @@ class mailoutAdminClass extends e107MailManager
* @param $name name of item
* @return text for display
*/
//FIXME use $frm->select() instead.
public function sendStyleSelect($curval = '', $name = 'email_send_style', $incTemplates = TRUE)
{
@ -954,24 +953,24 @@ class mailoutAdminClass extends e107MailManager
'texttheme' => LAN_MAILOUT_127
);
$text = "<select class='tbox' name='{$name}' required>\n";
foreach($emFormat as $key => $val)
{
$selected = ($key == $curval)? " selected='selected'": '';
$text .= "<option value='" . $key . "'{$selected}>" . $val . "</option>\n";
}
if($incTemplates)
{
$tList = self::getEmailTemplateNames('user');
foreach($tList as $key => $val)
{
$selected = ($key == $curval)? " selected='selected'": '';
$text .= "<option value='" . $key . "'{$selected}>" . LAN_MAILOUT_258 . $val . "</option>\n";
}
$emFormat[$key] = LAN_MAILOUT_258 . $val;
}
}
$text .= "</select>\n";
return $text;
if(empty($curval))
{
$curval = e107::getConfig()->get('mail_sendstyle');
}
return e107::getForm()->select($name,$emFormat, $curval, 'required=1&size=xxlarge');
}
/**

View File

@ -379,10 +379,10 @@ define("LAN_AL_MISC_07", "");
define("LAN_AL_PING_01", "Ping to service");
define("LAN_AL_ADMINUI_01", "Admin-UI DB Table Insert");
define("LAN_AL_ADMINUI_02", "Admin-UI DB Table Update");
define("LAN_AL_ADMINUI_03", "Admin-UI DB Table Delete");
define("LAN_AL_ADMINUI_04", "Admin-UI DB Error");
define("LAN_AL_ADMINUI_01", "Admin-UI DB Table Insert: [x]");
define("LAN_AL_ADMINUI_02", "Admin-UI DB Table Update: [x]");
define("LAN_AL_ADMINUI_03", "Admin-UI DB Table Delete: [x]");
define("LAN_AL_ADMINUI_04", "Admin-UI DB Error: [x]");
?>

View File

@ -250,7 +250,7 @@ define("LAN_MAILOUT_231", "Bounced emails - Processing method");
define("LAN_MAILOUT_232", "None");
define("LAN_MAILOUT_233", "Auto-process script");
define("LAN_MAILOUT_234", "Mail account");
define("LAN_MAILOUT_235", "(Your server has to be configured to use this script)");
define("LAN_MAILOUT_235", "(Your server must forward or 'pipe' from the email address above to the script path above.)");
define("LAN_MAILOUT_236", "Last Bounce Processed");
define("LAN_MAILOUT_237", "Summary counters updated on --COUNT-- emails");
define("LAN_MAILOUT_238", "Earliest time to send");

View File

@ -8,10 +8,6 @@
*
* Newsletter plugin - mailout function
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/newsletter/e_mailout.php,v $
* $Revision$
* $Date$
* $Author$
*
*/
@ -102,7 +98,7 @@ class newsletter_mailout
$qry = "SELECT newsletter_id,newsletter_subscribers FROM `#newsletter` WHERE (`newsletter_parent`=0) AND (`newsletter_id` IN ({$selectVals}))";
// echo "Selector {$selectVals} query: ".$qry.'<br />';
if (!($sql->db_Select_gen($qry))) return FALSE;
if (!($sql->gen($qry))) return FALSE;
$this->selectorActive = TRUE;
$this->mail_count = 1; // We have no idea of how many subscribers without reading all relevant DB records
$this->mail_read = 0;
@ -134,7 +130,7 @@ class newsletter_mailout
{
if (count($this->targets) == 0)
{ // Read in and process another newletter mailing list
if (!($row = $sql->db_Fetch(MYSQL_ASSOC)))
if (!($row = $sql->fetch()))
{
$this->selectorActive = FALSE;
return FALSE; // Run out of DB records
@ -146,9 +142,9 @@ class newsletter_mailout
{
if ($uid = intval(trim($v)))
{ // Got a user ID here - look them up and add their data
if ($this->ourDB->db_Select('user', 'user_name,user_email,user_lastvisit', '`user_id`='.$uid))
if ($this->ourDB->select('user', 'user_name,user_email,user_lastvisit', '`user_id`='.$uid))
{
$row = $this->ourDB->db_Fetch();
$row = $this->ourDB->fetch();
$ret = array('mail_recipient_id' => $uid,
'mail_recipient_name' => $row['user_name'], // Should this use realname?
'mail_recipient_email' => $row['user_email'],
@ -200,7 +196,7 @@ class newsletter_mailout
if ($sql->select('newsletter', 'newsletter_id, newsletter_title', '`newsletter_parent`=0'))
{
$c=0;
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
while ($row = $sql->fetch())
{
$checked = (isset($selects[$row['newsletter_id']])) ? " checked='checked'" : '';
@ -231,9 +227,17 @@ class newsletter_mailout
{
return false; // Return Nothing to avoid confusion.
}
}
/**
* Manage Bounces.
*/
public function bounce($data)
{
e107::getLog()->add('Newsletter Bounce', $data, E_LOG_INFORMATIVE, 'BOUNCE');
}
}