2017-07-19 27 views
0

申請工作需要發送一些電子郵件,包括姓名,電話號碼,電子郵件,當前ctc etcc等詳細信息。電子郵件發送正確,但問題是發送在主題行中的電子郵件,我需要包括名稱電子郵件CTT ...爲此,我已經這樣做,但它不接受這種格式。在codeigniter中添加發送郵件的主題行php

 $name = $this->input->post('fullname'); 
     $email = $this->input->post('email'); 
     $phone = $this->input->post('mobilenumber'); 
     $currentemploymentstatus = $this->input->post('current_employment_status'); 

     //set to_email id to which you want to receive mails 
     $to_email = '[email protected]'; 

     $config=Array(
     'protocol'=> 'smtp', 
     'smtp_host' => 'ssl://smtp.gmail.com', //smtp host name 
     'smtp_port' => '465', //smtp port number 
     'smtp_user' => '[email protected]', 
     'smtp_pass' => 'PASSWORD123', //$from_email password 
     'mailtype' =>'html', 
     'newline' =>"\r\n", 
     'crlf' =>"\r\n", 
     'charset' => 'iso-8859-1', 
     'wordwrap' => TRUE 
     ); 

     $message   = array();  
     $message[] = 'Fullname : '.trim($name).' '; 
     $message[] = 'Email : '.trim($email).' '; 
     $message[] = 'Mobile : '.trim($phone).' '; 
     $message[] = 'Current Employment Status : '.trim($currentemploymentstatus).' ';   

     //$message = implode(PHP_EOL, $message); 
     $message = implode('<br>', $message); 
     //send mail 
     $this->load->library('email',$config); 
     $this->email->from($email); 
     $this->email->to($to_email); 
     //$list = array(); 
     $this->email->subject($name|$email); 
     $this->email->message($message); 
     $this->email->set_newline("\r\n"); 
     $this->email->set_mailtype("html"); 
      if ($this->email->send()) 
     { 
      $this->flash->success('Thank you for applying to this post we will get back to you soon!</div>'); 
      redirect('apply'); 
     } 
     else 
     { 
      $this->flash->success('There is error in sending mail! Please try again later'); 
      redirect('apply'); 
     } 
    } 
+0

主題應該是這樣的$名稱| $ email – user8001297

+0

試試這個.. $ this-> email-> subject($ name。「|」。$ email); –

回答

0

通過將此代碼只是解決了。

$subject = $name .' | '.$currentemploymentstatus .' | '.$expectedctc .' | '.$primaryskills; 
     $this->email->subject($subject); 
0

對於您的問題嘗試更改「|」 to。'|'

要清理您的代碼,使您的生活更輕鬆:

如果使用CI,看看我的上建立一個email_model簡化您正在使用的代碼庫。不必加載的配置工具和庫中的所有你需要做的是打模型發送給郵件隊列和命中模型中的第二次處理隊列

https://github.com/ddell003/Email_model