communication email_config ai_generated true

SMTP connection fails — TLS vs STARTTLS port confusion (465 vs 587)

ID: communication/smtp-tls-starttls-port-confusion

Also available as: JSON · Markdown
90%Fix Rate
92%Confidence
4Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
any active

Root Cause

Using implicit TLS (port 465) settings with STARTTLS port (587) or vice versa.

generic

Workarounds

  1. 93% success Use port 587 with STARTTLS for submission (RFC 8314)
    smtplib.SMTP('smtp.example.com', 587); server.starttls()

    Sources: https://www.rfc-editor.org/rfc/rfc8314

  2. 88% success Use port 465 with implicit TLS when STARTTLS is not supported
    smtplib.SMTP_SSL('smtp.example.com', 465)

    Sources: https://www.rfc-editor.org/rfc/rfc8314

Dead Ends

Common approaches that don't work:

  1. Use port 465 with STARTTLS 95% fail

    Port 465 expects implicit TLS; STARTTLS is an upgrade from plaintext

  2. Use port 587 with implicit SSL/TLS 95% fail

    Port 587 starts plaintext and upgrades via STARTTLS