Skip to main content

Posts

Showing posts from September, 2022

javamail jdk11(11.0.10 and above) needs tls upgrade from 1.1 to 1.2

ISSUE 1: Unable to send/read mails using javamail/javaxmail after you upgraded your jdk to 11.0.10 or above?  The reason is they came up with higher security level for SSL with TLS 1.2 which is dependency for latest jdk, find the solution below: Possible Exception if you used older version TLS-1.1:  javax.net.ssl.sslhandshakeexception Solution: Add below property to your existing Properties. properties.put("mail.imaps.ssl.protocols","TLSv1.2");(IMAP used to read mail) properties.put("mail.smtp.ssl.protocols","TLSv1.2");(SMTP used to send mail) ISSUE 2: Unable to type case Multipart to String? From jdk11(latest version) onwards multipart and string cant be type casted, so we need to use Object to store message content. Solution: for (int i = 0; i < messages.length; i++) { Message message = messages[i]; Object content = message.getContent(); if (content instanceof String) { String body = (String)content; System.out.println...