I am currently getting
sun.security.validator.ValidatorException: PKIX path building failed:
another exception is:
unable to find valid certification path to requested target
Here is my java code if this helps.
` def send(toAddress, fromAddress, subject, emailBody){
final String username = applicationService.getMailUsername();
final String password = applicationService.getMailPassword()
Properties props = new Properties();
def auth = applicationService.getMailAuth()
def starttls = applicationService.getMailStartTlsEnabled()
def host = applicationService.getMailHost()
def port = applicationService.getMailPort()
props.put("mail.smtp.auth", auth);
props.put("mail.smtp.starttls.enable", starttls);
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", port);
println "to : ${toAddress} -> from : ${fromAddress} -> auth : ${auth} -> starttls : ${starttls} -> host : ${host} -> port : ${port}"
Session session = Session.getInstance(props,
new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromAddress));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toAddress));
message.setSubject(subject);
message.setText(emailBody, "utf-8", "html");
Transport.send(message);
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}`
What am I missing?
I am new to setting up mail servers and how to configure and use. Any additional information is much appreciated.