CodeIgniter Forums
Send HTML email but showing souce code ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1)
+--- Forum: Lounge (https://forum.codeigniter.com/forumdisplay.php?fid=3)
+--- Thread: Send HTML email but showing souce code ? (/showthread.php?tid=61454)



Send HTML email but showing souce code ? - mylastof - 04-16-2015

:huh:
I dont know my wrong, but when send email HTML using showing as source code.

Please help me

my code :


Code:
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => $sender_email,
'smtp_pass' => $user_password,
'mailtype' => 'html',
'wordwrap' => TRUE,
'charset' => 'iso-8859-1',
'newline' => '\r\n'
);

$this->load->library('email', $config);

$this->email->from($sender_email, $sender_name);
$this->email->to($to_email);
$this->email->subject($subject_mail);
$body = $this->load->view('email',null,TRUE);

$this->email->message($body);
if (!$this->email->send()){
echo 'fail to load email';
}
else {
echo 'success to send email';
}



RE: Send HTML email but showing souce code ? - webnaz - 04-16-2015

Try this, change
PHP Code:
$this->load->library('email'$config); 
with
PHP Code:
$this->load->library('email');
$this->email->initialize($config);