Configuring Emails in Laravel
Asked Answered
L

6

6

I am trying to setup emails in my Laravel aplication, I have my env file something like this:

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

I tried according to the answer given in this question Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted

I followed the steps, enabled 2 step verification, then created app password and configured my .env file

Finally I did php artisan config:cache

Failed to authenticate on SMTP server with username "[email protected]" using 3 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 235 but got code "534", with message "534-5.7.14

Please help me out with this. Thanks.

Lukash answered 25/10, 2018 at 8:58 Comment(17)
So your authentication failed, how do you think we can help?Jellicoe
@Jellicoe I followed the steps, before that I was using normal mail password, but that didn't workout, I am sure there no mistake with my credentials.Lukash
set less secure app in your google account settingAyurveda
@ShaielndraGupta you mean disable 2 step verification and enable less secure app?Lukash
[email protected] is a gmail adress you own right?Octonary
yes @NitishKumarAyurveda
enable less secure app as well 2 step verification also.Besot
@Octonary yes I have purchased GMail for my domain, I can go to gmail and login with the credentials.Lukash
#42559403Besot
@PayalPandav I have already mentioned the same link in the question.Lukash
did you try using ssl encryption and port 465 also?Octonary
@Octonary no, you mean to say MAIL_ENCRYPTION=ssl and MAIL_PORT=465 ??Lukash
@NitishKumar yesOctonary
you want to different reply to..?Ayurveda
@Octonary Same issue, no change. :(Lukash
Check this #42559403 maybe help youIlliquid
@Illiquid I already have same link in my question. I followed the same thing.Lukash
I
7

Steps to configure Gmail/Google SMTP with Laravel

  1. .env file setup

     MAIL_DRIVER=smtp
     MAIL_HOST=smtp.googlemail.com
     MAIL_PORT=465
     MAIL_USERNAME=GMAIL_USERNAME
     MAIL_PASSWORD=GMAIL_PASSWORD
     MAIL_ENCRYPTION=ssl
    
  2. Allow Less Secure Apps

Go to Google Accounts > Security > Allow less secure apps.

  1. Allow new device, either allow new signing from google review notification from your mobile device or if that doesn't work. Login with the same gmail id and open below link, it will enable you to allow the recent login attempt. (only required once to authenticate our Laravel app)

https://www.google.com/accounts/DisplayUnlockCaptcha

P.S. - If you have 2 step verification enabled, then Create app password and use that instead of GMAIL_PASSWORD

Reference - https://support.google.com/mail/answer/7126229

Infinite answered 2/2, 2021 at 14:39 Comment(1)
This UnlockCaptcha saved my day. Thx.Howzell
S
4

I had the same problem. It was the Captcha link that fixed the issue, even though I don't use it. It seems there is an additional step to allow new devices to open the gmail account.

https://support.google.com/mail/answer/7126229?visit_id=636865986363810933-1186759849&rd=1#cantsignin

I had already set up this below beforehand

Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.

Smitt answered 24/2, 2019 at 10:45 Comment(2)
Thank you, @Paul Mead. I just follow your given URL. It works like charm.Podium
thanks the url that work for me is google.com/accounts/DisplayUnlockCaptchaGoddamned
U
4

Need to create new less secure gmail account for configuration Email. your email should not use in more than 3 projects.

Upheave answered 13/11, 2019 at 7:25 Comment(2)
This type of answer should be in a comment.Oviduct
I tried to using with different emails. But it always give me the same error "Failed to authenticate on SMTP server with username "" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "534", with message "534-5.7.14"Psalter
S
2

If you can't solve this with all the answers above, go to your account setting https://myaccount.google.com/security turn on two-step verification and generate an app password, this way will definitely work.

Stockbroker answered 8/8, 2020 at 19:12 Comment(1)
super!! that worked.. thanks a lot, I was trying to solve this issue since a month and your answer worked just in 10 minutes... thank you!!Buckish
M
0

You can use MAIL_PASSWORD=yourapppassword instead of gmail password like

MAIL_DRIVER=smtp
 MAIL_HOST=smtp.googlemail.com
 MAIL_PORT=465
 MAIL_USERNAME=GMAIL_USERNAME
 MAIL_PASSWORD=APP_PASSWORD
 MAIL_ENCRYPTION=ssl

If u are not created. Create a new one go to Google Account ,then security then u will app password.

Myelitis answered 19/7, 2022 at 11:2 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewRubbing
T
0

use app password instead of gmail password go to gmail settings/security In Signing in to Google section open app password and generate password

Tichonn answered 4/1, 2023 at 5:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.