3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
37 * When running script from cli :
38 * 1. By default script is being used for civimail processing.
39 * eg : nice -19 php bin/EmailProcessor.php -u<login> -p<password> -s<sites(or default)>
41 * 2. Pass "activities" as argument to use script for 'Email To Activity Processing'.
42 * eg : nice -19 php bin/EmailProcessor.php -u<login> -p<password> -s<sites(or default)> activities
46 // bootstrap the environment and run the processor
47 // you can run this program either from an apache command, or from the cli
48 if (php_sapi_name() == "cli") {
49 require_once "bin/cli.php";
50 $cli = new civicrm_cli();
51 //if it doesn't die, it's authenticated
52 //log the execution of script
53 CRM_Core_Error
::debug_log_message('EmailProcessor.php from the cli');
54 $lock = Civi\Core\Container
::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
56 if (!$lock->isAcquired()) {
57 throw new Exception('Could not acquire lock, another EmailProcessor process is running');
60 require_once 'CRM/Utils/Mail/EmailProcessor.php';
62 // check if the script is being used for civimail processing or email to
63 // activity processing.
64 if (isset($cli->args
[0]) && $cli->args
[0] == "activities") {
65 CRM_Utils_Mail_EmailProcessor
::processActivities();
68 CRM_Utils_Mail_EmailProcessor
::processBounces();
74 require_once '../civicrm.config.php';
75 require_once 'CRM/Core/Config.php';
76 $config = CRM_Core_Config
::singleton();
77 CRM_Utils_System
::authenticateScript(TRUE);
79 require_once 'CRM/Utils/System.php';
80 CRM_Utils_System
::loadBootStrap();
82 //log the execution of script
83 CRM_Core_Error
::debug_log_message('EmailProcessor.php');
85 $lock = Civi\Core\Container
::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
87 if (!$lock->isAcquired()) {
88 throw new Exception('Could not acquire lock, another EmailProcessor process is running');
91 // try to unset any time limits
92 if (!ini_get('safe_mode')) {
96 require_once 'CRM/Utils/Mail/EmailProcessor.php';
98 // cleanup directories with old mail files (if they exist): CRM-4452
99 CRM_Utils_Mail_EmailProcessor
::cleanupDir($config->customFileUploadDir
. DIRECTORY_SEPARATOR
. 'CiviMail.ignored');
100 CRM_Utils_Mail_EmailProcessor
::cleanupDir($config->customFileUploadDir
. DIRECTORY_SEPARATOR
. 'CiviMail.processed');
102 // check if the script is being used for civimail processing or email to
103 // activity processing.
104 $isCiviMail = !empty($_REQUEST['emailtoactivity']) ?
FALSE : TRUE;
105 CRM_Utils_Mail_EmailProcessor
::process($isCiviMail);