I was using the JavaMail API to send an email containing a text file. This code I wrote was working perfectly fine last week, however I logged on today and ran the program and received the error in the image I've attached at the bottom. I updated to the newest version of java 8 and still receive this error. (I have to use java 8 for the project for work) I looked at the java 8 patch notes for this update and saw the removed of root CA Certificates and I'm not sure what to think/do. I am posting this question because I cannot find any solution in the other tons of questions about this.
I am running Java 8 (jre 1.8.0_221) and previously was running jre 1.8.0_211. I do not know what changed as it stopped working today with v.211 and is also not working after I updated to the most recent version of Java 8 with v.221. I have tried various other properties with no success. I'm not sure if it is the Java removal of something specific (which I doubt) or if it has to do with firewall permissions any smtp permissions I may or may not have. Anyways, the code is below for the email sending portion and the code fails at Transport.send(message);
with error "Could not convert socket to TLS"
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", "25");
props.put("mail.smtp.debug", "true");
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(smtpUsername, u2);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
message.setSubject(prop.getProperty("Message"));
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(prop.getProperty("Message"));
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(prop.getProperty("text") + ".txt");
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(prop.getProperty("filename"));
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
System.out.println("Sent successfully.\n");
Error Message I am receiving. Hopefully I have explained thoroughly enough. This is only my second question I've asked on here. Any help is appreciated, thanks.
I am not an expert , but...
You may be impacted by intentional distrusting of some root certificates in April 2019, or whenever they were applied in your environment (re: https://blogs.oracle.com/java-platform-group/jdk-distrusting-symantec-tls-certificates ).
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.