org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:465

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,
Expert tip

If you're using wiremock, configure your code to accept wiremock self-signed certificate or create a keystore and certificate that are trusted by your HTTP client and configure wiremock to use that

,
via Stack Overflow by carlos

Set the mail.smtp.ssl.trust system property to an smtp host, like smtp.gmail.com.

Solutions on the web

via GitHub by benwhicks
, 7 months ago
Sending the email to the following server failed : smtp.gmail.com:465
via Stack Overflow by M Betz
, 6 months ago
Sending the email to the following server failed : smtp.gmail.com:465
via Stack Overflow by badera
, 1 year ago
Sending the email to the following server failed : mail.gmx.net:465
via Google Groups by mighty....@gmail.com, 2 years ago
Sending the email to the following serve r failed : smtp.gmail.com:465
via Google Groups by Bertram Hurtig, 4 months ago
Sending the email to the following server failed : smtp.gmx.de:25
via Stack Overflow by Frits Verstraten
, 1 year ago
Sending the email to the following server failed : smtp.gmail.com:465
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:543)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:348)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:215)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2019)
at javax.mail.Service.connect(Service.java:386)
at javax.mail.Service.connect(Service.java:245)
at javax.mail.Service.connect(Service.java:194)
at javax.mail.Transport.send0(Transport.java:253)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1400)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at undefined.RJavaTools.invokeMethod(RJavaTools.java:386)

Users with the same issue

2 times, 1 month ago
Once, 2 months ago
25 times, 5 months ago
Once, 6 months ago
Once, 7 months ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.