menu

Questions & Answers

Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data "

Hi i am trying to send emails in laravel.But when trying to send it is genrating following error and mails are not sending. But everything worked fine in localhost without any problems.

  Failed to authenticate on SMTP server with username "lifeloveandotherthings94@gmail.com" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data
     ". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data"

Following is my code in .env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=MyEmailPassword
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply@lifelove.com
MAIL_FROM_NAME='LifeLoveAndOtherThings'

I havent added additonal code in config/mail.php

'stream' => [
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true,
    ],
],

I havent changed or added my emails in config/mail.php.I have set it up only in .env file. What is the issue here.

Comments:
2023-01-23 23:30:07
Have you enabled "Allow less secure apps" on your google account security policy? Is 2- Factor authentication enabled for this gmail id?
2023-01-23 23:30:07
Yup i have enabled and also generated App password
2023-01-23 23:30:07
Does your password has any special characters? If yes enclose it with double quotes like -> MAIL_PASSWORD="MyEmailPassword"
Answers(5) :

it was solved in my case by disabling the SMTP restriction option from WHM.enter image description here WHM SMTP restriction

For me, this was my problem

Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful 

This happened suddenly after a few month in production (before it worked perfectly). After having visited other post with similar question, none of which worked, the solution that I found was...

to change the password and WAIT SOME TIME in order to be effective.

I know, I know

I think that the password on outlook was expired after some time. The config was the same.

The way you can do if you are using cpanel/whm :

  1. in WHM search TweakSetting in Server Configuration
  2. In Tweak Setting Page click on the Mail tab
  3. Search smtp in Mail tab
  4. search for Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) enter image description here
  5. change the default on to off
  6. Save the new setting

Hope this will help you :)

I have a similar error and I enquoted my password and it worked like charm.

MAIL_PASSWORD="YourEmailPassword"

If the problem still continues try using username, password and port number in double quotes.

If you are using your personal Gmail account then follow these steps :

  1. Go to https://myaccount.google.com/security#connectedapps
  2. Take a look at Security menu -> Apps with account access menu.
  3. You must turn the option "Allow less secure apps" ON.

If you have already followed these steps, try re-starting your project. and if it still doesn't work, please continue these steps :

  1. Visit https://accounts.google.com/UnlockCaptcha
  2. Click continue button

Good luck!

Try to solve it using either of these: Your .env should be something like this..

This if for domain email

MAIL_DRIVER=mail
MAIL_HOST=mail.yourdomain.com
MAIL_PORT=465
MAIL_USERNAME=yourdomain.com
MAIL_PASSWORD="password"
MAIL_ENCRYPTION=ssl
MAIL_FROM_NAME="${APP_NAME}"

This if for Gmail email

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=youremail@gmail.com
MAIL_PASSWORD="yourPassword"
MAIL_ENCRYPTION=ssl
MAIL_FROM_NAME="${APP_NAME}"

The second option Change

MAIL_ENCRYPTION=ssl

to

MAIL_ENCRYPTION=tsl

Or vice versa

The 3rd option

Allow less secure apps in you email

I hope it solve your problem

Comments:
2023-01-23 23:30:07
it's tls not tsl