c702f1bdac
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 17s
CI / ui (pull_request) Successful in 1m4s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m54s
The 465-only implicit-TLS heuristic mis-classified Selectel's SSL port (1127), which the mailer would have dialled with STARTTLS and failed. Add BACKEND_SMTP_TLS (ssl|starttls) — empty still derives the mode from the port (implicit on 465, else STARTTLS) — and dial implicit TLS with WithSSL()+WithPort so any port works, not just 465. Wire SMTP_RELAY_TLS through compose/ci/prod/.env.example and document it (Selectel: 1127 = SSL, 1126 = STARTTLS). Unit-tested.
30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
package account
|
|
|
|
import "testing"
|
|
|
|
// TestSMTPTLSMode covers the explicit TLS mode and the port-based fallback, including
|
|
// the non-standard Selectel ports (1127 = SSL, 1126 = STARTTLS) that the 465 heuristic
|
|
// alone cannot classify.
|
|
func TestSMTPTLSMode(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
tls string
|
|
port int
|
|
want string
|
|
}{
|
|
{"explicit ssl on a custom port (Selectel 1127)", "ssl", 1127, smtpTLSImplicit},
|
|
{"explicit starttls on a custom port (Selectel 1126)", "starttls", 1126, smtpTLSSTARTTLS},
|
|
{"tls is an alias for ssl", "TLS", 2525, smtpTLSImplicit},
|
|
{"empty derives implicit TLS on 465", "", 465, smtpTLSImplicit},
|
|
{"empty derives STARTTLS on 587", "", 587, smtpTLSSTARTTLS},
|
|
{"an unknown value falls back to the port heuristic", "bogus", 465, smtpTLSImplicit},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
if got := (SMTPConfig{TLS: c.tls}).tlsMode(c.port); got != c.want {
|
|
t.Errorf("tlsMode(TLS=%q, port=%d) = %q, want %q", c.tls, c.port, got, c.want)
|
|
}
|
|
})
|
|
}
|
|
}
|