我不断收到此异常: javax.mail.MessagingException: Unrecognized SSL message, plaintext connection?
如果我用 imap 替换 imap,我会得到 javax.mail.MessagingException: 220 *********** ESMTP MAIL Service ready at Tue, 16 Nov 2021 14:46:44 +0100;
properties.setProperty("mail.imaps.host", host);
properties.setProperty("mail.imaps.port", port);
// SSL setting
properties.setProperty("mail.imaps.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail.imaps.socketFactory.fallback", "false");
properties.setProperty("mail.imaps.socketFactory.port", String.valueOf(port));
properties.setProperty("mail.imaps.starttls.enable", "true");
properties.setProperty("mail.imaps.ssl.enable", "true");
properties.setProperty("mail.imaps.ssl.trust", "*");
properties.setProperty("mail.store.protocol", "imaps");
// Debug
properties.setProperty("mail.debug", "true");