Bug in Dx auth when used with Gmail as SMTP server
Today I was building a simple authentication system for a web project of mine using CodeIgniter with Dx auth Library. and found a bug in the Dx-auth code when used with gmail as smtp server. i was breaking my head for hours to fix it and finally I got the solution. so here is the small tourtial as to how to fix it.
I was using windows vista, Xampp server (php 5.2) with mysql database.
first varify your SMTP connection details Especially port its not 25 (default) but its 465.
Even after you giving all the right configuration details for your SMTP connection like
$config = Array(
‘protocol’ => ‘smtp’,
‘smtp_host’ => ‘ssl://smtp.googlemail.com’,
‘smtp_port’ => 465,
‘smtp_user’ => ‘username’,
‘smtp_pass’ => ‘*******’,
‘mailtype’ => ‘html’,
‘charset’ => ‘iso-8859-1′
);
your code still might not be working and you may get activity time out by localhost or SSL errors . the exact reason i still could not figure out
But Here is how you can fix it
1. go to System\application\libraries\DX_Auth.php
search for the function _email($to, $from, $subject, $message)
$this->ci->load->library(‘Email’);
$email = $this->ci->email;
$email->set_newline(“\r\n”);
$email->from($from);
$email->to($to);
$email->subject($subject);
$email->message($message);
return $email->send();
as you might have observe the line $email->set_newline(“\r\n”); might not be present in your function so just add the line and problem is solved. I found this solution at this place check the video and comments section .



Hi.
Nice blog!
Where (which file) do you wrote $config = Array [...]?
I’m having problems because the CI never takes the smtp server information that are set directly in the library CI_Email (Email.php).
Thank you.
Hi alex,
$config you can find it in the system/library/ folder with name as Email.php that is where i have setup those settings .
hope it works in your case as well.