我正在尝试通过发送邮件中的html
内容来发送邮件,但邮件中的所有邮件都是html
。
下面是我的代码:
控制器
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'abc@gmail.com',
'smtp_pass' => 'passwrd',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'bcc_batch_mode' => 'true',
);
$this->load->library("email",$config);
$data = array(
'xyz' => $xyz,
'abc'=> $abc,
);
$this->email->set_newline("\r\n");
$this->email->from("abc@gmail.com","abc");
$this->email->to("xyz@gmail.com");
$this->email->subject("abc");
$body = $this->load->view('mailbody.php',$data,TRUE);
$this->email->message($body);
if($this->email->send())
echo "Mail send successfully!";
else
show_error($this->email->print_debugger());
答案 0 :(得分:0)
您需要设置charset = utf-8
;
'charset' => 'utf-8', // you need to replace this line in your code
答案 1 :(得分:0)
在$ config数组中添加这两个
'mailtype' => 'html',
'charset' => 'utf-8',
替换此行
$body = $this->load->view('mailbody.php',$data,TRUE);
与
$body = $this->load->view('mailbody',$data,TRUE);
答案 2 :(得分:0)
更改行
$body = $this->load->view('mailbody.php',$data,TRUE);
要
$body = $this->load->view('mailbody',$data,TRUE);
将charset更改为utf8