FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Custom socketFactory is not taken into account with the SMTPS transport · Issue #611 · bbottema/simple-java-mail · GitHub

Custom socketFactory is not taken into account with the SMTPS transport #611

Description

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");

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL