2016-09-21 87 views
0

我有關於發送電子郵件的Java的SSL證書以下錯誤:Java郵件錯誤:550 SMTP認證

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

而是這行:

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!");