diff --git a/e107_handlers/cron_class.php b/e107_handlers/cron_class.php index 035b417d0..8e13933ab 100644 --- a/e107_handlers/cron_class.php +++ b/e107_handlers/cron_class.php @@ -172,18 +172,23 @@ class _system_cron function procEmailQueue() { - //global $pref; + + $sendPerHit = e107::getConfig()->get('mail_workpertick',5); + $pauseCount = e107::getConfig()->get('mail_pause',5); + $pauseTime = e107::getConfig()->get('mail_pausetime',2); + if (CRON_MAIL_DEBUG) { - $e107 = e107::getInstance(); - $e107->admin_log->e_log_event(10,debug_backtrace(),'DEBUG','CRON Email','Email run started',FALSE,LOG_TO_ROLLING); + e107::getLog()->e_log_event(10,debug_backtrace(),'DEBUG','CRON Email','Email run started',FALSE,LOG_TO_ROLLING); } + require_once(e_HANDLER.'mail_manager_class.php'); $mailManager = new e107MailManager(); - $mailManager->doEmailTask(varset($pref['mail_workpertick'],5)); + $mailManager->doEmailTask($sendPerHit,$pauseCount,$pauseTime); + if (CRON_MAIL_DEBUG) { - $e107->admin_log->e_log_event(10,debug_backtrace(),'DEBUG','CRON Email','Email run completed',FALSE,LOG_TO_ROLLING); + e107::getLog()->e_log_event(10,debug_backtrace(),'DEBUG','CRON Email','Email run completed',FALSE,LOG_TO_ROLLING); } } diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index 58413588d..bb6c9b309 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -123,7 +123,7 @@ class e107MailManager const E107_EMAIL_MAX_TRIES = 3; // Maximum number of tries by us (mail server may do more) // - max allowable value is MAIL_STATUS_MAX_ACTIVE - MAIL_STATUS_PENDING - private $debugMode = 1; + private $debugMode = false; protected $e107; protected $db = NULL; // Use our own database object - this one for reading data protected $db2 = NULL; // Use our own database object - this one for updates @@ -902,16 +902,26 @@ class e107MailManager * Call to do a number of 'units' of email processing - from a cron job, for example * Each 'unit' sends one email from the queue - potentially it could do some other task. * @param $limit - number of units of work to do - zero to clear the queue (or do maximum allowed by a hard-coded limit) + * @param $pauseCount - pause after so many emails + * @param $pauseTime - time in seconds to pause after 'pauseCount' number of emails. * @return None */ - public function doEmailTask($limit = 0) + public function doEmailTask($limit = 0, $pauseCount=null, $pauseTime=1) { if ($count = $this->selectEmails($limit)) { + $c=1; while ($count > 0) { $this->sendNextEmail(); $count--; + + if(!empty($pauseCount) && ($c === $pauseCount)) + { + sleep($pauseTime); + $c=1; + } + } if ($this->mailer) {