示例#1
0
/**
 * Job to get mail and create activities.
 *
 * @param array $params
 *
 * @return array
 */
function civicrm_api3_job_fetch_activities($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');
    }
    try {
        CRM_Utils_Mail_EmailProcessor::processActivities();
        $values = array();
        $lock->release();
        return civicrm_api3_create_success($values, $params, 'Job', 'fetch_activities');
    } catch (Exception $e) {
        $lock->release();
        return civicrm_api3_create_error('Process Activities failed');
    }
}
示例#2
0
        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');
    }
    // try to unset any time limits
    if (!ini_get('safe_mode')) {
        set_time_limit(0);
    }
    require_once 'CRM/Utils/Mail/EmailProcessor.php';
    // cleanup directories with old mail files (if they exist): CRM-4452
    CRM_Utils_Mail_EmailProcessor::cleanupDir($config->customFileUploadDir . DIRECTORY_SEPARATOR . 'CiviMail.ignored');
    CRM_Utils_Mail_EmailProcessor::cleanupDir($config->customFileUploadDir . DIRECTORY_SEPARATOR . 'CiviMail.processed');
    // check if the script is being used for civimail processing or email to
    // activity processing.
    $isCiviMail = !empty($_REQUEST['emailtoactivity']) ? FALSE : TRUE;
    CRM_Utils_Mail_EmailProcessor::process($isCiviMail);
    $lock->release();
}
示例#3
0
/**
 * Job to get mail and create activities
 */
function civicrm_api3_job_fetch_activities($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');
    }
    try {
        CRM_Utils_Mail_EmailProcessor::processActivities();
        $values = array();
        $lock->release();
        return civicrm_api3_create_success($values, $params, 'mailing', 'activities');
    } catch (Exception $e) {
        $lock->release();
        return civicrm_api3_create_error('Process Activities failed');
    }
}