In SMTP, how does STARTTLS on ports 25 and 587 differ from implicit TLS on port 465, and which does RFC 8314 prefer for submission?
answer
- upgrade versus encrypted from the first byte
- cleartext greeting and EHLO come first
- 220 Ready to start TLS, then EHLO again
- the submissions service name
- MX records cannot name a port
basics
~20 sSTARTTLS (RFC 3207) begins in cleartext and upgrades the same connection; implicit TLS on port 465 handshakes before any SMTP is spoken. RFC 8314 (2018) prefers implicit TLS for submission, while relay between servers stays on port 25 with STARTTLS.
solid answer
~50 sWith `STARTTLS` the client connects, reads the `220` greeting, sends `EHLO`, sees `STARTTLS` in the extension list, issues the command, gets `220 Ready to start TLS`, runs the handshake and then sends `EHLO` again, because RFC 3207 makes both sides discard what they learned before the handshake. Relay between MTAs on port 25 and submission on port 587 (RFC 6409) both work this way. Port 465 is the `submissions` service: the TLS handshake starts as soon as TCP connects, so no SMTP travels in cleartext. RFC 8314 (January 2018) says providers SHOULD offer implicit TLS and advertise it in preference to STARTTLS, and SHOULD run both 587 and 465 during a transition; it also notes the two are equally secure when both ends require TLS before submission. Relay has no implicit-TLS port, because an MX record cannot name a port, so MTA-to-MTA encryption is STARTTLS on 25.
go deeper
Recall the three ports and their roles: 25 relay with STARTTLS, 587 submission with STARTTLS, 465 submission with TLS from the first byte.
Walk through the upgrade: cleartext EHLO, STARTTLS, 220, handshake, then a fresh EHLO because pre-TLS knowledge is discarded, and say why AUTH often appears only afterwards.
Explain why relay can only use STARTTLS on 25, why a public MX may not insist on it, and how you would configure a submission service that refuses cleartext.
Argue the migration: when to offer 465 alongside 587, what RFC 8314's equal-security note means for a policy decision, and how you retire cleartext submission for existing clients.
## Two ways to put TLS under SMTP SMTP itself has no encryption. Two mechanisms add **Transport Layer Security (TLS)** to a connection, and they differ in *when* the encryption starts: - **STARTTLS** (RFC 3207, February 2002) is an SMTP service extension. The session opens in cleartext and the client asks to upgrade it in place. It is used on **port 25**, where mail transfer agents (MTAs) relay to each other, and on **port 587**, the message submission port defined by RFC 6409. - **Implicit TLS** (RFC 8314, January 2018) uses a separate port on which the TLS handshake begins the moment TCP connects. For submission that is **port 465**, registered as the `submissions` service. The handshake itself (key exchange, certificates, record protection) is the same in both cases; it belongs to the material on the TLS handshake. What this topic keeps is where and when SMTP hands over to it. ## The STARTTLS upgrade, step by step An administrator testing their own submission server with an ordinary message sees this sequence: 1. `S: 220 mail.example.com ESMTP` — the cleartext greeting. 2. `C: EHLO client.example.net`, answered by a multiline `250` list that includes `STARTTLS`. 3. `C: STARTTLS`, answered by `220 Ready to start TLS`. RFC 3207 also defines `454 TLS not available due to temporary reason` and `501` for a command sent with parameters. 4. Client and server run the TLS handshake and each decides whether the result is good enough to continue. 5. `C: EHLO client.example.net` again. RFC 3207 section 4.2 requires both sides to **discard everything learned before the handshake**, including the extension list, and tells the client to send `EHLO` as its first command afterwards. The server MUST NOT offer `STARTTLS` a second time. The second extension list may differ from the first: a submission server commonly lists `AUTH` only once the session is encrypted. How the client then authenticates is covered with submission authentication; this topic keeps the rule that the upgrade comes first. ## Implicit TLS on port 465 and the port's history On port 465 there is no cleartext phase at all: the client starts the TLS handshake immediately, validates the server certificate, and only then reads the `220` greeting. RFC 8314 section 7.3 records the history. Port 465 was briefly registered as `smtps`, the registration was revoked because the relay infrastructure has no way to signal a port, but widely deployed mail software kept using 465 for secure submission. RFC 8314 re-registered it as `submissions` rather than fight that practice. | | Port 25 | Port 587 | Port 465 | |---|---|---|---| | Role | MTA-to-MTA relay | Submission (RFC 6409) | Submission (`submissions`) | | How TLS starts | `STARTTLS` upgrade | `STARTTLS` upgrade | Handshake at connect | | Cleartext phase | Greeting and `EHLO` | Greeting and `EHLO` | None | | May the server insist on TLS? | Not if it is a domain's public MX | Yes | Always TLS | ## What RFC 8314 recommends for submission - Providers SHOULD offer implicit-TLS instances of submission, POP and IMAP, and SHOULD advertise them in preference to STARTTLS ones. - During a transition of several years, clients and servers SHOULD implement **both** STARTTLS on 587 and implicit TLS on 465. - Providers MUST support TLS for submission and mail access, and those servers MUST support TLS 1.2 or later. - The RFC says there is **no significant security difference** between the two when implementations are correct and both sides require TLS before submission. Its design notes prefer implicit TLS because the upgrade step is more complex and has produced a recurring implementation error across independent products. ## Why relay between MTAs stays on STARTTLS A sender finds the next hop through MX records, and an MX record carries a host name and a preference, never a port. Every MTA therefore connects to port 25, and the only way to encrypt that hop is STARTTLS. RFC 3207 adds a constraint: a **publicly referenced** server, the port-25 host named by a domain's MX (or A) record, MUST NOT require STARTTLS before accepting mail for local delivery, so senders that cannot do TLS can still deliver. That is why encryption between MTAs is opportunistic by default, and why MTA-STS and DANE exist to make it mandatory for domains that ask. ## What an administrator configures and checks - In Postfix, `smtpd_tls_security_level = may` announces STARTTLS without requiring it, which suits a public MX; `encrypt` requires it and suits only a non-public service such as 587. - Postfix runs implicit TLS on a dedicated `submissions` entry in master.cf with `-o smtpd_tls_wrappermode=yes`; its documentation discourages setting wrapper mode in main.cf. - Postfix records TLS details in the Received header when `smtpd_tls_received_header = yes`, which is how a later reader can see that the hop was encrypted.
- Can a submission server on port 587 refuse mail until the client has issued STARTTLS?Yes. RFC 3207 forbids only a publicly referenced server, a domain's port-25 MX, from requiring STARTTLS for local delivery. A submission server is not publicly referenced, so it may answer `530 Must issue a STARTTLS command first` (enhanced code 5.7.0) to every command other than `NOOP`, `EHLO`, `STARTTLS` and `QUIT`. In Postfix that is `smtpd_tls_security_level = encrypt` on the submission service.
- What should a client do when a server answers STARTTLS with 454?`454` means TLS is temporarily unavailable. RFC 3207 leaves the choice to local policy: continue in cleartext, retry later, or give up and notify the sender. A client about to send a password should not continue. An MTA delivering under an enforced MTA-STS policy or to a host with usable DANE records must not fall back to cleartext and treats it as a temporary failure.
- Is implicit TLS on 465 more secure than STARTTLS on 587?Not inherently. RFC 8314 says the security properties are essentially the same when implementations are correct and both sides require TLS before any message data. It prefers 465 because there is no cleartext phase to get wrong: the upgrade step is extra state that independent implementations have mishandled. Running both during the transition is the RFC's own advice.
- Port 465 is a deprecated SMTPS port and should be closed
- Submission on port 587 is unencrypted because it is not port 465
- Mail servers relay to each other over implicit TLS on port 465
- After STARTTLS the extension list from the first EHLO still applies
- A domain's public MX should refuse every sender that does not use STARTTLS