CodeIgniter Forums
sending mail in html - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: sending mail in html (/showthread.php?tid=76569)



sending mail in html - cb21 - 05-27-2020

I try different code but none works with me I am using CI4

PHP Code:
$email = \Config\Services::email();
$email->setFrom('[email protected]');
$email->setTo($sendto);
$email->setSubject($subject);
$email->setMessage($texte);
$email->mailType('html');

$email->send(); 

I got an error on $email->mailType('html');

I tried $email->set_mailtype("html"); same

I tried

PHP Code:
$config['mailtype'] = 'html'
$email = \Config\Services::email();
$email->initialize($config);

$email->setFrom('[email protected]');
$email->setTo($sendto);
$email->setSubject($subject);
$email->setMessage($texte);
$email->send(); 

No error but I receive the html code as text

How is the correct way of sending html mail


RE: sending mail in html - dave friend - 05-28-2020

Change this:

PHP Code:
$email->mailType('html'); 

to this

PHP Code:
$email->setMailType('html'); 

Or

Change this:

PHP Code:
$config['mailtype'] = 'html'

to thisĀ  (case sensitive!)

PHP Code:
$config['mailType'] = 'html'



RE: sending mail in html - cb21 - 05-28-2020

Thank you! It works That would be nice to have an example in the documentation. I didn't find it.