我發送電子郵件給用戶,但電子郵件必須HTML格式。我已閱讀其他帖子,但沒有幫助。HTML格式的電子郵件笨
下面是從控制器我的代碼:
public function reply_post(){
$to = $this->input->post('contact_email');
$subject = $this->input->post('contact_subject');
$header_message = "<html><head><title>".$subject."</title></head><body>";
$footer_message = "</body></html>";
$input_msg = $this->input->post('contact_reply');
$msg = $header_message.$input_msg.$footer_message;
$from = "[email protected]";
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'mail.XXXXXX.com',
'smtp_port' => XXX,
'smtp_user' => '[email protected]', // change it to yours
'smtp_pass' => 'XXXXX', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($from, "Admin"); // change it to yours
$this->email->to($to);// change it to yours
$this->email->subject($subject);
$this->email->message($msg);
if($this->email->send()){
$msg = 'Email sent.';
} else {
log_message('error','Email did not send');
$msg = "Email Did not send";
}
$this->finish($msg);
}
的消息,我從形式得到的是通過Summernote所見即所得的編輯器,以便它已經HTML格式。但是,當我收到電子郵件時,它不會將HTML標籤應用於它,並且所有標籤都可見。它就像某種方式將mailtype設置爲'text',即使在配置中將其設置爲HTML。除非你初始化它們
嘗試加入'$這個 - >的電子郵件 - > set_mailtype( 「HTML」);已經在配置陣列'mailtype => html' – Linus
心不是@AnmolRaghuvanshi。不介意,但你有這個解釋嗎?因爲它已經存在於配置文件 – cyberrspiritt
它確實工作接着說: – cyberrspiritt