我发送电子邮件的java SSL证书有以下错误:
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 23 more
我使用InstallCert.java生成了证书,现在我收到以下错误:
com.sun.mail.smtp.SMTPSendFailedException: 550 SMTP authentication mandatory
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at com.MailerPecUtility.sendMail(MailerPecUtility.java:201)
at com.MailerPecUtility.main(MailerPecUtility.java:266)
任何人都知道如何解决这个问题? 感谢
答案 0 :(得分:0)
如JavaMail FAQ所述,您需要对服务器进行身份验证。除了常见问题解答中的示例外,您还可以使用Transport.send method that takes a username and password。
答案 1 :(得分:0)
而不是这一行:
transport.connect(specProps.getProperty("mail.smtp.host"), port, user, pass);
我必须使用它:
transport.connect( null,smtpUser,smtpPassword);
因此,通过以下方式,我可以毫无错误地发送电子邮件:
message.setText("The email body text");
Transport transport = session.getTransport("smtp");
transport.connect( null,smtpUser,smtpPassword);
message.saveChanges();
Transport.send(message);
System.out.println("Message Has been sent!");