0

I am trying to use Google's SMTP server to send emails from my Laravel 7.x application. The config settings I am using are copied from my other working Laravel apps (with credentials changed).

My Gsuite account has 2-step verification enabled and I am using application password in my .ENV file.

Somehow though, I am getting the following error every time:

 Failed to authenticate on SMTP server with username "hello@xxxxx.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. Learn more at 535 5.7.8 
 https://support.google.com/mail/?p=BadCredentials gb19sm28030pjb.38 - gsmtp ". Authenticator PLAIN 
 returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and 
 Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials 
 gb19sm28030pjb.38 - gsmtp ". Authenticator XOAUTH2 returned 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 
 https://support.google.com/mail/?p=BadCredentials gb19sm28030pjb.38 - gsmtp ". 

My .env entries look like this:

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=hello@xxxx.com
MAIL_PASSWORD=hqubwafijjkkvexnah
MAIL_ENCRYPTION=tls

Issue is with Goog;le's smtp because when I point to mailtrap instead, everything works fine.

hackernewbie
  • 1,606
  • 20
  • 13

1 Answers1

0

I managed to solve this by changing Less Secure Apps to On and also, turning 2-Step verification off. But I do not think this is the approach I would like to go with, in the long term.

For now, this stands solved.

hackernewbie
  • 1,606
  • 20
  • 13