when i connect to my imap server using imaps,it failes.
can you tell me how to ignore server cert error in javamail
Exception in thread \"main\"
java
If It is the problem persisted in Java 6 then the solution is simple.It is just simple as Java 7 was released.Install java 7 in machine.java 7 have the certificates file having the capability of ignoring certificate authentication.
copy the "cacerts" file from following java 7 directory
C:\Program Files\Java\jdk1.7.0_79\jre\lib\security
and paste it in
C:\Program Files\Java\jdk1.6.0\jre\lib\security
now the certificate authentication problem will be resolved.
I was the same issue.
MailSSLSocketFactory socketFactory = new MailSSLSocketFactory(); socketFactory.setTrustedHosts(new String[] { "my-server"});
socketFactory.setTrustAllHosts(true); props.put("mail.smtps.socketFactory", socketFactory);
it's works!!
use prop.put("mail.imaps.ssl.trust", "*");
since you are using imaps
store.
and for smtp
you can try :
prop.put("mail.smtp.ssl.trust", "*");
.
Properties propsSSL = new Properties();
propsSSL.put("mail.transport.protocol", "smtps");
propsSSL.put("mail.smtps.host", "hostname");
propsSSL.put("mail.smtps.auth", "true");
propsSSL.put("mail.smtps.ssl.checkserveridentity", "false");
propsSSL.put("mail.smtps.ssl.trust", "*");
Above changes will fix javax.mail.MessagingException: Could not connect to SMTP host: hostname, port: 465;
for the nested exception
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
exception