开发者

javamail connect to imap over ssl to read mails

I want to read emails from exchange server over IMAP SSL with JavaMail API. I am using the following piece of code.

Properties props =System.getProperties();

props.setProperty("mail.store.protocol","imaps");

Session session = Session.getDefaultInstance(props, 开发者_运维知识库null);

Store store = session.getStore("imaps");

store.connect("server hostname","username","password");

But I am unable to establish a connection. All I get is following error.

javax.mail.MessagingException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed; nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:618) at javax.mail.Service.connect(Service.java:291) at javax.mail.Service.connect(Service.java:172) at

I am not sure if there are any pre-requisite steps to be followed for establishing a connection.

Appreciate your help!


to which mail server u r trying to connect?? replace IMAPS with IMAP and try it.

If you really need to use IMAPS try this

http://blogs.oracle.com/andreas/entry/no_more_unable_to_find


Your particular error seems to indicate that your current SSL certificate is expired.

java.security.cert.CertPathValidatorException: timestamp check failed

You either need to renew your SSL certificate or configure your mail server to point to the correct one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜