The bug is here
props.put("mail.smtp.ssl.socketFactory", serverConfig.getCustomSSLFactoryInstance());
The Prop is ok for a SMTP transport but for a SMTPS transport it should be
props.put("mail.smtps.ssl.socketFactory", serverConfig.getCustomSSLFactoryInstance());
The angus library expects: mail.smtps.ssl.socketFactory or mail.smtps.socketFactory
when the transport is SMTPS and not mail.smtp.ssl.socketFactory or mail.smtp.socketFactory
The Angus code can be seen here
where they use a prefix (ie mail.smtps for SMTPS transport)
Object sfo = props.get(prefix + ".ssl.socketFactory");
A mailer defined has:
Mailer mailer = MailerBuilder
.withSMTPServer("localhost", SmtpService.PORT_587)
.withTransportStrategy(TransportStrategy.SMTPS)
.withCustomSSLFactoryInstance(sslFactory)
.buildMailer()
will therefore not work.
Note that for a custom SSLFactory to work, Angus expects also no value in the prop mail.smtps.ssl.trust, otherwise it creates its own socket as seen here
So I needed to add this 2 lines to make it work:
Session session = mailer.getSession();
Properties properties = session.getProperties();
properties.put("mail.smtps.ssl.socketFactory", sslFactory);
properties.remove("mail.smtps.ssl.trust");
The bug is here
The Prop is ok for a SMTP transport but for a SMTPS transport it should be
The angus library expects:
mail.smtps.ssl.socketFactoryormail.smtps.socketFactorywhen the transport is
SMTPSand notmail.smtp.ssl.socketFactoryormail.smtp.socketFactoryThe Angus code can be seen here
where they use a
prefix(iemail.smtpsfor SMTPS transport)A mailer defined has:
will therefore not work.
So I needed to add this 2 lines to make it work: