javax.mail.MessagingExcep tion:无法向SMTP主机发送命令;嵌套异常是:javax.net.ssl.SSLKeyException:RSA premaster secret错误

时间:2012-11-28 12:43:41

标签: email smtp gmail java

在jdk1.4中我可以发送邮件,但是当我尝试使用jdk1.6发送邮件时,我得到以下异常。

My Working Environment.
========================
1.OS       :  windwos 2008
2.JAVA     :  JDK1.6
3.Mail Api :  java mail1.4
4.Email    :  gmail
5.smtp port:  465 or 587
Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingExcep
tion: Can't send command to SMTP host;
nested exception is:
    javax.net.ssl.SSLKeyException: RSA premaster secret error
    at SendMailTLS.main(SendMailTLS.java:47)
Caused by: javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
    javax.net.ssl.SSLKeyException: RSA premaster secret error
    at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1365)
    at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1353)
    at com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:794)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:33
6)
    at javax.mail.Service.connect(Service.java:258)
    at javax.mail.Service.connect(Service.java:137)
    at javax.mail.Service.connect(Service.java:86)
    at javax.mail.Transport.send0(Transport.java:150)
    at javax.mail.Transport.send(Transport.java:80)
    at SendMailTLS.main(SendMailTLS.java:42)

1 个答案:

答案 0 :(得分:0)

您使用的是JDK的lates版本吗? 你能提供不起作用的源代码吗? 请显示邮件代码的输出:

  • System.out.println(“Java version:”+ System.getProperty(“java.version”));
  • System.out.println(“Ext dirs:”+ System.getProperty(“java.ext.dirs”));