I had the following error regarding the java SSL certificate for sending email:
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
I have generated a certificate using InstallCert.java and NOW i am getting the following error:
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)
Anyone knows how should i resolve this ?? Thanks
As described in the JavaMail FAQ , you need to authenticate to your server. In addition to the example in the FAQ, you can use the Transport.send method that takes a username and password .
Instead of this line:
transport.connect(specProps.getProperty("mail.smtp.host"), port, user, pass);
I had to use this:
transport.connect( null,smtpUser,smtpPassword);
Therefore, by the following way, I could send the email without error:
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!");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.