The response code was expected to be 250, but instead 535 was received, and the message was "535-5.7.8 Username and password not accepted"
P粉510127741
2023-08-21 23:19:07
<p>I recently encountered a SwiftMail error while trying to send an email through gmail. </p>
<pre class="brush:php;toolbar:false;">Expected response code 250, but received code "535" with message "535-5.7.8 Username and password not accepted." /pre>
<p>I tried sending an email through my gmail and Google thought I was spam (probably because I requested too quickly) and they sent me an email saying my account was accessed, which I told them it was I operated it myself. I was able to send emails without issue, I just now have this problem. </p>
<p>This is the content of my env file. </p>
<pre class="brush:php;toolbar:false;">MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=talentscoutphil@gmail.com
MAIL_PASSWORD=mypasswordhere
MAIL_FROM=talentscoutphil@gmail.com
MAIL_NAME=talentscout</pre>
<p><br /></p>
I had the same problem, changing my gmail password solved the problem, also don't forget to enable Insecure Applications on your gmail account
I researched on the internet and some of the answers included enabling "Lower App Access" and "Unlocking gmail verification code" but unfortunately didn't work for me Worked until I found two-step verification.
What I did was:
To enable two-step verification on Google, click here
To create an application password for system use, click here
I selected Other (custom name) and clicked Generate
Go into my laravel environment file and edit it
MAIL_USERNAME=talentscoutphil@gmail.com
MAIL_PASSWORD=Generated password
This is my solution. I created this solution to at least save others from wasting time looking for possible answers.