Mail protocols began without encryption, and ports and programs are hard to change. STARTTLS solves this: the client connects to the ordinary port, the server announces that it supports TLS, and after the command both sides perform a TLS handshake within the same connection.
What it looks like in SMTP
S: 220 mail.example.com ESMTPC: EHLO client.example.orgS: 250-mail.example.comS: 250-STARTTLSS: 250 SIZE 52428800C: STARTTLSS: 220 2.0.0 Ready to start TLS ... TLS handshake ...C: EHLO client.example.orgAfter the handshake, both sides discard everything they learned before it, and the client sends EHLO again, this time over the encrypted channel. This is defined in RFC 3207 (Paul Hoffman, February 2002); other protocols, such as IMAP, have their own RFCs for the command.
Ports: STARTTLS and implicit TLS
| Protocol | STARTTLS | Implicit TLS |
|---|---|---|
| SMTP, client to server | port 587 | port 465 |
| SMTP, server to server | port 25 | not used |
| IMAP | port 143 | port 993 |
RFC 8314 (January 2018) recommends that mail clients prefer implicit TLS: the connection is encrypted from the first byte. When implementations and settings are correct, the two methods are comparable in security, but port 587 with STARTTLS remains very common.
The weak spot
Between servers, STARTTLS is usually opportunistic: if encryption cannot be negotiated, the message is sent in the clear. An attacker in the middle of the channel can strip the 250 STARTTLS line from the server’s reply, and the client will not try to enable TLS. The defence is to require TLS in client and server settings and, between servers, to publish an MTA-STS policy.
Sources
the term is written from these pagesVerified 9 Nov