Home > Enterprise >  Codeigniter4 Email showing Html Source
Codeigniter4 Email showing Html Source

Time:07-24

I am having trouble with displaying email in codeigniter4

I have just deployed the application to shared hosting

However emails are not displayed correctly, it just showing html source instead.

See below

<p>to reset your password.<br/>
<br />
If you did not request a password reset, you can safely ignore this
email.<br />
<br />
Yours,<br />
</p>

    $email = \Config\Services::email();

    $email->setFrom($settings->info->site_noreply_email, $settings->info->site_title);
    $email->setTo($emailTo);
    $email->setSubject($subject, $settings->info->site_title);
    $email->setMessage($body);
    $email->send();

If anyone ever came across this please help

CodePudding user response:

Check your mail Type in config.

In app/config/Email.php

public $mailType = 'html';

or before send initialize it

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

CodePudding user response:

Before $email->send();, call:

    $email->setMailType("html");

Reference: \CodeIgniter\Email\Email::setMailType($type = 'text')

  • Related