當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。