I changed my SendGrid password yesterday for an unrelated reason and when one of my crons ran this morning, I received the error message below. While it mentions the authenticator, it doesn't give any indication of what the actual error was.
(Paths removed but otherwise message untouched.)
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Expected response code 250 but got code "", with message ""' in /[path]/vendor/sendgrid-php/lib/swift/classes/Swift/Transport/AbstractSmtpTransport.php:422
#0 /[path]/vendor/sendgrid-php/lib/swift/classes/Swift/Transport/AbstractSmtpTransport.php(306): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('', Array)
#1 /[path]/vendor/sendgrid-php/lib/swift/classes/Swift/Transport/EsmtpTransport.php(224): Swift_Transport_AbstractSmtpTransport->executeCommand('RSET??', Array, Array)
#2 /[path]/vendor/sendgrid-php/lib/swift/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php(50): Swift_Transport_EsmtpTransport->executeCommand('RSET??', Array)
#3 /[path]/vendor/sendgrid-php/lib/swift/classes/Swift/Transport/Esmtp/AuthHandler.php(170): Swift_Transport_Esmtp_Auth_LoginAuthenticator->authenticate in /[path]/vendor/sendgrid-php/lib/swift/classes/Swift/Transport/AbstractSmtpTransport.php on line 422
What version of the library are you using?
I can't find a version number. :(
But I assume it's the latest because it has this commit: d292263
@caseysoftware Is still this still an issue for you?
Yes, I just set incorrect credentials and received the same message. It could be as simple as catching the error and giving a more expressive error message.
Here's a post that covers one strategy: http://stackoverflow.com/a/2146171
My first thought was just to wrap the underlying call to the SwiftMailer send method in a try...catch. For whatever reason, that doesn't work. May have something to do with the version of SwiftMailer we are using. Will try again once we upgrade (coming in the next few days).
@caseysoftware this will be ready soon. It's part of version 1.0.3. Once I get access to push up to packagist, it will be available. Until then, you could setup your composer.json to look like:
That will put you on edge, but if you can wait, just wait to version 1.0.3 is officially released.
Thanks for your help to us on all this.
Thank you sir and much appreciated. :)
@caseysoftware that is live now as 1.0.3. By design you'll still have to catch the error, but now the error will look like this (just tested by hand as well on a separate project utilizing this library)
Uncaught exception 'SendGrid\AuthException' with message 'Bad username / password'