HTML格式的电子邮件笨
我发送电子邮件给用户,但电子邮件必须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。除非你初始化它们
设置的配置选项不起作用。您$配置阵列后补充一点:
$this->email->initialize($config);
所以你没有intealize它,所以它并没有进一步增加工作
adding $this->email->set_mailtype("html");
可以解决你的问题。然后
加载库初始化
为什么它工作时,我当时是使用引导所见即所得的编辑器中的数据。但是这在夏季注释中没有用? – cyberrspiritt
并且config已经传递给库加载函数。它初始化了一切,除了邮件类型? – cyberrspiritt
@cyberrspiritt顺便说一句,我不知道引导所见即所得的和summernote – Linus
尝试加入'$这个 - >的电子邮件 - > set_mailtype( “HTML”);已经在配置阵列'mailtype => html' – Linus
心不是@AnmolRaghuvanshi。不介意,但你有这个解释吗?因为它已经存在于配置文件 – cyberrspiritt
它确实工作接着说: – cyberrspiritt