user3260912
user3260912

Reputation: 641

Google rejects OAuth 2 Javax.Mail API with bad credentials

java.lang.RuntimeException: 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 v7-20020a4a8607000000b0041bdf977c6dsm58061ooh.31 - gsmtp

I am receiving this error when attempting to use javax.mail API to send emails over my GMail account. I attempted to check my settings to verify it allows less secure apps to use my GMail account but the Google website says

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.

Does anyone know where I can find a current guide on how to build hooks to send/receive mail messages with my GMail account that gets around these new requirements?

Upvotes: 1

Views: 2429

Answers (1)

Gustavo Rupp Santos
Gustavo Rupp Santos

Reputation: 41

  1. Access the page with your Gmail/Google Account -> https://myaccount.google.com/security
  2. In the Signing in to Google section, enable the 2-Step Verification
  3. After enabling 2-Step Verification, return to Signing in to Google section
  4. Click on App passwords
  5. Select app as Mail and select device as Other - choose a name
  6. Done! Copy the password and use it with the username account

Upvotes: 4

Related Questions