Javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted

jakarta-mailjava

I am getting this error when I try to send mail using the JavaMail API:

javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted

How can I fix this?

Best Answer

Sorry for coming late to Party.These could be the problem in your task if you are using Gmail Server.

  1. Two Step Verification should be turned off.
  2. Allow Less Secure App(should be turned on).
  3. Please Check Your UserName and Password.
  4. Check the code(which was my Problem), Above three You can change form google help center and by Yourself last one My Experience I can Share with You. You need to Authenticate the Mail server before Communicating the message because it is Challenge Response System By which You are Communicating through the mail.I am sharing code snippets file you can refer not able to format my code by ctrl+K.