Laravel Email is not sending due to the Failed to authenticate on SMTP server with username

Viewed 755

I have a problem when I send mail from localhost everything works fine, but when sending from the server I don't receive mail and I get an error. Failed to authenticate on SMTP server with username please help me how can resolve that? thanks.

please check the error thanks.

https://flareapp.io/share/RmrlNRN7

Swift_TransportException
Failed to authenticate on SMTP server with username "zubair.bhw@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "534", with message "534-5.7.9 Application-specific password required. Learn more at 534 5.7.9 https://support.google.com/mail/?p=InvalidSecondFactor c25sm22236461edt.0 - gsmtp ". Authenticator PLAIN returned Expected response code 235 but got code "534", with message "534-5.7.9 Application-specific password required. Learn more at 534 5.7.9 https://support.google.com/mail/?p=InvalidSecondFactor c25sm22236461edt.0 - 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 c25sm22236461edt.0 - gsmtp ".
https

.env

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=zubair.bhw@gmail.com
MAIL_PASSWORD='12345678'  
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=zubair.bhw@gmail.com
MAIL_FROM_NAME="${APP_NAME}"
MALE_TO=zubair.bhw@gmail.com
1 Answers
  • Try port 465 instead of 587 as Gmail normally uses that one. Check if port is blocked on your live server. Login to your gmail account( mygmail@gmail.com ). Go to https://myaccount.google.com/security , Scroll down till bottom of page. In right you will see: Allow less secure apps, make sure that option is on.
Related