Solve error javax.mail.AuthenticationFailedException
You should change the port to 587
, I tested your code and it's working fine
If error still happens, please change session variable to code below:
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password);
}
});
javax.mail.AuthenticationFailedException Java Mail
Go to browser then Login to your gmail account which you trying in your code, then go to the this link https://www.google.com/settings/security/lesssecureapps
You will see
You should click TURN ON
.
AuthenticationFailedException error while sending SMTP email
Login to email from browser and go this page. You will see this;
Make sure to click "Turn on" and try your code again.
Getting error while sending email through Gmail
Do login-to gmail via web browser and click Clik-this.select turn-on button.Once you select you will be able to send mail.
javax.mail.AuthenticationFailedException: failed to connect during Transport.send(Message)
Failed to connect: maybe you connection is blocked by firewall, is your software up to date? No password provided: check the requirements from Google, they maybe changed them and check how your password is provided for your mail method. Maybe the debugger can help you. That's what I would look for.
Related Topics
Exact Difference Between Charsequence and String in Java
How to Make Cartesian Product with Java 8 Streams
Stringbuilder/Stringbuffer VS. "+" Operator
Fetch First Element of Stream Matching the Criteria
Comparing the Values of Two Generic Numbers
How to Use Collections.Sort() in Java
How to Create an Instance of Inner Class Using Java Reflection
How to Intercept a Method Invocation with Standard Java Features (No Aspectj etc)
Cannot Assign Requested Address Using Serversocket.Socketbind
Deserializing an Abstract Class in Gson
Get Integer Value of the Current Year in Java
What Is the Best Library for Java to Grid/Cluster-Enable Your Application
Multiple Runwith Statements in Junit
Java/Jdk for the Apple M1 Chip
Binding a List in @Requestparam
Tablecellrenderer and How to Refresh Cell Background Without Using Jtable.Repaint()