send html mail using codeigniter send html mail using codeigniter codeigniter codeigniter

send html mail using codeigniter


You can try this line of code which will set the mail type to be for HTML:

 $this->email->set_mailtype("html");


As of CodeIgniter 3.x. There are many features added. This example is almost same with earlier versions, but you can do much more.

Follow the link for documentation.

// load email library$this->load->library('email');// prepare email$this->email    ->from('info@example.com', 'Example Inc.')    ->to('to@example.com')    ->subject('Hello from Example Inc.')    ->message('Hello, We are <strong>Example Inc.</strong>')    ->set_mailtype('html');// send email$this->email->send();

If you have template design. You can also include template in message method like this ...

->message($this->load->view('email_template', $data, true))

Here, the first parameter is email_template.php in your views directory, second parameter the data to be sent to email template, you can set it '' or array() or [] if not passing any dynamic data and last parameter true make sure, you grab the template data instead output.

Hope this is helpful.


Setting the mail type to HTML works for me:

$email_setting  = array('mailtype'=>'html');$this->email->initialize($email_setting);