Failed to authenticate on SMTP server error using gmail
This will not work as of May 30, 2022 checkout here https://support.google.com/accounts/answer/6010255?hl=en&authuser=6 Thanks @sarout for pointing this out.
Did you turn on the "Allow less secure apps" on? go to this link
https://myaccount.google.com/security#connectedapps
Take a look at the Sign-in & security -> Apps with account access menu.
You must turn the option "Allow less secure apps" ON.
If is still doesn't work try one of these:
Go to https://accounts.google.com/UnlockCaptcha , and click continue
and unlock your account for access through other media/sites.Use double quote in your password: "your password"
And change your .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=dianexxxxx@gmail.com
MAIL_PASSWORD=xxxxxx
MAIL_ENCRYPTION=tls
because the one's you have specified in the mail.php will only be used if the value is not available in the .env file.
Laravel - Failed to authenticate on SMTP server with username
I have the same your problem today. For months the smtp has been working well and suddently today it gives me the same your error.
For what it worth I simply solved, re-generating the password in google Account -> Security -> App passwords
.
It's not the first time this happend to me. Maybe it's some sort of Google protection... but I didn't found evidence of that anywhere. Anyway it's very annoying.
What I wonder is how to catch this kind of error so that we can intervene on time.
Expected response code 250 but got code 535, with message 535-5.7.8 Username and Password not accepted
I researched on the internet and some answers includes enabling the "access for lesser app" and "unlocking gmail captcha" which sadly didn't work for me until I found the 2-step verification.
What I did the following was:
enable the 2-step verification to google HERE
Create App Password to be use by your system HERE
I selected Others (custom name) and clicked generate
Went to my env file in laravel and edited this
MAIL_USERNAME=talentscoutphil@gmail.com
MAIL_PASSWORD=thepasswordgenerated
- Restarted my apache server and boom! It works again.
This was my solution. I created this to atleast make other people not go wasting their time researching for a possible answer.
Related Topics
Reading Numbers as Text Format With Phpexcel
Removing Specific Elements from Json Encoded Array by Use of PHP
How to Install Imagick/Imagemagick PHP Extension on Windows 7
How to Deal With Json That Is Encoded Twice
How to Set the Default Value of an Attribute on a Laravel Model
How to Get Comma Separated Values from a Table in Laravel
Laravel, Sync() - How to Sync an Array and Also Pass Additional Pivot Fields
How to Get the Sucess Message in the Same Page After Submitting the Contact Form
Remove Country Code from Phone Number
How to Export Data in Multiple Sheets in PHP
Finding the Longest Gap Between Multiple Intervals
How to Get the Path to the Laravel Storage Folder
In Laravel,How to Use Foreach Loop
Build a Tree from a Flat Array in PHP
Difference Between Single-Quoted and Double-Quoted Strings in PHP