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?
Sorry for coming late to Party.These could be the problem in your task if you are using Gmail Server.
This worked for me:
Update: Google stopped supporting "Less Secure Apps" as of May 30th, 2022.
One of the alternatives to solve this problem is to use 2-Step Verification and generate app password:
Google support link here.
Update since June 2022: Google closed the "Less secure app access", but opened another option called "App Passwords":
"When you use 2-Step Verification, some less secure apps or devices may be blocked from accessing your Google Account. App Passwords are a way to let the blocked app or device access your Google Account." (see docs).
Follow this answer to set up App Passwords
Hint: when using Jenkins Email Extension Plugin, emailext
(which does not permit tokens like Google's App Passwords, still requiring logins), just use App Password as the password, and supply any string as login, e.g. your Gmail address login.
OLD ANSWER , not relevant anymore
Step 1: Log into your gmail account
Step 2: Click Settings
Step 3: Click the Accounts and Import Tab > Other Google Account Settings
Step 4: Click Security
Step 5: Set Allow less secure apps to ON
mail.smtp.host=smtp.gmail.com
,
mail.smtp.port=25
,
mail.smtp.auth=true
mail.smtp.starttls.enable=true
Now,make sure that two step verification is off
Allow less secure app (ON) follow this link :-
https://myaccount.google.com/lesssecureapps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With