// you can run this program either from an apache command, or from the cli if (php_sapi_name() == "cli") { 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'); require_once 'CRM/Core/Lock.php'; $lock = new CRM_Core_Lock('EmailProcessor'); if (!$lock->isAcquired()) { throw new Exception('Could not acquire lock, another EmailProcessor process is running'); } // check if the script is being used for civimail processing or email to // activity processing. if (isset($cli->args[0]) && $cli->args[0] == "activities") { EmailProcessor::processActivities(); } else { EmailProcessor::processBounces(); } $lock->release(); exit; } else { session_start(); require_once '../civicrm.config.php'; require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(); CRM_Utils_System::authenticateScript(true); } //log the execution of script CRM_Core_Error::debug_log_message('EmailProcessor.php'); // load bootstrap to call hooks