Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rajdeepom12's avatar

Sendgrid STMP Error 250 response

Hi All,

I am using Sendgrid for the mail service.

My Account is two factor authentication is enabled.

My .env

MAIL_DRIVER=smtp

MAIL_HOST=smtp.sendgrid.net

MAIL_PORT=587

MAIL_USERNAME=S4gYKuoPRBaOAy7qT__J8w

MAIL_PASSWORD=SG.APIKEYPASSWORD

MAIL_ENCRYPTION=tls

MAIL_FROM_NAME="Xyz Name"

[email protected]

If I execute the mail then I am getting below error.

Swift_TransportException : Failed to authenticate on SMTP server with username "S4gYKuoPRBaOAy7qT__J8w" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 250 but got an empty response. Authenticator PLAIN returned Expected response code 250 but got an empty response.

And If I disable the two-factor authentication then it works with the UserName and Password of the account but sendgrid will suspend my account if I do it like this.

Can anyone faced this issue. if yes then please let me know how you solved the problem.

0 likes
6 replies
ian_h's avatar

Looks like the username is wrong. THis is the config from one of my apps using Sendgrid:

MAIL_MAILER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=$MY_SENDGRID_API_PASSWORD

MAIL_USERNAME needs to be literally apikey not an actual API key :)

This is done as most apps don't actually require a username and API key, it's all done with the API key (a token).. and the 'username' in this case just tells sendgrid that authentication should be done with the API key (which in this case, would be the password).

Cheers..

Ian

2 likes
sulimanBabar's avatar

@ian_h 😂 O man I dont know if I should complain like a Karen or laugh it off. Its tricky. Thanks

rajdeepom12's avatar

As I said that I have enabled two factor authentication... It will not work

marcellopato's avatar

No one could solve this yet? I am stuck in the same error here...

Please or to participate in this conversation.