Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gmail SMTP send - 535-5.7.8 Username and Password not accepted

Tags:

smtp

gmail

I am having trouble sending an email from my gmail account with my java application.

I have written simple Java code to send emails from my application. I have MFA turned on and I have created an App Password and I am using it in my code. When I execute the code I get the message

javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials ft13-20020a17090b0f8d00b0022630ba1c80sm1576429pjb.42 - gsmtp

I am fairly certain that the error message is not related to a code issue (but what do I know?) and I have double checked the credentials multiple times to ensure they are correct. I'm trying to understand what else could be the issue. I'd appreciate any advice or things to check.

like image 261
Test Automation Avatar asked Sep 12 '25 09:09

Test Automation


1 Answers

Username and Password not accepted

Is the standard error message when you are trying to connect to Googles SMPT server and are trying to use the users actual google password.

As of May 30 2022 google has removed the less secure apps option. There is no way to turn this on as it no longer exists.

You have two options

  1. Enable 2fa on your google account and create an apps password and use that in place of your true password in your code.
  2. switch to using Xoauth2 most of the libraries support it. it will depend upon the language you are using though.

Quick fix for SMTP username and password not accepted error

like image 89
DaImTo Avatar answered Sep 16 '25 08:09

DaImTo