Welcome Guest, Not a member yet? Register   Sign In
sending mail in html
#1

(This post was last modified: 05-27-2020, 09:29 AM by jreklund.)

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
Reply
#2

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'
Reply
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB