From a3bb28403118beeaf834038a8e7cd1b1430aeec9 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 22 Oct 2014 17:58:20 -0700 Subject: [PATCH] Mailout bounce handling fixes. --- e107_admin/mailout.php | 42 ++-- e107_handlers/bounce_handler.php | 34 +++- e107_handlers/e_parse_class.php | 2 +- e107_handlers/mail.php | 38 ++-- e107_handlers/mail_manager_class.php | 179 +++++++++++++----- e107_handlers/mailout_admin_class.php | 25 ++- .../English/admin/lan_log_messages.php | 8 +- e107_languages/English/admin/lan_mailout.php | 2 +- e107_plugins/newsletter/e_mailout.php | 26 +-- 9 files changed, 243 insertions(+), 113 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index eba6dc706..97ef3cfee 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -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 ".LAN_MAILOUT_115."
- \n"; $mailers = array('php','smtp','sendmail'); foreach($mailers as $opt) { @@ -886,17 +891,15 @@ class mailout_main_ui extends e_admin_ui ".LAN_MAILOUT_25." - ".LAN_MAILOUT_26." - ".LAN_MAILOUT_27. - " ".LAN_MAILOUT_29.".
+ ".LAN_MAILOUT_26." ".$frm->number('mail_pause', $pref['mail_pause'])." ".LAN_MAILOUT_27." ". + $frm->number('mail_pausetime', $pref['mail_pausetime'])." ".LAN_MAILOUT_29.".
".LAN_MAILOUT_30." \n ".LAN_MAILOUT_156." - - ".LAN_MAILOUT_157." + ".$frm->number('mail_workpertick',varset($pref['mail_workpertick'],5))."".LAN_MAILOUT_157." \n"; @@ -981,7 +984,10 @@ class mailout_main_ui extends e_admin_ui - ".LAN_MAILOUT_32." + + ".LAN_MAILOUT_32." + ".$frm->text('mail_bounce_email2', $pref['mail_bounce_email'], 40, 'size=xxlarge')." + ".LAN_MAILOUT_233."".(e_DOCROOT).e107::getFolder('handlers')."bounce_handler.php"; @@ -1006,11 +1012,25 @@ class mailout_main_ui extends e_admin_ui - + "; + + $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 .= "".$label."".$frm->text($key,$pref[$key],40,'size=xlarge').""; + } + + /* + $text .= " ".LAN_MAILOUT_32." ".LAN_MAILOUT_33." ".LAN_MAILOUT_34." ".LAN_MAILOUT_35." + "; + */ + + $text .= " ".LAN_MAILOUT_120."\n"; - - foreach($emFormat as $key => $val) - { - $selected = ($key == $curval)? " selected='selected'": ''; - $text .= "\n"; - } if($incTemplates) { $tList = self::getEmailTemplateNames('user'); foreach($tList as $key => $val) { - $selected = ($key == $curval)? " selected='selected'": ''; - $text .= "\n"; - } + $emFormat[$key] = LAN_MAILOUT_258 . $val; + } } - $text .= "\n"; - return $text; + + if(empty($curval)) + { + $curval = e107::getConfig()->get('mail_sendstyle'); + + } + + + return e107::getForm()->select($name,$emFormat, $curval, 'required=1&size=xxlarge'); + } /** diff --git a/e107_languages/English/admin/lan_log_messages.php b/e107_languages/English/admin/lan_log_messages.php index 809303928..404591a03 100644 --- a/e107_languages/English/admin/lan_log_messages.php +++ b/e107_languages/English/admin/lan_log_messages.php @@ -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]"); ?> diff --git a/e107_languages/English/admin/lan_mailout.php b/e107_languages/English/admin/lan_mailout.php index b681d1495..7cf1706f4 100644 --- a/e107_languages/English/admin/lan_mailout.php +++ b/e107_languages/English/admin/lan_mailout.php @@ -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"); diff --git a/e107_plugins/newsletter/e_mailout.php b/e107_plugins/newsletter/e_mailout.php index fd7e398dd..db779828d 100644 --- a/e107_plugins/newsletter/e_mailout.php +++ b/e107_plugins/newsletter/e_mailout.php @@ -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.'
'; - 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'); + } + }