Spring MailSender suddenly stopped working properly

737 Views Asked by At

I've been using spring's MailSender for a few weeks now on a project I'm working on. I have it set up such that an email sends a confirmation token to a newly registered user to confirm their account. This has been working steadily the whole time. Today it's saying that the Username/Password is incorrect. It isn't. It's a gmail account that I am using, and I enabled the feature that allows for less secured apps to interact with the email.

Not sure if its related but I noticed this when checking if it was enabled on the settings of the gmail account.

"To help keep your account secure, from May 30, 2022, ​​Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password."

Could this be the problem?

Here's part of the error message (relevant part)

DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "SMTPUTF8", arg ""
DEBUG SMTP: STARTTLS requested but already using SSL
DEBUG SMTP: protocolConnect login, host=smtp.gmail.com, user="MY EMAIL I REMOVED IT", password=<non-null>
DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM XOAUTH2 
DEBUG SMTP: Using mechanism LOGIN
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN failed
[2m2022-06-07 09:12:32.509[0;39m [31mERROR[0;39m [35m8616[0;39m [2m---[0;39m [2m[nio-3307-exec-8][0;39m [36mo.a.c.c.C.[.[.[/].[dispatcherServlet]   [0;39m [2m:[0;39m Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is 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 m8-20020a05600c4f4800b003942a244f51sm27447733wmq.42 - gsmtp
] with root cause

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 m8-20020a05600c4f4800b003942a244f51sm27447733wmq.42 - gsmtp

TLDR

My MailSender keeps saying that my credentials are wrong (Username or password) and they aren't. I also enabled less secured apps to use this email. What might be causing this problem? It was working just fine past few weeks.

0

There are 0 best solutions below