how to ignore server cert error in javamail

后端 未结 10 1335
长发绾君心
长发绾君心 2020-12-05 07:12

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         


        
10条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 08:07

    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!!

提交回复
热议问题