本文整理汇总了PHP中CRM_Core_BAO_MailSettings::includeMessageId方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_MailSettings::includeMessageId方法的具体用法?PHP CRM_Core_BAO_MailSettings::includeMessageId怎么用?PHP CRM_Core_BAO_MailSettings::includeMessageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_MailSettings
的用法示例。
在下文中一共展示了CRM_Core_BAO_MailSettings::includeMessageId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addMessageIdHeader
/**
* Given and array of headers and a prefix, job ID, event queue ID, and hash,
* add a Message-ID header if needed.
*
* i.e. if the global includeMessageId is set and there isn't already a
* Message-ID in the array.
* The message ID is structured the same way as a verp. However no interpretation
* is placed on the values received, so they do not need to follow the verp
* convention.
*
* @param array $headers
* Array of message headers to update, in-out.
* @param string $prefix
* Prefix for the message ID, use same prefixes as verp.
* wherever possible
* @param string $job_id
* Job ID component of the generated message ID.
* @param string $event_queue_id
* Event Queue ID component of the generated message ID.
* @param string $hash
* Hash component of the generated message ID.
*
* @return void
*/
public static function addMessageIdHeader(&$headers, $prefix, $job_id, $event_queue_id, $hash)
{
$config = CRM_Core_Config::singleton();
$localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$includeMessageId = CRM_Core_BAO_MailSettings::includeMessageId();
if ($includeMessageId && !array_key_exists('Message-ID', $headers)) {
$headers['Message-ID'] = '<' . implode($config->verpSeparator, array($localpart . $prefix, $job_id, $event_queue_id, $hash)) . "@{$emailDomain}>";
}
}
示例2: send
/**
* Wrapper function to send mail in CiviCRM. Hooks are called from this function. The input parameter
* is an associateive array which holds the values of field needed to send an email. These are:
*
* from : complete from envelope
* toName : name of person to send email
* toEmail : email address to send to
* cc : email addresses to cc
* bcc : email addresses to bcc
* subject : subject of the email
* text : text of the message
* html : html version of the message
* replyTo : reply-to header in the email
* attachments: an associative array of
* fullPath : complete pathname to the file
* mime_type: mime type of the attachment
* cleanName: the user friendly name of the attachmment
*
* @param array $params (by reference)
*
* @access public
*
* @return boolean true if a mail was sent, else false
*/
static function send(&$params)
{
$returnPath = CRM_Core_BAO_MailSettings::defaultReturnPath();
$includeMessageId = CRM_Core_BAO_MailSettings::includeMessageId();
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$from = CRM_Utils_Array::value('from', $params);
if (!$returnPath) {
$returnPath = self::pluckEmailFromHeader($from);
}
$params['returnPath'] = $returnPath;
// first call the mail alter hook
CRM_Utils_Hook::alterMailParams($params);
// check if any module has aborted mail sending
if (CRM_Utils_Array::value('abortMailSend', $params) || !CRM_Utils_Array::value('toEmail', $params)) {
return FALSE;
}
$textMessage = CRM_Utils_Array::value('text', $params);
$htmlMessage = CRM_Utils_Array::value('html', $params);
$attachments = CRM_Utils_Array::value('attachments', $params);
// CRM-6224
if (trim(CRM_Utils_String::htmlToText($htmlMessage)) == '') {
$htmlMessage = FALSE;
}
$headers = array();
// CRM-10699 support custom email headers
if (CRM_Utils_Array::value('headers', $params)) {
$headers = array_merge($headers, $params['headers']);
}
$headers['From'] = $params['from'];
$headers['To'] = self::formatRFC822Email(CRM_Utils_Array::value('toName', $params), CRM_Utils_Array::value('toEmail', $params), FALSE);
$headers['Cc'] = CRM_Utils_Array::value('cc', $params);
$headers['Bcc'] = CRM_Utils_Array::value('bcc', $params);
$headers['Subject'] = CRM_Utils_Array::value('subject', $params);
$headers['Content-Type'] = $htmlMessage ? 'multipart/mixed; charset=utf-8' : 'text/plain; charset=utf-8';
$headers['Content-Disposition'] = 'inline';
$headers['Content-Transfer-Encoding'] = '8bit';
$headers['Return-Path'] = CRM_Utils_Array::value('returnPath', $params);
// CRM-11295: Omit reply-to headers if empty; this avoids issues with overzealous mailservers
$replyTo = CRM_Utils_Array::value('replyTo', $params, $from);
if (!empty($replyTo)) {
$headers['Reply-To'] = $replyTo;
}
$headers['Date'] = date('r');
if ($includeMessageId) {
$headers['Message-ID'] = '<' . uniqid('civicrm_', TRUE) . "@{$emailDomain}>";
}
if (CRM_Utils_Array::value('autoSubmitted', $params)) {
$headers['Auto-Submitted'] = "Auto-Generated";
}
//make sure we has to have space, CRM-6977
foreach (array('From', 'To', 'Cc', 'Bcc', 'Reply-To', 'Return-Path') as $fld) {
if (isset($headers[$fld])) {
$headers[$fld] = str_replace('"<', '" <', $headers[$fld]);
}
}
// quote FROM, if comma is detected AND is not already quoted. CRM-7053
if (strpos($headers['From'], ',') !== FALSE) {
$from = explode(' <', $headers['From']);
$headers['From'] = self::formatRFC822Email($from[0], substr(trim($from[1]), 0, -1), TRUE);
}
require_once 'Mail/mime.php';
$msg = new Mail_mime("\n");
if ($textMessage) {
$msg->setTxtBody($textMessage);
}
if ($htmlMessage) {
$msg->setHTMLBody($htmlMessage);
}
if (!empty($attachments)) {
foreach ($attachments as $fileID => $attach) {
$msg->addAttachment($attach['fullPath'], $attach['mime_type'], $attach['cleanName']);
}
}
$message = self::setMimeParams($msg);
$headers =& $msg->headers($headers);
$to = array($params['toEmail']);
//.........这里部分代码省略.........