I am trying to send the mail by sending html
contents in message everything the working fine but the in the mail I am getting whole html
tags in the message.
below is my code:
controller
$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());
您需要设置charset = utf-8
;
'charset' => 'utf-8', // you need to replace this line in your code
add these two in your $config array
'mailtype' => 'html',
'charset' => 'utf-8',
Replace this line
$body = $this->load->view('mailbody.php',$data,TRUE);
with
$body = $this->load->view('mailbody',$data,TRUE);
Change the line
$body = $this->load->view('mailbody.php',$data,TRUE);
TO
$body = $this->load->view('mailbody',$data,TRUE);
Change the charset to utf8
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.