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


PHP Message::addCustomeHeader方法代码示例

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


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

示例1: sendemail

 /**
  * send email
  *
  * @param        $fromemail
  * @param        $accessToken
  * @param        $email_type
  * @param        $imap_server
  * @param        $subject
  * @param        $body
  * @param        $toEmail
  * @param        $ccEmail
  * @param        $bccEmail
  * @param        $attachemnts
  * @param string $mailtype
  *
  * @return bool|void
  *
  * @since rt-Helpdesk 0.1
  */
 public function sendemail($fromname, $fromemail, $accessToken, $email_type, $imap_server, $subject, $body, $toEmail, $ccEmail, $bccEmail, $attachemnts, $email = null, $mailtype = 'notification')
 {
     set_time_limit(0);
     if (!$this->try_imap_login($fromemail, $accessToken, $email_type, $imap_server)) {
         return false;
     }
     $transport = new SmtpTransport();
     $smtp_args = array();
     switch ($email_type) {
         case 'goauth':
             $smtp_args['name'] = 'gmail-smtp';
             $smtp_args['host'] = 'smtp.gmail.com';
             $smtp_args['port'] = 465;
             $smtp_args['connection_class'] = 'oauth2';
             $smtp_args['connection_config'] = array('xoauth2_request' => $this->authString, 'ssl' => 'ssl');
             break;
         case 'imap':
             global $rt_imap_server_model;
             $server = $rt_imap_server_model->get_server_by_id($imap_server);
             if (empty($server)) {
                 echo 'Mail Server Not Found. Invalid Server id.';
                 return false;
             }
             $smtp_args['name'] = $server->outgoing_smtp_server;
             $smtp_args['host'] = $server->outgoing_smtp_server;
             $smtp_args['port'] = $server->outgoing_smtp_port;
             $smtp_args['connection_class'] = 'login';
             $smtp_args['connection_config'] = array('username' => $fromemail, 'password' => rtmb_encrypt_decrypt($accessToken), 'ssl' => $server->outgoing_smtp_enc);
             break;
         default:
             break;
     }
     $options = new SmtpOptions($smtp_args);
     $transport->setOptions($options);
     $message = new Message();
     $message->addFrom($fromemail, $fromname);
     if (!empty($email)) {
         $message_id = $reference_id = $in_reply_to = '';
         if ('comment' == $email->refrence_type) {
             $message_id = get_comment_meta($email->refrence_id, '_rtlib_messageid', true);
             $reference_id = get_comment_meta($email->refrence_id, '_rtlib_references', true);
             if (empty($message_id)) {
                 $comment = get_comment($email->refrence_id);
                 $post_id = $comment->comment_post_ID;
             }
         } else {
             if ('post' == $email->refrence_type) {
                 $post_id = $email->refrence_id;
             }
         }
         if (isset($post_id)) {
             $reference_id = get_post_meta($post_id, '_rtlib_references', true);
             $message_id = rtmb_get_reply_to_from_ref_id($reference_id);
             $reply_to = apply_filters('rtlib_reply_to_header', '', $fromemail, $post_id);
             if (!empty($reply_to)) {
                 $message->addCustomeHeader('Reply-To', trim($reply_to));
             }
         }
         //Get reply to header
         if (!empty($message_id)) {
             $message->addCustomeHeader('In-Reply-To', trim($message_id));
         }
         //Get References header
         if (!empty($message_id)) {
             $reference_id = rtmb_add_message_id_in_ref_id($message_id, $reference_id);
         }
         if (!empty($reference_id)) {
             $reference_ids = rtmb_get_reference_id_array($reference_id);
             $_reference_id = implode(' ', $reference_ids);
             $message->addCustomeHeader('References', $_reference_id);
         }
         // Add x-mailer
         if (!empty($email->refrence_id)) {
             $message->addCustomeHeader('X-Mailer', 'rtCamp-mail-lib');
             if ('comment' == $email->refrence_type) {
                 $comment = get_comment($email->refrence_id);
                 $post_id = $comment->comment_post_ID;
             } else {
                 $post_id = $email->refrence_id;
             }
             $new_message_id = rtmb_generate_message_id($post_id, $email->id);
//.........这里部分代码省略.........
开发者ID:neerukoul,项目名称:rtbiz,代码行数:101,代码来源:class-rt-zend-mail.php


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