STARTTLS is a protocol extension command that upgrades an already open plaintext connection to an encrypted TLS session on the same port, without opening a new connection. In email infrastructure across the Internet, it is the standard way SMTP servers encrypt mail in transit between each other, and it is also used by IMAP, POP3 and several non-mail protocols such as XMPP and LDAP.
The approach is known as opportunistic or explicit TLS, in contrast to implicit TLS, where encryption starts immediately on a dedicated port. STARTTLS made it possible to add encryption to protocols designed in the 1980s without breaking older servers, but that backward compatibility is also the source of its best-known weaknesses.
How the STARTTLS upgrade works
The STARTTLS upgrade follows a fixed sequence: the client connects in plaintext, learns that the server supports encryption, issues the STARTTLS command, performs a TLS handshake, and then restarts the protocol session inside the encrypted channel. For SMTP this behavior is defined in RFC 3207, and for IMAP and POP3 in RFC 2595.
In an SMTP session, the server advertises the capability in its reply to EHLO. The client sends STARTTLS, the server answers 220 Ready to start TLS, and both sides negotiate keys and certificates. After the handshake, the client must discard all earlier state and send EHLO again, because anything learned in plaintext could have been altered.
The steps below summarize a typical server-to-server exchange.
| Step | Sender action | Receiver response |
|---|---|---|
| 1. Connect | Opens TCP to port 25 | Sends a 220 greeting |
| 2. Capability query | Sends EHLO | Lists extensions including STARTTLS |
| 3. Upgrade request | Sends STARTTLS | Replies 220 ready to start TLS |
| 4. TLS handshake | Negotiates cipher and keys | Presents its certificate |
| 5. Session restart | Sends EHLO again over TLS | Lists extensions afresh |
| 6. Mail transfer | Sends MAIL FROM, RCPT TO, DATA | Accepts or rejects the message |
Ports and the difference between STARTTLS and implicit TLS
STARTTLS and implicit TLS both produce an encrypted session, but they differ in when encryption begins and which port is used. With implicit TLS, the TLS handshake is the first thing that happens on the connection, so no protocol command is ever exchanged in plaintext.
Current guidance in RFC 8314 recommends implicit TLS for mail submission and retrieval by users, while server-to-server relay on port 25 continues to depend on STARTTLS because there is no widely adopted implicit-TLS alternative for MX delivery. A receiving MX host has no way to know in advance whether a sender expects encryption, so the single shared port 25 must serve both encrypted and unencrypted peers.
| Port | Protocol use | Encryption method |
|---|---|---|
| 25 | SMTP relay between servers | STARTTLS, usually opportunistic |
| 587 | Mail submission by clients | STARTTLS, normally required |
| 465 | Mail submission by clients | Implicit TLS |
| 143 | IMAP access | STARTTLS |
| 993 | IMAP access | Implicit TLS |
| 110 and 995 | POP3 access | STARTTLS and implicit TLS respectively |
Opportunistic versus enforced STARTTLS
Most mail servers use opportunistic STARTTLS: they encrypt when the receiving server advertises support and fall back to plaintext when it does not. They also typically accept any certificate, including self-signed or expired ones, because rejecting mail over certificate problems would cause widespread delivery failures.
Opportunistic encryption defends well against passive eavesdropping but offers little protection against an active attacker positioned on the network path. Several mechanisms in the same topic area exist to turn STARTTLS from a best-effort measure into an enforced policy.
| Mechanism | How it works | Main requirement |
|---|---|---|
| MTA-STS | Publishes a policy over HTTPS requiring valid TLS | Web server and DNS record |
| DANE for SMTP | Pins certificates in DNS TLSA records | DNSSEC-signed zone |
| TLS-RPT | Sends reports about TLS delivery failures | Reporting address in DNS |
| Local enforcement | Requires TLS for chosen destinations | Manual MTA configuration |
MTA-STS and DANE both instruct sending servers to refuse delivery rather than downgrade to plaintext. TLS-RPT complements them by giving domain owners visibility into failures before an enforced policy blocks legitimate mail.
Known weaknesses and attacks on STARTTLS
The central weakness of STARTTLS is that the negotiation happens in plaintext, so an attacker who can modify traffic can interfere before encryption starts. The classic example is a STARTTLS stripping attack, in which a middlebox removes the STARTTLS capability from the server’s EHLO reply, causing the client to continue unencrypted.
A second class is command injection, where an attacker appends plaintext commands after the STARTTLS command in the same TCP packet. A vulnerable server buffers those commands and executes them inside the TLS session as if they were authentic. Research published in 2021 found such buffering flaws in numerous mail clients and servers, which is one reason RFC 8314 favors implicit TLS for client access.
- Stripping: the capability is removed, and opportunistic clients silently use plaintext.
- Buffer injection: pre-handshake data is processed after encryption begins.
- Certificate laxity: unchecked certificates allow interception with a forged identity.
- Hop-by-hop scope: each relay decrypts mail, so STARTTLS never provides end-to-end confidentiality.
Correct implementations flush the input buffer at the moment of the upgrade, require TLS on submission ports, and validate certificates wherever a policy such as MTA-STS applies. For message-level confidentiality, organizations still need S/MIME or OpenPGP, because STARTTLS protects only the transport between two servers.
The short version
STARTTLS is like two people beginning a phone call in the open and then agreeing to switch to a private, scrambled line before discussing anything sensitive. The call continues on the same number, but from that moment outsiders can no longer understand it.
Email servers use it to protect messages while they travel from one server to the next. Its weak spot is the brief open moment at the start: someone listening in can try to prevent the switch. Extra rules such as MTA-STS tell servers to refuse to talk openly instead of quietly continuing without protection.
Where it makes a difference
A regional health clinic exchanges patient referrals by email with roughly 30 partner hospitals. Its mail server already offered opportunistic STARTTLS, but a review of TLS-RPT reports showed that about 2 percent of inbound sessions from one network path arrived in plaintext, a pattern consistent with STARTTLS stripping by a misconfigured or hostile middlebox.
The IT team obtained a publicly trusted certificate for the MX host, published an MTA-STS policy in testing mode for four weeks, reviewed the reports, and then switched the policy to enforce. They also moved staff mail clients from port 587 to implicit TLS on port 465 and disabled plaintext IMAP on port 143.
After the change, partner servers that honor MTA-STS refused to deliver without valid encryption, plaintext sessions on the monitored path dropped to zero, and the clinic could document enforced transport encryption for its compliance audit.