require_once "bin/cli.php"; $cli = new civicrm_cli(); //if it doesn't die, it's authenticated //log the execution of script CRM_Core_Error::debug_log_message('EmailProcessor.php from the cli'); $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor'); if (!$lock->isAcquired()) { throw new Exception('Could not acquire lock, another EmailProcessor process is running'); } require_once 'CRM/Utils/Mail/EmailProcessor.php'; // check if the script is being used for civimail processing or email to // activity processing. if (isset($cli->args[0]) && $cli->args[0] == "activities") { CRM_Utils_Mail_EmailProcessor::processActivities(); } else { CRM_Utils_Mail_EmailProcessor::processBounces(); } $lock->release(); } else { session_start(); require_once '../civicrm.config.php'; require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); CRM_Utils_System::authenticateScript(TRUE); require_once 'CRM/Utils/System.php'; CRM_Utils_System::loadBootStrap(); //log the execution of script CRM_Core_Error::debug_log_message('EmailProcessor.php'); $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor'); if (!$lock->isAcquired()) { throw new Exception('Could not acquire lock, another EmailProcessor process is running');
/** * Job to get mail responses from civimailing */ function civicrm_api3_job_fetch_bounces($params) { $lock = new CRM_Core_Lock('civimail.job.EmailProcessor'); if (!$lock->isAcquired()) { return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running'); } if (!CRM_Utils_Mail_EmailProcessor::processBounces()) { $lock->release(); return civicrm_api3_create_error('Process Bounces failed'); } $lock->release(); // FIXME: processBounces doesn't return true/false on success/failure $values = array(); return civicrm_api3_create_success($values, $params, 'mailing', 'bounces'); }
/** * Job to get mail responses from civiMailing. * * @param array $params * * @return array */ function civicrm_api3_job_fetch_bounces($params) { $lock = Civi::lockManager()->acquire('worker.mailing.EmailProcessor'); if (!$lock->isAcquired()) { return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running'); } if (!CRM_Utils_Mail_EmailProcessor::processBounces()) { $lock->release(); return civicrm_api3_create_error('Process Bounces failed'); } $lock->release(); // FIXME: processBounces doesn't return true/false on success/failure $values = array(); return civicrm_api3_create_success($values, $params, 'Job', 'fetch_bounces'); }
function civicrm_api3_job_fetch_bounces($params) { require_once 'CRM/Utils/Mail/EmailProcessor.php'; require_once 'CRM/Core/Lock.php'; $lock = new CRM_Core_Lock('EmailProcessor'); if (!$lock->isAcquired()) { return civicrm_api3_create_error("Could not acquire lock, another EmailProcessor process is running"); } if (!CRM_Utils_Mail_EmailProcessor::processBounces()) { return civicrm_api3_create_error("Process Bounces failed"); } // FIXME: processBounces doesn't return true/false on success/failure $values = array(); $lock->release(); return civicrm_api3_create_success($values, $params, 'mailing', 'bounces'); }