My Java program stopped sending emails using my gmail Account

I have been struggling with this error for several hours. I have tried to install the Server certificates using the answer provided by Bil Shannon. Nothing worked.

My problem was AVAST Antivirus. Once I have disabled Avast Mail Shield, I was able to send mails via gmail account from my web app.


The key error is this:

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

See this JavaMail FAQ entry.

Since you're connecting to Gmail, this shouldn't happen. The most likely causes are:

  • There's a firewall or anti-virus program intercepting your request.
  • There's something wrong in your JDK installation preventing it from finding the trusted certificate authorities
  • You're running in an application server that has overridden the JDK's list of trusted certificate authorities