Failing to authenticate

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
hessodreamy
Forum Commoner
Posts: 58
Joined: Wed Apr 20, 2005 8:11 am

Failing to authenticate

Post 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)?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
:)
hessodreamy
Forum Commoner
Posts: 58
Joined: Wed Apr 20, 2005 8:11 am

Post 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 :? )
Post Reply