Guide · SMTP and headers
STARTTLS vs. implicit TLS: which mode belongs on ports 587 and 465?
Mail submission with STARTTLS usually runs on port 587: the client first exchanges SMTP greetings, then asks the server to switch the same connection to TLS. With implicit TLS, usually on port 465, the TLS handshake starts as soon as the connection opens. Both protect submission well when the client validates the server's certificate and refuses to submit anything until TLS has succeeded. Use the host, port and mode your sending provider documents, not the setting whose name sounds strongest.
- Reading time
- 6 min
Two ways to an encrypted SMTP session
On port 587 the server sends its greeting and the client sends EHLO. The server lists STARTTLS among its capabilities, the client sends STARTTLS, the server answers 220 Ready to start TLS, and the handshake begins (RFC 3207, section 4). After it, both sides must discard what they learned before TLS, and the client should send EHLO again as its first command (section 4.2). The capability list after the handshake can differ from the one before it.
On port 465 (the "submissions" service), the TLS handshake begins immediately when the TCP connection is established (RFC 8314, section 3.3). There is no plain-text greeting and no STARTTLS command. The SMTP greeting, EHLO, authentication and the message all travel inside TLS.
Two simplified timelines (not traces from a real provider):
587, STARTTLS required:
connect → greeting → EHLO → STARTTLS offered → STARTTLS → 220 → TLS handshake and certificate check
→ new EHLO → authenticate and submit inside TLS
465, implicit TLS:
connect → TLS handshake and certificate check → greeting and EHLO inside TLS → authenticate and submit inside TLSIn neither one does the client send credentials or the message before the encrypted connection is established.
Why a mismatched mode and port fails
| Setting | Endpoint expects | What usually happens |
|---|---|---|
| Implicit TLS | STARTTLS (port 587) | The client sends the start of a TLS handshake to a server waiting for SMTP commands: a handshake or protocol error. |
| STARTTLS | Implicit TLS (port 465) | The client waits for an SMTP greeting while the server waits for a handshake: a timeout, an early disconnect or a greeting error. |
The exact message depends on the client and the server, so do not diagnose a specific error string from the port alone. A timeout here does not mean the password is wrong: authentication may never have started.
A working TCP connection proves only that the client reached a listening port. It does not show which mode the listener speaks or that the host name matches the certificate. Write down the exact host, port and security mode and compare all three with the provider's current instructions. Do not swap ports and modes at random, turn off certificate validation, or send credentials in plain text to make an error go away. On a server you run, check the listener's configuration and its logs to see where negotiation stopped.
Is port 465 more secure than 587?
RFC 8314 (section 3.3) says there is no significant difference between the security of STARTTLS on port 587 and implicit TLS on port 465 if the implementations are correct and both client and server require successful TLS before submission. It still prefers implicit TLS (sections 1 and 3), while asking clients and servers to implement both during the transition (section 3.3) and mail providers to offer implicit TLS (section 4).
What changes the answer is fallback. STARTTLS starts in plain text, and RFC 3207 (section 6) warns that an attacker in the path can delete the 250 STARTTLS line, so the client never tries TLS. That is why the RFC requires that clients and servers can be configured to insist on TLS before mail is transferred. A client that carries on without encryption when STARTTLS is missing or fails gives no protection against that attack.
Validate the certificate, and fail closed
Encryption without certificate validation does not stop someone in the middle. RFC 8314 sets these rules for mail clients:
- Validate the server's certificate following RFC 7817 (section 5.3). By default, a new account must require successful certificate validation (section 5.2).
- With that minimum in place, do nothing on a connection that does not meet it except discover capabilities or start STARTTLS (section 5.2), and do not offer an easy "send anyway" click-through (section 5.2).
- Never "test" an account setting by sending the user's credentials over a connection without TLS (section 5.1).
- A client may offer to pin a certificate that does not validate only while an account is being set up, never after a failed check on an existing account. Even then a man-in-the-middle at setup can supply the certificate and capture the password, so a pinned connection does not count as validated, and the client must not present it as confidential (section 5.4). For a provider's public submission host, a certificate that does not validate is a reason to stop, not to pin.
So enable certificate and host-name checking, require TLS, and allow no plain-text fallback. Labels in mail client settings vary, so check what a setting does, not what it is called. If required TLS cannot be established, fix the configuration or contact the provider with a log that has credentials and addresses removed.
Submission is not relay between servers
Submission is the connection from your application or mail client to the provider that accepts its outgoing mail. Relay is between mail servers, on port 25. RFC 8314 (section 1) does not cover relay. Choosing port 465 for your application does not decide how later hops are protected, and it does not make a recipient's MX server a submission server. RFC 3207 (section 4) also says a publicly referenced server on port 25 must not require STARTTLS to deliver mail locally.
Between servers, MTA-STS lets a recipient domain publish which MX hosts may receive its mail and a mode. In "enforce" mode, sending servers must not deliver to a host that fails MX matching or certificate validation or does not support STARTTLS (RFC 8461, section 5). That is separate from how your application submits to its own provider (MTA-STS and TLS reporting).
A checklist for a failed setup
- Confirm the provider's exact submission host and which mode it uses on which port.
- Find the earliest stage that failed in a log with credentials removed: connect, greeting, TLS negotiation, certificate validation or authentication.
- For STARTTLS, check that the client reaches the upgrade and then sends a new EHLO. For implicit TLS, check that TLS starts before any SMTP.
- If authentication fails after TLS succeeds, look at the account and its settings. A client can complete TLS while the provider still rejects its credentials or the sender address it uses; that is not a handshake failure.
Questions
Which port should I use, 587 or 465?
The one your provider documents, with the mode it names. Both are equally secure when TLS is required and the certificate is validated (RFC 8314, section 3.3).
Why does my client time out on port 465?
A common cause is a client set to STARTTLS: it waits for a plain-text greeting while the server waits for a TLS handshake. Set the mode to implicit TLS, or use the port the provider assigns to STARTTLS.
Is STARTTLS insecure?
Not when TLS is required and the certificate is validated. It is weak when the client continues without TLS, because an attacker can remove the STARTTLS offer (RFC 3207, section 6), or when it accepts a certificate it cannot validate (RFC 8314, section 5).
Try it
See which mail servers a domain publishes with the MX lookup, or check an address with the free email checker.
Related
Related guides
- EHLO vs. HELO: what the SMTP greeting actually tells you
- MTA-STS and TLS reporting explained
- SMTP envelope sender vs. From header: which address goes where?
- Reverse DNS (PTR records) for mail servers
- SPF macros explained: what %{d}, %{o}, %{i} and %{ir} expand to
- All guides
Sources
- IETF: RFC 8314, Cleartext Considered Obsolete: Use of TLS for Email Submission and Access: sections 1 (scope and preference), 3 and 3.3 (implicit TLS for submission), 4 (providers), 5.1 to 5.4 (client rules).
- IETF: RFC 3207, SMTP Service Extension for Secure SMTP over TLS: sections 4 (the STARTTLS command), 4.2 (the reset), 6 (the stripped STARTTLS line).
- IETF: RFC 8461, SMTP MTA Strict Transport Security (MTA-STS): section 5 (policy modes).
How we wrote this: drafted by the email-validation.org team with the help of AI writing tools, from our product documentation and the sources linked in the text.