XF 2.1 Server error log: Swift_TransportException: Email to [email] failed: Failed to authenticate on SMTP server with username "xxxxxx"

PJK

Active member
I've used AWS SES for notifications for XF for years and worked great. Lately I've noticed about 5 errors a day that look like this:
  • Swift_TransportException: Email to xxxxxxx@gmail.com failed: Failed to authenticate on SMTP server with username "xxxxxxx" using 2 possible authenticators
  • src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php:181
The notifications work and emails work, but why is this error happening and how can I resolve it? It started randomly.

Thanks
 
Is there no other text with the error message? Looking at the code, it should have some details as to what errors happened with each specific authentication method it tried.

Unfortunately, if it's working 99% of the time, then that would indicate that it's something on the SMTP server end that's triggering this issue (as this error only happens if they don't give a positive response when sent authentication details).

If you get the error, does it look like the same email is failing each time? The only thing you can go on from the error log is the address the email is sent to. If so, that might indicate something specific about the email that is causing problems (though I should note that this appears to be authentication related, so I think this is happening before the email content is actually sent over). If not, an error like this should normally cause the email to be queued internally and sending will be tried again a few times. It seems likely that a subsequent attempt works, which further points to some sort of temporary issue on the SMTP server.
 
Is there no other text with the error message? Looking at the code, it should have some details as to what errors happened with each specific authentication method it tried.

Unfortunately, if it's working 99% of the time, then that would indicate that it's something on the SMTP server end that's triggering this issue (as this error only happens if they don't give a positive response when sent authentication details).

If you get the error, does it look like the same email is failing each time? The only thing you can go on from the error log is the address the email is sent to. If so, that might indicate something specific about the email that is causing problems (though I should note that this appears to be authentication related, so I think this is happening before the email content is actually sent over). If not, an error like this should normally cause the email to be queued internally and sending will be tried again a few times. It seems likely that a subsequent attempt works, which further points to some sort of temporary issue on the SMTP server.
Thanks for the reply. Here is the full message example below. This is on AWS SES and has worked great, but this error happens at least 1-5 times a day. It isn't the same email each day, it varies and is a range of different emails - yesterday there were like 10 from random emails. Any suggestions on how to resolve this? Thanks:
  • Swift_TransportException: Email to muaaz.xxxxx@gmail.com failed: Failed to authenticate on SMTP server with username "xxxxxxxx" using 2 possible authenticators
  • src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php:181
  • Generated by: Unknown account
  • May 13, 2021 at 12:47 AM

Stack trace​

#0 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(332): Swift_Transport_Esmtp_AuthHandler->afterEhlo(Object(Swift_SmtpTransport))
#1 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand()
#2 src/XF/Mail/Mailer.php(274): Swift_Transport_AbstractSmtpTransport->start()
#3 src/XF/Mail/Queue.php(138): XF\Mail\Mailer->send(Object(Swift_Message), Object(Swift_SmtpTransport), Array)
#4 src/XF/Job/MailQueue.php(12): XF\Mail\Queue->run(G)
#5 src/XF/Job/Manager.php(253): XF\Job\MailQueue->run(G)
#6 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#7 src/XF/Job/Manager.php(79): XF\Job\Manager->runJobEntry(Array, G)
#8 job.php(42): XF\Job\Manager->runQueue(false, 8)
#9 {main}

Request state​

array(4) {
["url"] => string(8) "/job.php"
["referrer"] => string(77) "xxxxxxx"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
 
Ahh, I just realized you're still on 2.1 and the error message has changed in the version of the mail library included in 2.2. The new version would give you more specific details on the error message returned.

Unfortunately, there isn't really any further detail that can be obtained from this message. However, the only reason this happens is if the SMTP server itself is not returning a response that indicates success. If it's sporadic and most mails work, it's not likely that you can do much about it on your side (though seeing the error message might at least give some guidance).
 
  • Like
Reactions: PJK
Have you generated a new IAM user for SMTP? Amazon recently depreciated some stuff, and one site I help with that is still on 2.1 stopped those errors by generating a new IAM user and using that for SMTP to log into.
 
  • Like
Reactions: PJK
Have you generated a new IAM user for SMTP? Amazon recently depreciated some stuff, and one site I help with that is still on 2.1 stopped those errors by generating a new IAM user and using that for SMTP to log into.
Thanks for the feedback guys. Good call, I'll generate a new user and see if that solves it.
 
Top Bottom