Welcome Guest, Not a member yet? Register   Sign In
Fix for SMTP sending problem

hi all,

I've pulled quite some hair whilst troubleshooting the sending of SMTP email via Code Igniter's Email class. The fix turned out to be not intuitive at all, but it did do the trick, so hereby I would like to share it with you.

My situation is that I have a local development server, whereas the SMTP server is external. On the SMTP server the provider created an account which I can use to send emails. I configured Code Igniter to use SMTP and provided all my settings, yet debugging showed that AUTH could not be send.

This sent me down the wrong path. I started to check firewall settings, my credentials, host authorizations and much more. None of those things helped, as the fix was the simply change the newline character:

$config['protocol']  = 'smtp';
$config['smtp_host'] = "smtp.externaldomain.com";
$config['smtp_user'] = "myuser";
$config['smtp_pass'] = "mypass";
$config['smtp_port'] = 25;
$config['mailtype']  = 'text';
$config['charset']  = 'utf-8';
$config['newline'] = "\r\n";

...and that did the trick! By default, CI uses '\n' as a newline character, which was rejected by the SMTP server. I got this fix from the Expression Engine forum:


In case of email sending problems, be sure to enable debugging so that you can inspect the response of the SMTP server in detail:

echo $this->email->print_debugger();

Wow, thanks for the quick tip. This post saved me from going the same path as you did. Awesome!

Hi man,

Thanks a lot. I was just having the same problems and this fixed everything for me as well.

Great Job!!


Theme © iAndrew 2016 - Forum software by © MyBB