One thing to note is that, in most of the cases of Google SMTP server, is that it won't allow SMTP consumption directly, if your account doesn't allow. In many cases, I have seen that many developers have written a correct implementation of the protocol API, but still they cannot send the email. In that case, make sure that your account allows SMTP communication through your authentication. It is in your settings, check it.
Later, the problem is still the authentication to your account. For example, see the error message:
Quote:
javax.mail.AuthenticationFailedException...Please log in via your web browser and then try again.
This tells that you need to authenticate the system to use that account. Google does not allow your application to use this.
One of the following may be the reason:
1. Your account is a new one. Google fights against spam; or that is what they tell us. :laugh:
2. Make sure you can sign in to account from web browser, try your luck at:
mail.google.com.
3. Make sure application is supported as per security standards; SSL, port and authentication etc.
4. Much more.
These are a few of the major things that you need to keep in mind. Your code is correct, the problem is with authentication. Either the username/password is incorrect, otherwise Google is preventing your app to communicate.
Also, the help URL is:
Can’t sign in to my email app - Gmail Help[
^], you are using the wrong one. :-)
For more, please read these:
JavaMail API – Sending email via Gmail SMTP example[
^]
java - Solve error javax.mail.AuthenticationFailedException - Stack Overflow[
^]