簡體   English   中英

codeigniter電子郵件主題行刪除帶有“ _”的空格

[英]codeigniter email subject line removes spaces with “_”

我使用codeigniter發送一些電子郵件。 除主題行外,一切正常。 我正在創建這樣的自定義主題行

$mailSubject = "Customer Query | " . $bookingID . " | " . $requestID;

像這樣使用

$this->email->subject($mailSubject);

但是當我收到電子郵件時,主題行看起來像

Customer_Query_|_6223871_|_92

相反,我需要像

Customer Query | 6223871 | 92

這是我的功能

> public function sendEmail($data) {
>         $config = Array(
>             'protocol' => 'smtp',
>             'smtp_host' => 'ssl://sub5.mail.xxxxx.com',
>             'smtp_port' => 465,
>             'smtp_user' => 'account@xxxxx.com',
>             'smtp_pass' => 'xxxxx',
>             'mailtype' => 'html',
>             'charset' => 'iso-8859-1',
>             'wordwrap' => TRUE
>         ); //set the basic configurations
> 
>         $bookingID = $data['booking_id'];
>         $requestID = $data['requestID'];
>         
>         $productCategory = "";
>         if($data['regarding'] == 1){
>             $productCategory = "Flights";
>         }else if($data['regarding'] == 2){
>             $productCategory = "Hotels";
>         }else if($data['regarding'] == 3){
>             $productCategory = "Visa Services";
>         }else if($data['regarding'] == 4){
>             $productCategory = "Travel Insurance";
>         }
>         
>         $queryType = "";
>         if($data['request_type'] == 1){
>             $queryType = "General";
>         }else if($data['request_type'] == 2){
>             $queryType = "Feedback";
>         }else if($data['request_type'] == 3){
>             $queryType = "Complain";
>         }else if($data['request_type'] == 4){
>             $queryType = "Flight Inquiry";
>         }else if($data['request_type'] == 5){
>             $queryType = "Hotel Inquiry";
>         }else if($data['request_type'] == 6){
>             $queryType = "Refund";
>         }else if($data['request_type'] == 7){
>             $queryType = "Cancellation";
>         }else if($data['request_type'] == 8){
>             $queryType = "Re-Scheduling";
>         }else if($data['request_type'] == 9){
>             $queryType = "E-ticket";
>         }else if($data['request_type'] == 10){
>             $queryType = "Invoice";
>         }else if($data['request_type'] == 11){
>             $queryType = "Visa Request";
>         }else if($data['request_type'] == 12){
>             $queryType = "Travel Insurance Request";
>         }else if($data['request_type'] == 13){
>             $queryType = "Date Change";
>         }
> 
>         $comments = $data['comments'];
>         $fname = $data['fname'];
>         $lname = $data['lname'];
>         $cusEmail = $data['email'];
>         $mobileNo = $data['contact_no'];
>         $subject = $data['subject'];
>         
>         $toEmail = "";
>         if($productCategory == 2){
>             $toEmail = "hotels@xxxxx.com";
>         }else{
>             $toEmail = "flights@xxxxx.com";
>         }
> 
>         $mailSubject = "Customer Query | " . $bookingID . " | " . $requestID;
> 
>         //prepare the message
>         $message = '<center><p><u>Customer Query</u></p></center>
>                     <p>Customer Query - '.$productCategory.' - '.$queryType.' </p>
>                     <br/>
>                     <p><b><u>Booking Details</u></b></p>
>                     <br/>
>                     <p>Product Category : '.$productCategory.'</p> 
>                     <p>Query Type : '.$queryType.' </p> 
>                     <p>Booking ID : '.$bookingID.'</p>
>                     <p>Subject : '.$subject.'</p> 
>                     <p>Comments : </p>
>                     <p><b>'.$comments.'</b></p>
>                     <br/>
>                     <p><b><u>Passenger Details</u></b></p>
>                     <br/>
>                     <p>First Name : '.$fname.'</p>
>                     <p>Last Name : '.$lname.'</p>
>                     <p>Email : '.$cusEmail.'</p>
>                     <p>Mobile No : '.$mobileNo.'</p>'; //end the message
>                         
>         //mail sending details
>         $this->load->library('email', $config);
>         $this->email->set_crlf("\r\n");
>         $this->email->from($cusEmail, $fname.' '.$lname);
>         $this->email->to('eranga.p@xxx.lk');
>         $this->email->subject($mailSubject);
>         $this->email->message($message);
> 
>         if ($this->email->send()) {//send mail and check weather it is sent successfully 
>             return TRUE;
>         } else {
>             return FALSE; //returns false if email not sent
>         }
>     }

請嘗試使用以下配置參數

         $config = Array(
         'protocol' => 'smtp',
         'smtp_host' => 'ssl://sub5.mail.xxxxx.com',
         'smtp_port' => 465,
         'smtp_user' => 'account@xxxxx.com',
         'smtp_pass' => 'xxxxx',
         'mailtype' => 'html',
         'charset' => 'iso-8859-1',
         'wordwrap' => TRUE,
         'remove_space' => FALSE
        ); //set the basic configurations

設置你的

$config['mailtype'] ='html';

然后

$mailSubject = "Customer&nbsp;Query&nbsp;|&nbsp;".$bookingID."&nbsp;|&nbsp;".$requestID;//$nbsp; is space it is replace because your mailtype is html

$this->email->subject($mailSubject);

替換$this->load->library('email', $config);

$this->load->library('email');
$this->email->initialize($config);

我找到了問題的原因。 這僅發生在我的郵件服務器中。 對於其他郵件服務器,則沒有發生。 即使在前景上也很好。 非常浪費您寶貴的時間,我真的很抱歉。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM