Skip to content

Support implicit TLS on port 465#12

Open
bugacha wants to merge 1 commit into
KeepSec-Technologies:mainfrom
bugacha:implicit-tls-465
Open

Support implicit TLS on port 465#12
bugacha wants to merge 1 commit into
KeepSec-Technologies:mainfrom
bugacha:implicit-tls-465

Conversation

@bugacha

@bugacha bugacha commented Jul 18, 2026

Copy link
Copy Markdown

Summary

When --tls-mode tls is used with SMTP port 465, Mail2Go now dials with implicit TLS (SMTPS) via mail.WithSSL() instead of STARTTLS. Port 465 expects TLS from the first byte, so the previous WithTLSPolicy(mail.TLSMandatory) (which negotiates STARTTLS on a plaintext connection) fails against implicit-TLS-only servers.

Other ports (e.g. 587, 25) are unchanged and keep using STARTTLS via WithTLSPolicy(mail.TLSMandatory).

The underlying go-mail library already supports both modes; this only wires up the port-465 case.

Change

case "tls":
    if smtpPort == 465 {
        clientOptions = append(clientOptions, mail.WithSSL())
    } else {
        clientOptions = append(clientOptions, mail.WithTLSPolicy(mail.TLSMandatory))
    }

Testing

  • CGO_ENABLED=0 go build -o mail2go . succeeds.
  • Verified against a 465 implicit-TLS endpoint with --tls-mode tls --smtp-port 465.

When tls-mode is "tls" and the SMTP port is 465, use implicit TLS
(SMTPS via mail.WithSSL()) instead of STARTTLS. go-mail already
supports this; other ports keep using WithTLSPolicy(TLSMandatory)
(STARTTLS on 587/25).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant