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

[eluser]fchristant[/eluser]
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:

Code:
$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:

http://ellislab.com/forums/viewthread/13836/#58689

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

Code:
$this->email->send();
echo $this->email->print_debugger();
#2

[eluser]warpman[/eluser]
Wow, thanks for the quick tip. This post saved me from going the same path as you did. Awesome!
#3

[eluser]deeaamon[/eluser]
Hi man,

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

Great Job!!

Darrell




Theme © iAndrew 2016 - Forum software by © MyBB