Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted

Tags:

php

gmail

laravel

I recently encountered a SwiftMail error while trying to send a mail through gmail.

 Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted.

I was trying to send mail through my gmail and google thought that I was a spam(maybe because I was requesting too fast) I received a mail from them saying my account was access and I told them it was me. I was able to send mail without problem and it just occured now.

This is the contents of my env file.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mypasswordhere
[email protected]
MAIL_NAME=talentscout
like image 228
Camilo Go Jr. Avatar asked Mar 02 '17 15:03

Camilo Go Jr.


2 Answers

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:

  1. enable the 2-step verification to google HERE

  2. Create App Password to be use by your system HERE

  3. I selected Others (custom name) and clicked generate

  4. Went to my env file in laravel and edited this

    [email protected]

    MAIL_PASSWORD=thepasswordgenerated

  5. 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.

like image 174
Camilo Go Jr. Avatar answered Oct 09 '22 04:10

Camilo Go Jr.


I had the same problem, changing my gmail password fixed the issue, and also don't forget to enable less secure app on on your gmail account

like image 22
M-O-H-S-E-N Avatar answered Oct 09 '22 03:10

M-O-H-S-E-N