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


PHP CRM_Utils_Mail::formatRFC2822Name方法代码示例

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


在下文中一共展示了CRM_Utils_Mail::formatRFC2822Name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compose


//.........这里部分代码省略.........
         $html =& $pEmails['html'];
     }
     $text = NULL;
     if (isset($pEmails['text']) && is_array($pEmails['text']) && count($pEmails['text'])) {
         $text =& $pEmails['text'];
     }
     // push the tracking url on to the html email if necessary
     if ($this->open_tracking && $html) {
         array_push($html, "\n" . '<img src="' . $config->userFrameworkResourceURL . "extern/open.php?q={$event_queue_id}\" width='1' height='1' alt='' border='0'>");
     }
     $message = new Mail_mime("\n");
     $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY ? TRUE : FALSE;
     if ($useSmarty) {
         $smarty = CRM_Core_Smarty::singleton();
         // also add the contact tokens to the template
         $smarty->assign_by_ref('contact', $contact);
     }
     $mailParams = $headers;
     if ($text && ($test || $contact['preferred_mail_format'] == 'Text' || $contact['preferred_mail_format'] == 'Both' || $contact['preferred_mail_format'] == 'HTML' && !array_key_exists('html', $pEmails))) {
         $textBody = implode('', $text);
         if ($useSmarty) {
             $textBody = $smarty->fetch("string:{$textBody}");
         }
         $mailParams['text'] = $textBody;
     }
     if ($html && ($test || ($contact['preferred_mail_format'] == 'HTML' || $contact['preferred_mail_format'] == 'Both'))) {
         $htmlBody = implode('', $html);
         if ($useSmarty) {
             $htmlBody = $smarty->fetch("string:{$htmlBody}");
         }
         $mailParams['html'] = $htmlBody;
     }
     if (empty($mailParams['text']) && empty($mailParams['html'])) {
         // CRM-9833
         // something went wrong, lets log it and return null (by reference)
         CRM_Core_Error::debug_log_message(ts('CiviMail will not send an empty mail body, Skipping: %1', array(1 => $email)));
         $res = NULL;
         return $res;
     }
     $mailParams['attachments'] = $attachments;
     $mailingSubject = CRM_Utils_Array::value('subject', $pEmails);
     if (is_array($mailingSubject)) {
         $mailingSubject = implode('', $mailingSubject);
     }
     $mailParams['Subject'] = $mailingSubject;
     $mailParams['toName'] = CRM_Utils_Array::value('display_name', $contact);
     $mailParams['toEmail'] = $email;
     // Add job ID to mailParams for external email delivery service to utilise
     $mailParams['job_id'] = $job_id;
     CRM_Utils_Hook::alterMailParams($mailParams, 'civimail');
     // CRM-10699 support custom email headers
     if (!empty($mailParams['headers'])) {
         $headers = array_merge($headers, $mailParams['headers']);
     }
     //cycle through mailParams and set headers array
     foreach ($mailParams as $paramKey => $paramValue) {
         //exclude values not intended for the header
         if (!in_array($paramKey, array('text', 'html', 'attachments', 'toName', 'toEmail'))) {
             $headers[$paramKey] = $paramValue;
         }
     }
     if (!empty($mailParams['text'])) {
         $message->setTxtBody($mailParams['text']);
     }
     if (!empty($mailParams['html'])) {
         $message->setHTMLBody($mailParams['html']);
     }
     if (!empty($mailParams['attachments'])) {
         foreach ($mailParams['attachments'] as $fileID => $attach) {
             $message->addAttachment($attach['fullPath'], $attach['mime_type'], $attach['cleanName']);
         }
     }
     //pickup both params from mail params.
     $toName = trim($mailParams['toName']);
     $toEmail = trim($mailParams['toEmail']);
     if ($toName == $toEmail || strpos($toName, '@') !== FALSE) {
         $toName = NULL;
     } else {
         $toName = CRM_Utils_Mail::formatRFC2822Name($toName);
     }
     $headers['To'] = "{$toName} <{$toEmail}>";
     $headers['Precedence'] = 'bulk';
     // Will test in the mail processor if the X-VERP is set in the bounced email.
     // (As an option to replace real VERP for those that can't set it up)
     $headers['X-CiviMail-Bounce'] = $verp['bounce'];
     //CRM-5058
     //token replacement of subject
     $headers['Subject'] = $mailingSubject;
     CRM_Utils_Mail::setMimeParams($message);
     $headers = $message->headers($headers);
     //get formatted recipient
     $recipient = $headers['To'];
     // make sure we unset a lot of stuff
     unset($verp);
     unset($urls);
     unset($params);
     unset($contact);
     unset($ids);
     return $message;
 }
开发者ID:scardinius,项目名称:civicrm-core-api-mailing,代码行数:101,代码来源:Mailing.php


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