Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Neeraj1005's avatar

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.

This is my env file, can anyone how to fix this?

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=My password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=my_account
MAIL_FROM_NAME=Neeraj
Failed to authenticate on SMTP server with username "[email protected]" using 3 possible authenticators. Authenticator LOGIN returned Expected r ▶
534 5.7.9  https://support.google.com/mail/?p=InvalidSecondFactor 196sm1545659pfw.140 - 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 196sm1545659pfw.140 - 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 196sm1545659pfw.140 - gsmtp
".
0 likes
17 replies
ajithlal's avatar

@neeraj1005 did you turn on less secure app option on your google account?

if you already did that then add this config to mail.php file in your config folder

'stream' => [
        'ssl' => [
            'allow_self_signed' => true,
            'verify_peer'       => false,
            'verify_peer_name'  => false,
        ],
    ],
2 likes
Pradhyuman Jadeja's avatar

I have the same issue, and it does work on my local server however not working on the live server.

Edit: It worked afterward, there was some other issue that I can't figure out but it started working and no issue so far.

gheinrich's avatar

I have been having this same issue and finally came across this solution. Thank you @mallow php! This worked right away with no issues.

thisrahul's avatar

@Mallow php Thankyou so much this is what I was finding for. It solved this problem

JPFarber's avatar

@Mallow php This link solution is not accesible. Is there another option/link/solution? Thnks

shahsmit's avatar

@neeraj1005 I found one sollution & Its Working

  1. Login to your gmail account e.g. myaccount.google.com
  2. Go to Security setting and Enable 2 factor (step) authentication
  3. After enabling, Inside the 2 Step Verfication , you can see App passwords option.
  4. Put your app name and click CREATE button to get new app password.
  5. Finally copy the 16 digit of password and click done. Now use this password instead of email password to send mail via your app.

MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=youremail MAIL_PASSWORD=16degitpasswordwithoutspace MAIL_ENCRYPTION=tls

2 likes

Please or to participate in this conversation.