How to solve the Sendgrid STMP Error 250 response in Laravel - laravel

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"
MAIL_FROM_ADDRESS=xyz#xyz.com
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.

Try using the literal value 'apikey' as the MAIL_USERNAME, and the key from an API Key that you create in Settings >> API Keys as the MAIL_PASSWORD.
They are now enforcing 2FA, and auth with keys instead of a user/password when using 2FA, starting Nov 18, 2020. I just changed over and this worked for me.
For example,
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=SG.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

We should highlight this one
MAIL_USERNAME=apikey
The string "apikey" is literally the MAIL_USERNAME` for all

Related

Failed to authenticate on SMTP server with username "d0234aa6969603" using 3 possible authenticators. using laravel 8

I am using mailtrap.io for sending emails i am trying to send emails but unfortunatly i am getting error please help me how can i resolved that thank u.
please check error. https://flareapp.io/share/Rmr2ZAqm
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=d0234aa6969603
MAIL_PASSWORD=2d973b871e67d5
MAIL_ENCRYPTION=tls

Gmail smtp not working with only one email

I am using gmail smtp in my laravel, It was working fine till yesterday but it suddenly stopped, I am getting this error
Failed to authenticate on SMTP server with username "email#gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted
Less secure apps was already on so i added 2 factor auth and created an app password but still not working, I created a test email and it worked fine, why is not working with my first email
This is my setting in env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=email#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_EMAIL_ADDRESS=email#gmail.com
I also tried by adding double quotes, but still not wokring,
Can anyone please help
After the removal of less secure apps. You can no longer connect to googles smtp server using the actual password of the users gmail account.
YOu have two options.
enable 2fa on the google account and create an apps password. The apps password can then be used in place of the password in your code.
Switch to using Xoauth2.

"Failed to authenticate on SMTP server" after more than 100 emails

I'm trying to send about 500 emails with Laravel, my provider is Gmail.
The first 150 emails (more or less) are sent correctly, but after I receive this error:
"Failed to authenticate on SMTP server with username "XXXXXXX" using 3 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. Authenticator XOAUTH2 returned Expected response code 250 but got an empty response."
My .env is
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=ssl
MAIL_USERNAME=...
MAIL_PASSWORD=...
I also tried to wait for about 5 seconds between each email, but it doesn't work.
Anyone knows how I can handle this?
Thank you
Try to use the next settings:
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
Enable 2FA in your Google account and create an app password.
Use it in MAIL_PASSWORD
I had a similar problem, and here is how I solved it.
the Google mail service may have blocked emails from being sent from your app. Google surely viewed this as a security threat. you should definitely receive a security alert in your mailbox.
You just have to admit that it was you who tried to access the account or just change your gmail password. after that please change the info in the .env file and i think it will work.
try to change your password on gmail
and also in your .env file

Laravel Mail Can't Send

Failed to authenticate on SMTP server with username "#####gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted```
i have got this error when sending mail.
My .env configaration is
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=#####gmail.com
MAIL_PASSWORD=######
MAIL_ENCRYPTION=ssl
you need to configure .env like this
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
Don't forget to run php artisan config:cache after you make changes in your .env file.
NOTE:- you need to allow less secure apps from "Google Account" - https://myaccount.google.com/ - Settings - Less secure app access (Turn On)
In your case, please try to enable less secure app.
Turn turn off 2 step verification and enable less secure app (as follows)
go to gmail.com
my account
and enable
Allow less secure apps: ON

Failed to authenticate on SMTP server with username "apikey" using 2 possible authenticators in SendGrid

I got the following error when trying to send an Email via SendGrid SMTP.
Failed to authenticate on SMTP server with username "apikey" using 2 possible authenticators. Authenticator LOGIN returned the Expected response code 250 but got an empty response. Authenticator PLAIN returned Expected response code 250 but got an empty response.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=mysecretkey
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="RPLS"
MAIL_FROM_ADDRESS=info#rtsss.com
check your IP to be whitelisted in Sendgrid dashboard
https://app.sendgrid.com/settings/access

Resources