Score:0

Email sending in laravel8, fails when using application specific password for gmail

az flag

I have used application-specific password for my Gmail account to send emails since other way does not work in my server environment though it works in local. my configuration is as follows

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=app=pwd-from-gmail
MAIL_ENCRYPTION=ssl
[email protected]
MAIL_FROM_NAME="testy"

but i get following error in the local environment also now.

Swift_TransportException: Failed to authenticate on SMTP server with username "[email protected]" 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 k14sm3626375pfh.154 - gsmtp

How do I fix this issue?

Score:0
az flag

I couldn't solve this issue using app password. However I solved it in other way by following steps.

  1. Disabled two factor authentication
  2. Enabled less secure app
  3. Logged in to the gmail account from a browser in the server.
  4. Changed the app password to account password in the .env file

Now it works that way. I even checked this after signing out from the gmail account from the server browser. It works. It seems like they just need to verify the device. If I move this to another server, then I have to re-login. That is problem I encounter now.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.