[英]Adding subject line for sending an email in codeigniter php
申請工作需要發送一封電子郵件,其中包含一些詳細信息,例如姓名,電話號碼,電子郵件,當前ctc等。電子郵件已正確發送,但問題是在主題行中發送電子郵件時,我需要包含名稱電子郵件ctc。 。為此,我已經這樣做了,但是它不接受這種格式。
$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 = 'yyyy@gmail.com';
$config=Array(
'protocol'=> 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com', //smtp host name
'smtp_port' => '465', //smtp port number
'smtp_user' => 'xxxxxx@gmail.com',
'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');
}
}
通過添加此代碼即可解決。
$subject = $name .' | '.$currentemploymentstatus .' | '.$expectedctc .' | '.$primaryskills;
$this->email->subject($subject);
對於您的問題,請嘗試更改“ |” 到。'|'
要清理代碼並使生活更輕松:
如果您使用的是CI,請查看我的存儲庫中有關設置email_model的信息,以簡化您使用的代碼。 您無需加載庫的配置內容,只需擊中模型以發送到電子郵件隊列,然后再次擊中模型以處理隊列即可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.