我使用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
> }
> }
答案 0 :(得分:0)
请尝试使用以下配置参数
$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
答案 1 :(得分:0)
设置
$config['mailtype'] ='html';
然后
$mailSubject = "Customer Query | ".$bookingID." | ".$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);
答案 2 :(得分:0)
我找到了问题的原因。它只发生在我的邮件服务器上。对于其他邮件服务器,它并没有发生。即使在展望中也很好。我很遗憾浪费你宝贵的时间。