From d4d55ac05786f5a9d4e9d4c0f88d43198e6e059a Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 14 Nov 2014 18:15:03 -0800 Subject: [PATCH] New 'sent' method added to e_mailout. Triggered during email queue processing. --- e107_handlers/mail_manager_class.php | 23 +++++++++++++++++++++++ e107_plugins/newsletter/e_mailout.php | 17 +++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index bb6c9b309..2f9c675c6 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -712,6 +712,29 @@ class e107MailManager // return; // ************************************************** Temporarily stop DB being updated when line active ***************************** + $addons = array_keys($email['mail_selectors']); // trigger e_mailout.php addons. 'sent' method. + + foreach($addons as $plug) + { + if($plug === 'core') + { + continue; + } + + if($cls = e107::getAddon($plug,'e_mailout')) + { + $email['status'] = $result; + + if(e107::callMethod($cls, 'sent', $email) === false) + { + e107::getAdminLog()->add($plug.' sent process failed', $email, E_LOG_FATAL, 'SENT'); + } + } + } + // -------------------------- + + + $this->checkDB(2); // Make sure DB object created // Now update email status in DB. We just create new arrays of changed data diff --git a/e107_plugins/newsletter/e_mailout.php b/e107_plugins/newsletter/e_mailout.php index db779828d..879500006 100644 --- a/e107_plugins/newsletter/e_mailout.php +++ b/e107_plugins/newsletter/e_mailout.php @@ -237,6 +237,23 @@ class newsletter_mailout { e107::getLog()->add('Newsletter Bounce', $data, E_LOG_INFORMATIVE, 'BOUNCE'); } + + + + /** + * Manage Sent. + */ + public function sent($data) // trigerred when email sent from queue. + { + if($data['status'] == 1) // Successfully sent + { + // e107::getLog()->add('Newsletter Sent', $data, E_LOG_INFORMATIVE, 'SENT'); + } + else // Failed + { + // e107::getLog()->add('Newsletter Sent', $data, E_LOG_FATAL, 'SENT'); + } + } }