Skip to content

Email bug in StartTLS and advanced settings #519

Description

@markkrj

SMTP has a bug introduced by 579c6ab

After trying out PWM 2.0 (master branch) with 1.9 config, SMTP started failing. Then I went on and investigated.

In 2.0 there was introduced two more options for SMTP configuration which are SMTPS (SMTP over SSL/TLS) and StartTLS (Plain SMTP with STARTTLS). But after trying everyone of them, I found out that the new StartTLS option does not work and plain SMTP does not use advanced settings anymore. We used StartTLS for over 3 years through advanced settings (mail.smtp.starttls.enable=true).

I went further and checked the code.
The following lines set SSL even if using StartTLS, which is wrong:

final MailSSLSocketFactory mailSSLSocketFactory = new MailSSLSocketFactory();
mailSSLSocketFactory.setTrustManagers( trustManager );
properties.put( "mail.smtp.ssl.enable", true );
properties.put( "mail.smtp.ssl.checkserveridentity", true );
properties.put( "mail.smtp.socketFactory.fallback", false );
properties.put( "mail.smtp.ssl.socketFactory", mailSSLSocketFactory );
properties.put( "mail.smtp.ssl.socketFactory.port", port );
final boolean useStartTls = smtpServerType == SmtpServerType.START_TLS;
properties.put( "mail.smtp.starttls.enable", useStartTls );
properties.put( "mail.smtp.starttls.required", useStartTls );

Also, the following is returning properties before putting advanced settings if using plain SMTP:

if ( smtpServerType == SmtpServerType.SMTP )
{
return properties;
}

So basically, the only working options are plain SMTP without advanced settings and SMTPS.

I proposed the PR #494 for this in July and it's still hanging without a comment. It fix the problem and does not conflict, so why not merge and fix this once and for all?

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions