本文整理汇总了PHP中CRM_Core_Config::_mail方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Config::_mail方法的具体用法?PHP CRM_Core_Config::_mail怎么用?PHP CRM_Core_Config::_mail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Config
的用法示例。
在下文中一共展示了CRM_Core_Config::_mail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
/**
* retrieve a mailer to send any mail from the applciation
*
* @param
* @access private
* @return object
*/
static function &getMailer()
{
if (!isset(self::$_mail)) {
require_once "CRM/Core/BAO/Preferences.php";
$mailingInfo =& CRM_Core_BAO_Preferences::mailingPreferences();
if (defined('CIVICRM_MAILER_SPOOL') && CIVICRM_MAILER_SPOOL) {
require_once 'CRM/Mailing/BAO/Spool.php';
self::$_mail = new CRM_Mailing_BAO_Spool();
} elseif ($mailingInfo['outBound_option'] == 0) {
if ($mailingInfo['smtpServer'] == '' || !$mailingInfo['smtpServer']) {
CRM_Core_Error::fatal(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
$params['host'] = $mailingInfo['smtpServer'] ? $mailingInfo['smtpServer'] : 'localhost';
$params['port'] = $mailingInfo['smtpPort'] ? $mailingInfo['smtpPort'] : 25;
if ($mailingInfo['smtpAuth']) {
require_once 'CRM/Utils/Crypt.php';
$params['username'] = $mailingInfo['smtpUsername'];
$params['password'] = CRM_Utils_Crypt::decrypt($mailingInfo['smtpPassword']);
$params['auth'] = true;
} else {
$params['auth'] = false;
}
// set the localhost value, CRM-3153
$params['localhost'] = $_SERVER['SERVER_NAME'];
self::$_mail =& Mail::factory('smtp', $params);
} elseif ($mailingInfo['outBound_option'] == 1) {
if ($mailingInfo['sendmail_path'] == '' || !$mailingInfo['sendmail_path']) {
CRM_Core_Error::fatal(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the Sendmail Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
$params['sendmail_path'] = $mailingInfo['sendmail_path'];
$params['sendmail_args'] = $mailingInfo['sendmail_args'];
self::$_mail =& Mail::factory('sendmail', $params);
} else {
CRM_Core_Session::setStatus(ts('There is no valid SMTP server Setting Or SendMail path setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
}
return self::$_mail;
}
示例2: setUp
/**
* Common setup functions for all unit tests.
*/
protected function setUp()
{
$session = CRM_Core_Session::singleton();
$session->set('userID', NULL);
$this->errorScope = CRM_Core_TemporaryErrorScope::useException();
// REVERT
// Use a temporary file for STDIN
$GLOBALS['stdin'] = tmpfile();
if ($GLOBALS['stdin'] === FALSE) {
echo "Couldn't open temporary file\n";
exit(1);
}
// Get and save a connection to the database
$this->_dbconn = $this->getConnection();
// reload database before each test
// $this->_populateDB();
// "initialize" CiviCRM to avoid problems when running single tests
// FIXME: look at it closer in second stage
// initialize the object once db is loaded
CRM_Core_Config::$_mail = NULL;
$config = CRM_Core_Config::singleton();
// when running unit tests, use mockup user framework
$config->setUserFramework('UnitTests');
$this->hookClass = CRM_Utils_Hook::singleton(TRUE);
// also fix the fatal error handler to throw exceptions,
// rather than exit
$config->fatalErrorHandler = 'CiviUnitTestCase_fatalErrorHandler';
// enable backtrace to get meaningful errors
$config->backtrace = 1;
// disable any left-over test extensions
CRM_Core_DAO::executeQuery('DELETE FROM civicrm_extension WHERE full_name LIKE "test.%"');
// reset all the caches
CRM_Utils_System::flushCache();
// Make sure the DB connection is setup properly
$config->userSystem->setMySQLTimeZone();
$env = new CRM_Utils_Check_Env();
CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime());
// clear permissions stub to not check permissions
$config = CRM_Core_Config::singleton();
$config->userPermissionClass->permissions = NULL;
//flush component settings
CRM_Core_Component::getEnabledComponents(TRUE);
error_reporting(E_ALL);
$this->_sethtmlGlobals();
}
示例3: array
/**
* Retrieve a mailer to send any mail from the application.
*
* @param bool $persist
* Open a persistent smtp connection, should speed up mailings.
* @return object
*/
public static function &getMailer($persist = FALSE)
{
if (!isset(self::$_mail)) {
$mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
if ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB || defined('CIVICRM_MAILER_SPOOL') && CIVICRM_MAILER_SPOOL) {
self::$_mail = self::_createMailer('CRM_Mailing_BAO_Spool', array());
} elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
if ($mailingInfo['smtpServer'] == '' || !$mailingInfo['smtpServer']) {
CRM_Core_Error::debug_log_message(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
CRM_Core_Error::fatal(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
}
$params['host'] = $mailingInfo['smtpServer'] ? $mailingInfo['smtpServer'] : 'localhost';
$params['port'] = $mailingInfo['smtpPort'] ? $mailingInfo['smtpPort'] : 25;
if ($mailingInfo['smtpAuth']) {
$params['username'] = $mailingInfo['smtpUsername'];
$params['password'] = CRM_Utils_Crypt::decrypt($mailingInfo['smtpPassword']);
$params['auth'] = TRUE;
} else {
$params['auth'] = FALSE;
}
// set the localhost value, CRM-3153
$params['localhost'] = CRM_Utils_Array::value('SERVER_NAME', $_SERVER, 'localhost');
// also set the timeout value, lets set it to 30 seconds
// CRM-7510
$params['timeout'] = 30;
// CRM-9349
$params['persist'] = $persist;
self::$_mail = self::_createMailer('smtp', $params);
} elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL) {
if ($mailingInfo['sendmail_path'] == '' || !$mailingInfo['sendmail_path']) {
CRM_Core_Error::debug_log_message(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the sendmail server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
CRM_Core_Error::fatal(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the sendmail server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
}
$params['sendmail_path'] = $mailingInfo['sendmail_path'];
$params['sendmail_args'] = $mailingInfo['sendmail_args'];
self::$_mail = self::_createMailer('sendmail', $params);
} elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MAIL) {
self::$_mail = self::_createMailer('mail', array());
} elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MOCK) {
self::$_mail = self::_createMailer('mock', array());
} elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED) {
CRM_Core_Error::debug_log_message(ts('Outbound mail has been disabled. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
CRM_Core_Session::setStatus(ts('Outbound mail has been disabled. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
} else {
CRM_Core_Error::debug_log_message(ts('There is no valid SMTP server Setting Or SendMail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
CRM_Core_Session::setStatus(ts('There is no valid SMTP server Setting Or sendMail path setting. Click <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
CRM_Core_Error::debug_var('mailing_info', $mailingInfo);
}
}
return self::$_mail;
}
示例4: elseif
/**
* retrieve a mailer to send any mail from the applciation
*
* @param boolean $persist open a persistent smtp connection, should speed up mailings
*
* @access private
*
* @return object
*/
static function &getMailer($persist = FALSE)
{
if (!isset(self::$_mail)) {
$mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
if (defined('CIVICRM_MAILER_SPOOL') && CIVICRM_MAILER_SPOOL) {
self::$_mail = new CRM_Mailing_BAO_Spool();
} elseif ($mailingInfo['outBound_option'] == 0) {
if ($mailingInfo['smtpServer'] == '' || !$mailingInfo['smtpServer']) {
CRM_Core_Error::fatal(ts('There is no valid smtp server setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
$params['host'] = $mailingInfo['smtpServer'] ? $mailingInfo['smtpServer'] : 'localhost';
$params['port'] = $mailingInfo['smtpPort'] ? $mailingInfo['smtpPort'] : 25;
if ($mailingInfo['smtpAuth']) {
$params['username'] = $mailingInfo['smtpUsername'];
$params['password'] = CRM_Utils_Crypt::decrypt($mailingInfo['smtpPassword']);
$params['auth'] = TRUE;
} else {
$params['auth'] = FALSE;
}
// set the localhost value, CRM-3153
$params['localhost'] = CRM_Utils_Array::value('SERVER_NAME', $_SERVER, 'localhost');
// also set the timeout value, lets set it to 30 seconds
// CRM-7510
$params['timeout'] = 30;
// CRM-9349
$params['persist'] = $persist;
self::$_mail = Mail::factory('smtp', $params);
} elseif ($mailingInfo['outBound_option'] == 1) {
if ($mailingInfo['sendmail_path'] == '' || !$mailingInfo['sendmail_path']) {
CRM_Core_Error::fatal(ts('There is no valid sendmail path setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the Sendmail Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
$params['sendmail_path'] = $mailingInfo['sendmail_path'];
$params['sendmail_args'] = $mailingInfo['sendmail_args'];
self::$_mail = Mail::factory('sendmail', $params);
} elseif ($mailingInfo['outBound_option'] == 3) {
$params = array();
self::$_mail = Mail::factory('mail', $params);
} elseif ($mailingInfo['outBound_option'] == 4) {
self::$_mail = Mail::factory('mock', $params);
} else {
CRM_Core_Session::setStatus(ts('There is no valid SMTP server Setting Or SendMail path setting. Click <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))));
}
}
return self::$_mail;
}