当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_Config::getMailer方法代码示例

本文整理汇总了PHP中CRM_Core_Config::getMailer方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Config::getMailer方法的具体用法?PHP CRM_Core_Config::getMailer怎么用?PHP CRM_Core_Config::getMailer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_Config的用法示例。


在下文中一共展示了CRM_Core_Config::getMailer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:58,代码来源:Mail.php

示例2: send


//.........这里部分代码省略.........
     $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']);
     //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();
     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);
             // append error message in case multiple calls are being made to
             // this method in the course of sending a batch of messages.
             CRM_Core_Session::setStatus($message, TRUE);
             return FALSE;
         }
         // CRM-10699
         CRM_Utils_Hook::postEmailSend($params);
         return TRUE;
     }
     return FALSE;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Mail.php

示例3: send

 function send($from, $toDisplayName, $toEmail, $subject, $message, $cc = null, $bcc = null)
 {
     require_once 'CRM/Core/DAO/Domain.php';
     $dao = new CRM_Core_DAO_Domain();
     $dao->id = 1;
     $dao->find(true);
     $returnPath = $dao->email_return_path;
     if (!$returnPath) {
         $returnPath = CRM_Utils_Mail::_pluckEmailFromHeader($from);
     }
     $headers = array();
     $headers['From'] = $from;
     $headers['To'] = CRM_Utils_Mail::encodeAddressHeader($toDisplayName, $toEmail);
     $headers['Cc'] = $cc;
     $headers['Bcc'] = $bcc;
     $headers['Subject'] = CRM_Utils_Mail::encodeSubjectHeader($subject);
     $headers['Content-Type'] = 'text/plain; charset=utf-8';
     $headers['Content-Disposition'] = 'inline';
     $headers['Content-Transfer-Encoding'] = '8bit';
     $headers['Return-Path'] = $returnPath;
     $headers['Reply-To'] = $from;
     $to = array($toEmail);
     if ($cc) {
         $to[] = $cc;
     }
     if ($bcc) {
         $to[] = $bcc;
     }
     $mailer =& CRM_Core_Config::getMailer();
     if ($mailer->send($to, $headers, $message) !== true) {
         return false;
     }
     return true;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:34,代码来源:Mail.php

示例4: 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;
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:70,代码来源:Mail.php

示例5: mte_civicrm_alterMailParams

/**
 * Implementation of hook_civicrm_alterMailParams( )
 * To send headers in mail and also create activity
 */
function mte_civicrm_alterMailParams(&$params, $context = NULL)
{
    if ($context != 'civimail') {
        CRM_Core_Smarty::singleton()->assign('alterMailer', 'ignore');
    }
    if (!mte_checkSettings($context)) {
        return FALSE;
    }
    $session = CRM_Core_Session::singleton();
    $userID = $session->get('userID');
    $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
    $params['toEmail'] = trim($params['toEmail']);
    // BRES-103 Prevent silent failure when emails with whitespaces are used.
    if (!$userID) {
        $config = CRM_Core_Config::singleton();
        if (version_compare($config->civiVersion, '4.3.alpha1') < 0) {
            //FIX: source id for version less that 4.3
            $matches = array();
            preg_match('/[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b/i', $params['from'], $matches);
            if (!empty($matches)) {
                $userID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $matches[0], 'contact_id', 'email');
                if (!$userID) {
                    $userID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $params['toEmail'], 'contact_id', 'email');
                }
            }
        } else {
            $userID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', CRM_Core_Config::domainID(), 'contact_id');
        }
    }
    if ($context == 'civimail' && CRM_Mte_BAO_Mandrill::$_mailingActivityId) {
        $activityParams = array('id' => CRM_Mte_BAO_Mandrill::$_mailingActivityId, 'target_contact_id' => mte_targetContactIds($params), 'deleteActivityTarget' => FALSE, 'version' => 3);
    } else {
        $activityParams = array('source_contact_id' => $userID, 'activity_type_id' => array_search('Mandrill Email Sent', $activityTypes), 'subject' => CRM_Utils_Array::value('subject', $params) ? $params['subject'] : CRM_Utils_Array::value('Subject', $params), 'activity_date_time' => date('YmdHis'), 'status_id' => 2, 'priority_id' => 1, 'version' => 3, 'details' => CRM_Utils_Array::value('html', $params, $params['text']), 'target_contact_id' => mte_targetContactIds($params));
        if (!empty($params['job_id'])) {
            $jobCLassName = 'CRM_Mailing_DAO_MailingJob';
            if (version_compare('4.4alpha1', CRM_Core_Config::singleton()->civiVersion) > 0) {
                $jobCLassName = 'CRM_Mailing_DAO_Job';
            }
            $activityParams['source_record_id'] = CRM_Core_DAO::getFieldValue($jobCLassName, $params['job_id'], 'mailing_id');
        }
    }
    $result = civicrm_api('activity', 'create', $activityParams);
    if (CRM_Utils_Array::value('id', $result)) {
        $params['activityId'] = $mandrillHeader = $result['id'];
        // include verp in header incase of bulk mailing
        if ($context == 'civimail') {
            $mandrillHeader .= CRM_Core_Config::singleton()->verpSeparator . CRM_Utils_Array::value('Return-Path', $params);
        } else {
            mte_createQueue($mandrillHeader, $params['toEmail']);
            $params['mandrillHeader'] = $mandrillHeader;
        }
        $params['headers']['X-MC-Metadata'] = '{"CiviCRM_Mandrill_id": "' . $mandrillHeader . '" }';
        CRM_Core_Smarty::singleton()->assign('alterMailer', 1);
        if ($context == 'civimail' && !CRM_Mte_BAO_Mandrill::$_mailingActivityId) {
            CRM_Mte_BAO_Mandrill::$_mailingActivityId = $result['id'];
        }
        if (!method_exists(CRM_Utils_Hook::singleton(), 'alterMail')) {
            $mailer =& CRM_Core_Config::getMailer();
            mte_getmailer($mailer);
        }
    }
}
开发者ID:vakeesan26,项目名称:biz.jmaconsulting.mte,代码行数:66,代码来源:mte.php

示例6: 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();
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Mail.php


注:本文中的CRM_Core_Config::getMailer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。