Page 1 of 1

Failing to authenticate

Posted: Tue May 15, 2007 10:16 am
by hessodreamy
I've been using swiftmail for a while, but haven't really had to get INTO it too much. :D
Have moved to a new server and now the authentication won't work. I'm using the same credentials as i use successfully in outlook.
The code I'm using:

Code: Select all

$connection = new Swift_Connection_SMTP($mail_server);

$mailer = new Swift($connection);

$mailer->loadAuthenticator(new Swift_Authenticator_LOGIN);

if(! $mailer->authenticate($mail_username,$mail_password )) 
{
	doLog("Failed to authenticate email", $logErrors);
	exit();
}
I'm checking with my host that all the credentials are spot on, but like i said its all the same as i use in outlook. The SMTP server does require authentication but I think this code handles that?

Any suggestions as to what I might be doing wrong or how I might get better info from the package as to where it is going wrong (The instantiation and function calls leading up to the authentication return TRUE, but not sure how meaningful that is)?

Posted: Tue May 15, 2007 10:35 am
by Chris Corbyn
Upgrade to a newer version. This is old (very early) code which probably had bugfixes made since then. You will need to read the documentation though since the API has changed in a MASSIVE rewrite.

Using Swift-3.2.2

Code: Select all

$connection =& new Swift_Connection_SMTP($mail_server);
$connection->setUsername($mail_username);
$connection->setPassword($mail_password);

$mailer =& new Swift($connection);
//No check needed.  An error will be generated if authentication fails.
:)

Posted: Tue May 15, 2007 10:51 am
by hessodreamy
if i get the time I'll upgrade :)
In the meantime I've been reminded that I don't need to authenticate if I just connect to localhost (avoiding the problem rather than fixing it - nice :? )