>PROBLEM
Attempt to send email fails returning the following message:
javax.mail fails to send email to Gmail account returning: 535-5.7.8 Username and Password not accepted. Learn more at
>SOLUTION
A fast approach is to use the "App Password" option that generates a new password for the application to get access.
Using this option, the only thing necessary is to replace the previous user's password in your java code with the new password generated.
>Extra
Configuration used:
PROPS.put("mail.debug", "false");
PROPS.put("mail.smtp.port", "587");
PROPS.put("mail.smtp.auth", "true");
PROPS.put("mail.smtp.starttls.enable", "true");
PROPS.put("mail.smtp.host", "smtp.googlemail.com");
PROPS.put("mail.smtp.ssl.trust", "smtp.gmail.com");
PROPS.put("mail.smtp.ssl.protocols", "TLSv1.2");
PROPS.put("mail.smtp.host", "smtp.gmail.com");
session = Session.getInstance(PROPS, new javax.mail.Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(SENDER, PASSWORD);
}
});
>ENV
Windows
No comments:
Post a Comment