Sending html email displays as code in codeigniter

$config = Array(
‘protocol’ => ‘smtp’,
‘smtp_host’ => ‘xxxxxx’,
‘smtp_port’ => 25,
‘smtp_user’ => ‘xxx@xxx-xx.com’,
‘smtp_pass’ => ‘xxxxxx’,
‘mailtype’ => ‘html’
);

$this->load->library(’email’, $config);
$this->email->set_newline(“\r\n”);
$this->email->set_header(‘MIME-Version’, ‘1.0; charset=utf-8’); //must add this line
$this->email->set_header(‘Content-type’, ‘text/html’); //must add this line
$this->email->from(‘xxx@xxx.com’, $this->input->post(‘txtName’));
$this->email->to(‘xxx@xxx.com’);
$this->email->subject(‘Feeback from Website’.’ | ‘.$this->input->post(‘txtName’).’ | ‘.$this->input->post(‘txtEmail’));
$this->email->set_mailtype(“html”);

$msg = “<html><head>Hi</head><body>Dear Concern,”;
$msg = $msg.”<br><br>Feedback from “.$this->input->post(‘txtName’);
$msg = $msg.”<br>Email: “.$this->input->post(‘txtEmail’);
$msg = $msg.”<br>Feedback Type: “.$this->input->post(‘txtType’);
$msg = $msg.”<br>Feedback: “.$this->input->post(‘txtFeedback’);
$msg = $msg.”<br><br>Thank you.”;
$msg = $msg.”<br></body></html>”;

echo $msg;
$this->email->message($msg);

// echo $this->email->send();

if($this->email->send() == 1)
{
$this->load->view(‘contact/thankyou’, $data);
}

Leave a comment