Skip to content
AdminKit

Does your mail server actually enforce STARTTLS?

STARTTLS lets two mail servers upgrade a plaintext SMTP connection to an encrypted one, but by default that upgrade is opportunistic, not mandatory — if an attacker sitting on the network path strips out the STARTTLS offer, most mail servers will simply fall back to sending the message in plaintext. AdminKit explains the gap and how MTA-STS closes it.

By AdminKit team, Netbase JSC · Updated

Key takeaways

  • STARTTLS upgrades an SMTP connection to TLS only if the receiving server offers it and the sender takes it up. Anything said before the upgrade travels in plaintext and can be changed.
  • RFC 3207 itself describes the attack: delete the server’s 250 STARTTLS line and the sender never tries TLS. The usual sender behaviour is to deliver anyway, in plaintext.
  • The fix has to come from outside the live connection: MTA-STS (a policy fetched over HTTPS) or DANE (a DNSSEC-signed TLSA record). Both tell senders to refuse delivery rather than fall back.
  • Your MX hosts shouldn’t refuse mail without TLS; RFC 3207 forbids that for publicly listed servers. Ask senders to enforce instead, by publishing a policy.
  • AdminKit’s MTA-STS and TLS-RPT checks read your published policy. Testing what your server offers on port 25 needs a STARTTLS-aware client, such as openssl s_client -starttls smtp.

How does STARTTLS work?

RFC 3207 defines STARTTLS as an SMTP extension: a receiving mail server advertises support for it in its response to the client’s EHLO greeting, and a sending server that also supports it can issue the STARTTLS command to upgrade the connection to TLS before any message data is transmitted. This solved a real deployment problem when it was introduced — mail servers across the internet could start encrypting connections to each other incrementally, without every server needing to support encryption on day one, because an unencrypted fallback kept mail flowing between servers that hadn’t upgraded yet.

The exchange looks like this. The transcript is illustrative, modelled on the example in RFC 3207 §5 with documentation names:

S: 220 mx1.example.com ESMTP
C: EHLO sender.example.net
S: 250-mx1.example.com
S: 250-8BITMIME
S: 250-STARTTLS
S: 250 SIZE 35882577
C: STARTTLS
S: 220 Ready to start TLS
   ... TLS handshake: certificate, protocol version, cipher ...
C: EHLO sender.example.net
S: 250-mx1.example.com
S: 250 SIZE 35882577

Note the second EHLO. RFC 3207 says that once the handshake completes, both sides “MUST discard any knowledge obtained prior to the start of the TLS handshake”, because everything said before it was in the clear and may have been modified. The client asks again over the encrypted channel. If the server can’t start TLS right now it replies 454 TLS not available due to temporary reason, and the client decides what to do next.

Why is the upgrade opportunistic?

That same incremental-adoption design is exactly what makes STARTTLS weaker than it looks today. Because the fallback to plaintext is the expected, standards-compliant behavior when TLS can’t be negotiated, a sending server has no built-in way to distinguish “the recipient genuinely doesn’t support TLS” from “an attacker on the network path just stripped out the STARTTLS offer to force plaintext.” Both look identical from the sending server’s point of view, and in both cases, the default behavior is to send the message anyway. M3AAWG’s TLS for Mail baseline recommendations describe this same gap from an operator’s perspective, recommending opportunistic TLS on every mail server as a minimum while pointing operators toward MTA-STS and DANE/TLSA for the enforced delivery this guide covers next.

The receiving side is deliberately kept lenient too. RFC 3207 says “a publicly-referenced SMTP server MUST NOT require use of the STARTTLS extension in order to deliver mail locally”, where publicly referenced means a server on port 25 listed in a domain’s MX records. If your MX hosts refused plaintext, any sender without TLS would simply fail to reach you. M3AAWG adds two limits worth knowing. TLS protects one hop at a time, so a message is only as protected as the weakest hop on its path. And only TLS 1.2 and 1.3 should be enabled, in line with RFC 8996.

What is a STARTTLS stripping attack?

This downgrade technique doesn’t require breaking TLS’s cryptography at all — it targets the negotiation that happens before encryption starts. An attacker with a position on the network path (a compromised router, a rogue access point, or access to transit infrastructure) can intercept the plaintext portion of the SMTP conversation and simply delete or corrupt the server’s STARTTLS announcement before it reaches the sending server. The sending server, seeing no STARTTLS support advertised, proceeds with a normal plaintext delivery — and because nothing about the resulting connection looks like an error, neither mail server necessarily logs anything unusual.

RFC 3207 §6 names this attack in plain words: “A man-in-the-middle attack can be launched by deleting the ‘250 STARTTLS’ response from the server.” From the sender’s side, the stripped greeting is indistinguishable from a server that never offered TLS (illustrative):

S: 220 mx1.example.com ESMTP
C: EHLO sender.example.net
S: 250-mx1.example.com
S: 250-8BITMIME
S: 250 SIZE 35882577          <- the STARTTLS line was removed in transit
C: MAIL FROM:<alice@example.net>
   ... message sent in plaintext ...

The same section says clients and servers “MUST be able to be configured to require successful TLS negotiation” for selected hosts. That is a per-server setting, though. A sender has no way to know which of the millions of domains it delivers to expect TLS unless those domains publish it somewhere the attacker can’t edit.

How does mandatory TLS stop the downgrade?

The practical fix is a receiving domain publishing a policy that tells senders, in advance and out-of-band, “don’t fall back to plaintext for us, ever.” MTA-STS, defined in RFC 8461 (also tracked in the IETF Datatracker), does exactly that: a domain publishes a policy file over HTTPS (discovered via a DNS TXT record) declaring that mail to it must be delivered over TLS with a certificate the sender can validate. Because a sending server fetches this policy ahead of time rather than relying on what the live connection claims to support, an attacker stripping the STARTTLS offer in real time can no longer force a silent downgrade — the sending server already knows, independently, that plaintext delivery to this domain isn’t acceptable, and will refuse to deliver rather than fall back. DANE/TLSA solves a related problem a different way, using a DNSSEC-signed DNS record to pin exactly which certificate a mail server should present, instead of a web-hosted policy file. SMTP REQUIRETLS (RFC 8689) takes a third approach, letting an individual sender flag one outgoing message as requiring TLS end-to-end instead of relying on either the recipient domain’s standing policy or a locally-fetched certificate pin.

An MTA-STS deployment is two pieces: a TXT record that announces the policy and changes its id whenever the policy changes, and a policy file served at https://mta-sts.<domain>/.well-known/mta-sts.txt. The values below follow the examples in RFC 8461:

; DNS: announces that a policy exists
_mta-sts.example.com.  IN  TXT  "v=STSv1; id=20261110T000000;"

# https://mta-sts.example.com/.well-known/mta-sts.txt
version: STSv1
mode: enforce
mx: mail.example.com
mx: *.example.net
max_age: 604800

Under mode: enforce, RFC 8461 §5 says senders “MUST NOT deliver the message to hosts that fail MX matching or certificate validation or that do not support STARTTLS”. Under testing, they deliver as usual and only report failures, if the domain also publishes a TLS-RPT record. Senders treat an enforcement failure as temporary and retry, after checking DNS for an updated policy.

MTA-STS has one known gap. RFC 8461 §10.2 explains that an attacker who can block DNS can hide the policy from a sender that has never fetched it before. Once cached, the policy protects the domain for up to its max_age, which is why the RFC asks for values “as long as is practical”. DANE doesn’t have this weakness, because DNSSEC lets a sender confirm whether a record exists or not, but it needs DNSSEC signing on the domain.

How do the TLS-enforcement options compare?

  • Opportunistic TLS (plain STARTTLS) — encrypts when both sides support it, but delivers the message either way; an attacker who strips the STARTTLS offer forces a silent fallback to plaintext.
  • MTA-STS (RFC 8461) — a domain publishes a policy over HTTPS, discovered via a DNS TXT record, requiring TLS with a certificate the sender can validate; a supporting sender refuses to deliver in plaintext.
  • DANE/TLSA — pins the exact certificate a mail server should present using a DNSSEC-signed DNS record, instead of a web-hosted policy file.
  • SMTP REQUIRETLS (RFC 8689) — lets an individual sender flag one outgoing message as requiring TLS end-to-end, instead of relying on the recipient domain’s standing policy or a locally fetched certificate pin.
OptionWho decides TLS is requiredStops STARTTLS stripping?What you need
Opportunistic STARTTLSNobodyNoA certificate on the mail server
MTA-STSThe receiving domain, via HTTPS policyYes, once the policy is cachedHTTPS policy host, TXT record, publicly trusted certificate
DANE for SMTP (RFC 7672)The receiving domain, via DNSSECYesDNSSEC-signed zone and TLSA records
REQUIRETLSThe sender, per messageYes, for that messageSupport on every hop

How do you check what your domain has?

Most mail administrators assume STARTTLS is “handled” once it’s enabled, without checking whether it’s enforced or merely offered. The practical difference only shows up when something strips it — which is exactly the scenario a routine check won’t normally trigger on its own. The useful question to ask isn’t just “does my server support STARTTLS” (almost all modern mail servers do), but “does my domain also publish an MTA-STS policy that prevents a downgrade if STARTTLS is ever stripped in transit.”

  1. List your mail hosts with AdminKit’s MX lookup. Every host there needs STARTTLS and a certificate that matches its name. If you publish MTA-STS, every host must also match one of the policy’s mx lines.

  2. See what each host offers on port 25. AdminKit doesn’t run SMTP or STARTTLS tests. From a machine you control, OpenSSL’s s_client can do the SMTP exchange, start TLS and show the certificate and negotiated protocol:

    openssl s_client -starttls smtp -connect mail.example.com:25 -servername mail.example.com -brief </dev/null

    Look for a verification result of OK, a certificate name matching the host, and TLS 1.2 or 1.3.

  3. Check your domain’s MTA-STS policy with AdminKit’s MTA-STS check. It looks up the _mta-sts TXT record, fetches the policy file and reports the mode (enforce, testing or none), the mx entries and max_age, or that nothing is published. You can also see the raw _mta-sts TXT record, alongside your MX records, with AdminKit’s DNS lookup tool.

  4. Check the policy host’s certificate with AdminKit’s SSL/TLS check on mta-sts.<your domain>. RFC 8461 §3.3 requires that host to present a valid, unexpired certificate for that name, chaining to a trusted CA. The check also reports the negotiated TLS version and cipher suite. It makes a direct HTTPS handshake, so it tests the policy host, not your mail server’s STARTTLS.

  5. Make sure failures reach you with the TLS-RPT check, which shows whether a _smtp._tls record exists and where its reports go.

  6. If no MTA-STS policy exists yet, that’s the gap to close — publishing one moves your domain from “we hope senders keep using the encrypted path” to “senders who support MTA-STS are required to.” How to publish and test MTA-STS walks through the rollout from testing to enforce.

What you findWhat it meansNext step
No _mta-sts recordSenders fall back to plaintext if STARTTLS is strippedPublish a policy in testing mode, with TLS-RPT
Record exists, policy file can’t be fetchedSenders can’t apply the policyFix the HTTPS host and its certificate
mode: testingFailures are reported, not blockedRead TLS-RPT reports, then move to enforce
mode: enforce, an MX host missing from mx:Senders will refuse to deliver to that hostAdd the host to the policy and change the id

Do SPF, DKIM and DMARC protect mail in transit?

A domain can have SPF, DKIM, and DMARC fully configured and still have no protection against a STARTTLS downgrade, because authentication and transport encryption solve different problems — one verifies who sent a message and that it wasn’t altered after transit, the other protects the message while it’s in transit. Treat MTA-STS as the transport-layer complement to an already-solid authentication setup, not a replacement for it. A client authenticating directly to its own outbound mail server, rather than being verified after the fact via SPF/DKIM/DMARC, typically does so with SASL over the SMTP AUTH extension, which is itself expected to run only after STARTTLS has already encrypted the connection, not before. This STARTTLS/MTA-STS check is part of AdminKit’s email authentication cluster of SPF, DKIM and DMARC guides and tools.

Submission from your own users’ mail clients is the one place where requiring TLS is right. RFC 8314 asks mail clients to prefer implicit TLS, where the handshake starts as soon as the connection opens (port 465 for submission), over upgrading a plaintext connection with STARTTLS. M3AAWG’s baseline lists both port 465 with TLS and port 587 with STARTTLS for submission.

This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.

Frequently asked questions

What does STARTTLS actually do?

Defined in RFC 3207, STARTTLS is an SMTP extension that lets a mail server offer to upgrade an existing plaintext connection to an encrypted TLS connection before any message content is sent, rather than requiring a separate encrypted port from the start.

If STARTTLS encrypts the connection, what's the problem?

The upgrade is opportunistic by design — a sending server that doesn't see a STARTTLS offer, or whose attempt to negotiate one fails, will typically fall back to sending the message unencrypted rather than refuse delivery. An attacker positioned on the network path can exploit this by stripping the STARTTLS announcement from the connection, a classic downgrade attack, leaving the message to go out in plaintext with neither party necessarily noticing.

What's the difference between opportunistic and mandatory TLS for mail?

Opportunistic TLS encrypts the connection when both sides support it, but delivers the message either way. Mandatory TLS refuses to deliver the message at all if an encrypted connection to a trusted certificate can't be established — a much stronger guarantee, but one that depends on the sending server having a defined policy telling it mandatory TLS is expected for this particular recipient domain.

How does MTA-STS fix this?

MTA-STS (RFC 8461) lets a domain publish a policy, via DNS and HTTPS, declaring that it only accepts mail over TLS with a trusted certificate — so a sending server that supports MTA-STS will refuse to deliver mail in plaintext to that domain even if an attacker strips the STARTTLS offer, because the policy was fetched out-of-band ahead of time, not negotiated live in the vulnerable connection itself.

Does fixing SPF/DKIM/DMARC also fix the STARTTLS problem?

No — SPF, DKIM and DMARC authenticate who a message claims to be from and whether it was tampered with in transit by the time it arrives, but they don't guarantee the transport connection carrying it was encrypted. A message can pass every authentication check and still have crossed the network in plaintext if STARTTLS wasn't enforced.

How do I check my own mail server's TLS setup?

Start with AdminKit's [MTA-STS check](/tools/mta-sts-check/), which reads your domain's live policy and reports whether it is enforce, testing or none, and the [TLS-RPT check](/tools/tls-rpt-check/), which shows where failure reports go. To see what your mail server itself offers on port 25, use `openssl s_client -starttls smtp -connect <your MX host>:25` from a machine you control. AdminKit's [SSL/TLS check](/tools/ssl-check/) makes a direct TLS handshake to a hostname (HTTPS, port 443), so it doesn't speak SMTP or STARTTLS; it is the right tool for the certificate on your mta-sts. policy host, which senders fetch over HTTPS.

Should my mail server refuse mail from senders that don't use STARTTLS?

Not on the server your MX records point to. RFC 3207 says a publicly-referenced SMTP server (one listed in your MX records, on port 25) must not require STARTTLS in order to deliver mail locally, so that senders without TLS can still reach you. Enforcement belongs on the sending side, which is what MTA-STS and DANE ask senders to do. Mail submission from your own users is different: there you can and should require TLS.

Want AdminKit to watch this for you?

Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.

Huy Nguyen (David), Founder and CEO of Netbase JSC

Talk to an expert

Huy Nguyen (David), Founder & CEO, Netbase JSC

Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.