1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Corrected email 'pause' timing on mailout cron job.

This commit is contained in:
Cameron
2014-10-27 20:33:35 -07:00
parent 41ee837c7e
commit 38ff75d27e
2 changed files with 22 additions and 7 deletions

View File

@@ -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);
}
}

View File

@@ -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)
{