本文整理汇总了PHP中CRM_Core_BAO_MailSettings::defaultReturnPath方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_MailSettings::defaultReturnPath方法的具体用法?PHP CRM_Core_BAO_MailSettings::defaultReturnPath怎么用?PHP CRM_Core_BAO_MailSettings::defaultReturnPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_MailSettings
的用法示例。
在下文中一共展示了CRM_Core_BAO_MailSettings::defaultReturnPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
static function send($from, $toDisplayName, $toEmail, $subject, $text_message = null, $cc = null, $bcc = null, $replyTo = null, $html_message = null, $attachments = null)
{
require_once 'CRM/Core/BAO/MailSettings.php';
$returnPath = CRM_Core_BAO_MailSettings::defaultReturnPath();
if (!$returnPath) {
$returnPath = self::pluckEmailFromHeader($from);
}
$headers = array();
$headers['From'] = $from;
$headers['To'] = "{$toDisplayName} <{$toEmail}>";
$headers['Cc'] = $cc;
$headers['Subject'] = $subject;
$headers['Content-Type'] = $html_message ? 'multipart/mixed; charset=utf-8' : 'text/plain; charset=utf-8';
$headers['Content-Disposition'] = 'inline';
$headers['Content-Transfer-Encoding'] = '8bit';
$headers['Return-Path'] = $returnPath;
$headers['Reply-To'] = isset($replyTo) ? $replyTo : $from;
$headers['Date'] = date('r');
$to = array($toEmail);
if ($cc) {
$to[] = $cc;
}
if ($bcc) {
$to[] = $bcc;
}
// we need to wrap Mail_mime because PEAR is apparently unable to fix
// a six-year-old bug (PEAR bug #30) in Mail_mime::_encodeHeaders()
// this fixes CRM-4631
require_once 'CRM/Utils/Mail/FixedMailMIME.php';
$msg = new CRM_Utils_Mail_FixedMailMIME("\n");
if ($text_message) {
$msg->setTxtBody($text_message);
}
if ($html_message) {
$msg->setHTMLBody($html_message);
}
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);
$result = null;
$mailer =& CRM_Core_Config::getMailer();
CRM_Core_Error::ignoreException();
if (is_object($mailer)) {
$result = $mailer->send($to, $headers, $message);
CRM_Core_Error::setCallback();
if (is_a($result, 'PEAR_Error')) {
$message = self::errorMessage($mailer, $result);
CRM_Core_Session::setStatus($message, false);
return false;
}
return true;
}
return false;
}
示例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']);
//.........这里部分代码省略.........
示例3: send
static function send(&$params)
{
require_once 'CRM/Core/BAO/MailSettings.php';
$returnPath = CRM_Core_BAO_MailSettings::defaultReturnPath();
$from = CRM_Utils_Array::value('from', $params);
if (!$returnPath) {
$returnPath = self::pluckEmailFromHeader($from);
}
$params['returnPath'] = $returnPath;
// first call the mail alter hook
require_once 'CRM/Utils/Hook.php';
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);
$headers = array();
$headers['From'] = $params['from'];
$headers['To'] = "{$params['toName']} <{$params['toEmail']}>";
$headers['Cc'] = CRM_Utils_Array::value('cc', $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);
$headers['Reply-To'] = CRM_Utils_Array::value('replyTo', $params, $from);
$headers['Date'] = date('r');
$to = array($params['toEmail']);
if (CRM_Utils_Array::value('cc', $params)) {
$to[] = CRM_Utils_Array::value('cc', $params);
}
if (CRM_Utils_Array::value('bcc', $params)) {
$to[] = CRM_Utils_Array::value('bcc', $params);
}
// we need to wrap Mail_mime because PEAR is apparently unable to fix
// a six-year-old bug (PEAR bug #30) in Mail_mime::_encodeHeaders()
// this fixes CRM-4631
require_once 'CRM/Utils/Mail/FixedMailMIME.php';
$msg = new CRM_Utils_Mail_FixedMailMIME("\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);
$result = null;
$mailer =& CRM_Core_Config::getMailer();
CRM_Core_Error::ignoreException();
if (is_object($mailer)) {
$result = $mailer->send($to, $headers, $message);
CRM_Core_Error::setCallback();
if (is_a($result, 'PEAR_Error')) {
$message = self::errorMessage($mailer, $result);
CRM_Core_Session::setStatus($message, false);
return false;
}
return true;
}
return false;
}
示例4: 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)
{
require_once 'CRM/Core/BAO/MailSettings.php';
$returnPath = CRM_Core_BAO_MailSettings::defaultReturnPath();
$from = CRM_Utils_Array::value('from', $params);
if (!$returnPath) {
$returnPath = self::pluckEmailFromHeader($from);
}
$params['returnPath'] = $returnPath;
// first call the mail alter hook
require_once 'CRM/Utils/Hook.php';
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();
$headers['From'] = $params['from'];
$headers['To'] = "{$params['toName']} <{$params['toEmail']}>";
$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);
$headers['Reply-To'] = CRM_Utils_Array::value('replyTo', $params, $from);
$headers['Date'] = date('r');
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) {
$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']);
if (substr($from[0], 0, 1) != '"' || substr($from[0], -1, 1) != '"') {
$from[0] = str_replace('"', '\\"', $from[0]);
$headers['From'] = "\"{$from[0]}\" <{$from[1]}";
}
}
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']);
//get emails from headers, since these are
//combination of name and email addresses.
if (CRM_Utils_Array::value('Cc', $headers)) {
$to[] = CRM_Utils_Array::value('Cc', $headers);
}
if (CRM_Utils_Array::value('Bcc', $headers)) {
$to[] = CRM_Utils_Array::value('Bcc', $headers);
unset($headers['Bcc']);
}
$result = null;
$mailer =& CRM_Core_Config::getMailer();
//.........这里部分代码省略.........