我得到下面的异常,同时连接到我的邮件服务器在执行以下线错误通过发送邮件SMTPS
transport.connect("test.mailserver.com",465,"[email protected]","testpwd");
唯一的例外是:
(javax.mail.MessagingException) javax.mail.MessagingException: Exception reading response;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
下面
是代码:
protected static Session initializeSession(MailMessage p_msg) throws Exception{
//Get the SMTP Host
Properties prop = System.getProperties();
prop.put("mail.smtps.host", "test.mailserver.com");
prop.put("mail.transport.protocol", "smtps");
prop.put("mail.smtps.auth", true);
Session session = Session.getInstance(prop,null);
session.setDebug(p_msg.getDebugMode());
return session;
}
protected static void sendMessage(MimeMessage p_msg) throws Exception{
Properties prop = System.getProperties();
Session session = Session.getDefaultInstance(prop, null);
Transport transport = session.getTransport("smtps");
transport.connect("test.mailserver.com",465,"[email protected]","testpwd");
transport.sendMessage(p_msg, p_msg.getAllRecipients());
transport.close();
}
嗨Kandarp,谢谢你的回复..我添加了你提到的两个罐子。 – 2010-12-16 09:39:24
我添加了你提到的两个罐子,并尝试使用它的代码,它引发了一个例外:“连接到smtp.gmail.com的错误,465”用于gmail,当我尝试这个为我的邮件服务器抛出以前的异常(javax。 mail.MessagingException)javax.mail.MessagingException:异常读取响应;嵌套异常是:javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径验证失败:java.security.cert.CertPathValidatorException:主题/颁发者名称链接检查失败 – 2010-12-16 09:45:14