Laravel SMTP Gmail failed - laravel

Failed to authenticate on SMTP server with username "user#email.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 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 70sm7122401qkk.10 - gsmtp
". Authenticator PLAIN returned Expected response code 235 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 70sm7122401qkk.10 - 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 70sm7122401qkk.10 - gsmtp
".
Good morning, I'm trying to connect Gmail Smtp, above is the error that I get in laravel 5.8, I generated the application password on my personal mail, then sending emails worked, but as when I generated the application password on work mail, I immediately get the error. That is, when I use my personal mail with the application password, then everything is OK, but as soon as I use work mail I immediately get an error.
On both mailboxes I did the following actions, which are described in Google support
https://support.google.com/accounts/answer/185833
https://support.google.com/mail/?p=BadCredentials
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=user#email.com
MAIL_PASSWORD=generatedAppPassword
MAIL_ENCRYPTION=tls
So if you can help me do this, I would really appreciate

Make sure you account has “Access for less secure apps” enabled and that 2fa login is not enabled.
Update 2022
after the removal of less secure apps. You can no longer connect to googles smtp server using the actual password of the users gmail account.
You have two options.
enable 2fa on the google account and create an apps password. The apps password can then be used in place of the password in your code.
Switch to using Xoauth2.
Quick fix for SMTP username and password not accepted error

i had same issue i resolve this use under
go to gmail.com
my account
and enable
Allow less secure apps: ON
it start works

Related

Sending email fails

I am using my Gmail account and smtp.gmail.com inside my web application(laravel) to test and send the reset password email. When I click on the button "send password reset link", the laravel gave me the error:
"Failed to authenticate on SMTP server with username "xxxemail#gmail.com" using the following authenticators: "LOGIN", "PLAIN", "XOAUTH2". Authenticator "LOGIN" returned "Expected response code "235" 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 hj15-20020a056870c90f00b001631c5f7404sm2432098oab.22 - gsmtp".". Authenticator "PLAIN" returned "Expected response code "235" 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 hj15-20020a056870c90f00b001631c5f7404sm2432098oab.22 - gsmtp".". Authenticator "XOAUTH2" returned "Expected response code "235" but got code "334", with message "334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ=="."."
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail9#gmail.com
MAIL_PASSWORD=****
MAIL_ENCRYPTION=ssl
What can I do to solve this problem?
I had tried to change the e-mail, but not success.
I AM ALREADY USING THE "APP PASSWORD"!
I remember falling in this mistake in the past, in google there's feature called "App Password"
ref: https://support.google.com/accounts/answer/185833?hl=en
So instead of directly using your email and password you have to create new App password and use it, my advice tho (and it's google's advice) is that app password is kinda risky.

LARAVEL:send mail from gmail account?

Failed to authenticate on SMTP server with username "bisd.ensa#gamil.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 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 k12sm6011555wrd.75 - gsmtp ". Authenticator PLAIN returned Expected response code 235 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 k12sm6011555wrd.75 - 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 k12sm6011555wrd.75 - gsmtp ".
any solution please??
The issue you are having is that you are trying to login to the Gmail smtp server using the users login and password.
As the message states you should set up Xoauth2 Using Xoauth2 will allow you to authorze the user using Oauth2 and then you can send an access token with your request rather than the user password
user=someuser#example.com^Aauth=Bearer ya29.vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg^A^A
Alternatively you could try setting up an apps password for the account this often works as well. Even though your error message does not mention it.

Sending Email using Outlook / Office365 with Laravel - Failed to authenticate on SMTP server

I'm trying to send an email with our Laravel app using Office365/Outlook. It has worked well with gmail but when I switched over to Office365, the following error appears:
Failed to authenticate on SMTP server with username
"xxxxxx#companyname.co" using 2 possible authenticators. Authenticator
LOGIN returned Expected response code 235 but got code "535", with
message "535 5.7.3 Authentication unsuccessful
[HKAPR03CA0035.apcprd03.prod.outlook.com]
". Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful
[HKAPR03CA0035.apcprd03.prod.outlook.com]
".
This is what I have in my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=xxxxxx#companyname.co
MAIL_PASSWORD=emailPassword
MAIL_ENCRYPTION=tls
MAIL_SMTPAuth=true
MAIL_FROM_NAME=CompanyName
MAIL_FROM_ADDRESS=xxxxxx#companyname.co
*note: this is not the real username, password and from address.
I also tried changing the port to 25 but I get the same error
I'm using a dedicated support email from my company. And from what I confirmed with our IT, the support email does not have 2 factor authentication and the "Authenticated SMTP" setting is also enabled via the admin panel of Office365 so I don't know what seems to be the problem.
Keep in mind that for the new tenants, Microsoft turns SMTP authentication off, and it needs to be explicitly enabled. Please see
Enable or disable authenticated client SMTP submission (SMTP AUTH) in Exchange Online
as well as
What are security defaults?
I had the same issue and I called Microsoft support. They instructed me to change some security properties in Microsoft Azure. Here is my answer.
You have to enable the 2 factor authentication, the go to your account settings and create an application password. Then you have to use the new application password in your code. Check this link

Laravel - Failed to authenticate on SMTP server with username

Using Laravel-5.8 to send notification, I am getting this error:
Failed to authenticate on SMTP server with username "noblemfd#gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 23 ▶
535 5.7.8 https://support.google.com/mail/?p=BadCredentials n13sm8684140wmd.21 - gsmtp
". Authenticator PLAIN returned Expected response code 235 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 n13sm8684140wmd.21 - 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 n13sm8684140wmd.21 - gsmtp
It was working before, but suddenly began to mis-behave
this is my .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=noblemfd#gmail.com
MAIL_PASSWORD=****
MAIL_ENCRYPTION=ssl
What do I do?
Thanks
I have the same your problem today. For months the smtp has been working well and suddently today it gives me the same your error.
For what it worth I simply solved, re-generating the password in google Account -> Security -> App passwords.
It's not the first time this happend to me. Maybe it's some sort of Google protection... but I didn't found evidence of that anywhere. Anyway it's very annoying.
What I wonder is how to catch this kind of error so that we can intervene on time.
I had the same problem under symfony. I went into my google account and generated an application password via this link
generated password app
Attention you will receive a password with several characters.
Example: 'azer tyui opq'
you will need to replace the spaces with the url code.
Example: azer%20tyui%20opq
In my env file.
For me that to work
1- You must enable two-step verification from the Google Account section, security section, Signing in to Google section.
2- After completing the two-step verification, in the same Signing in to Google section, go to the App passwords section and create a password for the service or device or program you want (PHPMailer or anything else). (On the App passwords page, on the section Click Select app and choose Other option, a text field will be displayed and you should enter PHPMailer or a desired name and then press the Generate button, it will give you a 16 character password.)
3- Copy the displayed password and enter the PHPMailer password in the coding section.

Getting error "Failed to authenticate on SMTP server with username" on Laravel

I'm implementing email sending portal with laravel but it is giving me an error which is given below :
535 5.7.8 https://support.google.com/mail/?p=BadCredentials v21sm1478030pjy.3 - gsmtp
". Authenticator PLAIN returned Expected response code 235 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 v21sm1478030pjy.3 - 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 v21sm1478030pjy.3 - gsmtp
".
Make sure that you don't have 2-Step Verification turned ON with the account you're using and then login the email account on your browser then click this link to allow less secure apps to connect to your GMail Account.

Resources