Skip to content Skip to sidebar Skip to footer

Html Formatted Emailing In Codeigniter

how to send html formatted email in codeigniter i have this code which is sending email fine but it is not formatting it as it should look! you can see the picture which displays e

Solution 1:

Try this

// load email library$this->load->library('email');

// prepare email

$this->email
    ->from('ex@example.com', 'Example Test.')
    ->to('toex@example.com')
    ->subject('Hello Sample Test.')
    ->message('Hello, We are <strong>Htl content</strong>')
    ->set_mailtype('html');

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

You can also use a view file

$this->email
    ->from('ex@example.com', 'Example Test.')
    ->to('toex@example.com')
    ->subject('Hello Sample Test.')
    ->message($this->load->view('email_template-name', $dynamic-data, true))
    ->set_mailtype('html');

Solution 2:

You can try this line of code, which will set mail type to HTML:

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

Solution 3:

$config = Array(
    'mailtype' => 'html'
);

Add this to your mail config and recheck.

Solution 4:

In CodeIgniter 4.1.1

This should work, but is completely ignored:

$email_config = [
  'mailType' => 'html'
];
$email->initialize($config);

So after you've loaded the Altmessage in you can use this completely undocumented function:

$email->setMailType("html");

and then load your html version message in as you normally would - which I'd not have been able to guess without the other answers provided on this page.

Post a Comment for "Html Formatted Emailing In Codeigniter"