I have configured the email function in my Codeigniter application with the following...
$config = [
'protocol' => 'smtp',
'smtp_host' => 'smtp.xxxxx.com',
'smtp_user' => 'xxxxx',
'smtp_pass' => 'xxxxx',
'newline' => "\r\n",
'smtp_port' => 587,
'mailtype' => 'html',
'charset' => 'UTF-8'
];
And sending using...
$sub = 'KONERU Created Sucessfully';
$msg = '<p><a href="koneru.com" >KONERU</a> - Has been Created Sucessfully!</p>';
$msg .= '<br><br><br><p>This mail Generated by computer.<br>Please Don\'t replay to this mail.</p>';
$this->load->library('email', $config);
$this->email->from('xxxxxxxxx','xxxxxxx xxxxxx');
$this->email->to('xxxxxxxxxxxxxx');
$this->email->subject($sub);
$this->email->message($msg);
$this->email->send();
Am able to send an email, but I didn't see HTML format properly on Outlook inbox, I am seeing something like this...
KONERU - Has been Created Su=essfully!
This mail Generated by c=mputer.
Please Don't replay to this mail.
I don't know why, I am seeing some '=' in-between text, I tried with different charset like UTF-8, iso-8859-1 but nothing seems to work.
If I use mailtype = 'text', then if I tried to send a plain text without HTML tags, I didn't see any '=' in between text.
My Answer:
To fix the issue with the email content not being formatted properly in HTML, you can try the following:
1. Make sure that the HTML content in your email message is properly formatted. In your case, it looks like there might be an issue with the special characters in your HTML content. Try using htmlentities() function to encode special characters in your HTML content before adding it to the email message.
2. Check if the email library is properly configured to handle HTML content. Make sure that the 'mailtype' is set to 'html' in the email configuration.
3. Try setting the 'crlf' parameter in the email configuration to "\r\n" instead of 'newline'. This might help with the formatting of the email content.
4. If the issue persists, you can also try using a different SMTP server or service to send the emails. Sometimes, certain SMTP servers may not handle HTML content properly.
By following these steps, you should be able to send HTML-formatted emails without any formatting issues in your Codeigniter application.
Rate this post
5 of 5 based on 3384 votesComments