Jagdeesh Kumar
Jagdeesh Kumar

Reputation: 1760

Laravel Gmail: Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8

Hey guys I am using laravel and trying to send mail from contact page. It is working fine on local server, but when I am trying to test it on server it is giving me error with user credentials error.

Here is my .env file:

MAIL_DRIVER=smtp 
MAIL_HOST=smtp.gmail.com 
MAIL_PORT=587 
[email protected] 
MAIL_PASSWORD=AppPassword 
MAIL_ENCRYPTION=tls

Upvotes: 2

Views: 8919

Answers (4)

Poonam
Poonam

Reputation: 549

I had the same issue on my local server. I tried many options like turning on less secure apps and turned off 2-step verification but nothing seems worked for me.

So I found this solution, someone may get help with this solution.

You do not need to turn on less secure apps.

Turn on 2-step verification and then Create App Password by clicking here

Select Others (custom name) and click generate.

Use that system generated password as your gmail password.

That's It!

Upvotes: 0

Make sure that you enabled less secure app in security part of your google account. And better use

MAIL_PORT=465
MAIL_ENCRYPTION=ssl

Upvotes: 0

Daniel Beltrami
Daniel Beltrami

Reputation: 776

Two steps: - Enable "Allow less secure apps" on your google account security policy. - Restart your local servers.

Upvotes: 1

mhk
mhk

Reputation: 434

Just change your 'driver' => 'smtp', to 'driver' => 'sendmail' in env file. Make sure allow less secure apps is ON in your google account settings.

Upvotes: 9

Related Questions