I am trying to send email via google SMTP.
The code is working fine in my local windows PC in tomcat. But i got this error on my centos VPS
org.apach
Your host name must be smtp.gmail.com if you are using SMTP and port number can be either 465 or 587. Your error log informs like your username or password is wrong so please ensure your account credentials and try again. Please have a look at this google mail client link.
I got hung up on this... Make sure you set "Protocol" to SMTP+SSL. Otherwise follow instructions here: https://confluence.jetbrains.com/display/TCD8/Setting+up+Google+Mail+and+Google+Talk+as+Notification+Servers
To enable send mail via gmail you must disable some security options in your gmail account: see https://support.google.com/accounts/answer/6010255
Whenever a script tries to login automatically, Gmail generally blocks the script. To enable login through script do this:
If you do not have the activity in the list goto https://accounts.google.com/b/0/DisplayUnlockCaptcha and then try.
Both Tricks worked for me many times.
Even if the Gmail account credentials are correct, Google may still block authentication attempt, suspecting a robot mail sender. To fix it, make sure you are logged in using the same Gmail account in your browser, and then open the link below and step through the process of verification:
https://accounts.google.com/b/0/DisplayUnlockCaptcha
This will allow access to your Gmail account for about 10 minutes. Be sure to try your code within this time frame.
This trick helped me about half a year ago, hope nothing has been changed since then.