CodeIgniter Forums
Email Library smtp_auth Issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Email Library smtp_auth Issue (/showthread.php?tid=8716)



Email Library smtp_auth Issue - El Forum - 05-28-2008

[eluser]Unknown[/eluser]
Found a small 'bug' (more of a consistency issue) in the Email library in 1.6.2 (may have existed in earlier versions too). The "_smtp_auth" variable is only set if the username and password has been passed to the contructor, not if its passed to the "initialize" method as can be expected.

Broken Example: (does not try to auth with the smtp server)
Code:
$this->load->library('email');
$config['protocol']     = 'smtp';
$config['smtp_port']    =  25;
$config['smtp_host']    = 'mail.test.com';
$config['smtp_user']    = '[email protected]';
$config['smtp_pass']    = 'somepassword';
$this->email->initialize($config);

Working Example: (auths with the smtp server perfectly)
Code:
$config['protocol']    = 'smtp';
$config['smtp_port']   =  25;
$config['smtp_host']   = 'mail.test.com';
$config['smtp_user']   = '[email protected]';
$config['smtp_pass']   = 'somepassword';
$this->load->library('email', $config);

From what I can find, you only set the '_smtp_auth' variable in the CI_Email constructor using this line of code:
Code:
$this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;

If you try to initialize after construction with the login details, they are ignored since '_smtp_auth' in not set anywhere else.

Minor annoyance, but would be easy enough to fix and save the next guy 30 min of head scratching.


Email Library smtp_auth Issue - El Forum - 05-28-2008

[eluser]Référencement Google[/eluser]
I think that could be related to what I've reported here:
http://ellislab.com/forums/viewthread/79267/P0/

I will make some more tests and confirm if what you say solved my problem.


Email Library smtp_auth Issue - El Forum - 05-29-2008

[eluser]Référencement Google[/eluser]
So I confirm this bug relative to the problem I had with the post below, that does the trick!


Email Library smtp_auth Issue - El Forum - 05-29-2008

[eluser]sophistry[/eluser]
yep, looks like you caught a bug. nice one, thanks. did you put it in the bug tracker? (reach it from the codeigniter.com home page link.

as a workaround you could add:
Code:
$config['_smtp_auth']   = TRUE;
to your config array.

obviously, not the real answer, but the initialize code does go thru and dutifully set any keys you send it.

cheers.