← blog · November 26, 2026

Enforcing Transport Encryption in SMTP: MTA-STS, DANE and TLS-RPT, Which and How

Server-to-server email encryption is opportunistic by default, and an active attacker can strip STARTTLS with ease. How MTA-STS and DANE close the gap, which one to start with, a rollout plan and the pitfalls that stop mail delivery.

Encryption between SMTP servers is opportunistic in most deployments. The sending server connects, looks for STARTTLS in the EHLO response, upgrades if it is there and carries on in plaintext if it is not. It usually does not validate the certificate either. Expired, self-signed or wrong-name certificates are accepted, because the alternative is not delivering the mail at all. That design defeats passive eavesdropping and does nothing against an active attacker. Stripping the STARTTLS line from the response or presenting a forged certificate is enough, and neither side notices.

There are two standard ways to close this gap, MTA-STS and DANE, plus a reporting standard, TLS-RPT, that you want regardless. They are not competitors, but which one you start with and which one you can skip depends on what your infrastructure can actually sustain.

What the sender needs to know

The core problem: before connecting, the sender must learn that the recipient domain supports TLS and which certificate to expect, and it must learn this from a source the attacker cannot tamper with. With opportunistic TLS, that information arrives inside the connection the attacker controls.

MTA-STS publishes the information over HTTPS and anchors trust in the web PKI. DANE puts it in DNS and anchors trust in DNSSEC. Every practical difference follows from that.

MTA-STS: a policy announced over HTTPS

MTA-STS has two parts. A TXT record announcing that a policy exists and what version it is:

_mta-sts.example.com.  IN TXT  "v=STSv1; id=20261126T0900;"

And a plaintext policy file served over HTTPS with a valid certificate at a fixed location, https://mta-sts.example.com/.well-known/mta-sts.txt:

version: STSv1
mode: testing
mx: mx1.example.com
mx: mx2.example.com
max_age: 86400

A sender that sees the TXT record fetches the file, caches it for max_age seconds and, during that time, refuses to deliver to any server that does not match an mx line or cannot present a valid certificate. In testing mode failures are only reported. In enforce mode delivery is blocked. Change id on every policy change, because senders only refetch the file when that value changes.

The weak spot is first contact. A sender that has never seen your policy can be kept unaware of it if an attacker tampers with DNS on that first lookup. Caching limits the exposure to first contact and cache expiry. The payoff is large: MTA-STS needs no DNSSEC. A web server and an automatically renewed certificate are enough.

DANE: keys pinned through DNSSEC

DANE publishes the MX server's certificate or key directly in DNS as a TLSA record:

_25._tcp.mx1.example.com.  IN TLSA  3 1 1 <sha256-digest>

3 1 1 means: match the end-entity certificate (DANE-EE), using its public key (SPKI), by SHA-256 digest. This is the recommended form for SMTP. In this mode the issuing CA does not matter, nor does expiry. What matters is that the presented key matches the digest in DNS. Generate it from the certificate:

openssl x509 -in cert.pem -noout -pubkey \
  | openssl pkey -pubin -outform DER \
  | openssl dgst -sha256

DANE has no first-contact problem because a DNSSEC-signed answer cannot be altered in transit. The cost is significant: the zone holding your MX records and the zone holding the MX host names must both be signed, and the sender's resolver must validate. Common MTAs such as Postfix support DANE natively (smtp_tls_security_level = dane), while MTA-STS on Postfix requires a separate policy service.

TLS-RPT: stop flying blind

Whatever you choose, publish the TLS-RPT record first:

_smtp._tls.example.com.  IN TXT  "v=TLSRPTv1; rua=mailto:[email protected]"

Senders that support it send a daily JSON report, as a compressed attachment, listing how many sessions to you succeeded and why the others failed: certificate name mismatch, STARTTLS not offered, TLSA validation failure. You will want a parser or an aggregation service, but even a few days of reading them by hand tells you which MX is presenting the wrong certificate.

Seeing clean reports before switching to enforce is not optional.

Which one

If I have to pick a side: everyone should deploy MTA-STS and TLS-RPT. Add DANE if you already run DNSSEC, can automate key rollover, and monitor both. The two can be published together and both standards expect this; senders that do DANE use DANE, the rest use MTA-STS.

DANE is technically stronger. It has no first-contact gap and no dependency on the CA ecosystem. But DNSSEC carries real operational weight, and DANE failures are harsh. A broken signature or a stale TLSA record means every validating sender stops delivering to you. MTA-STS mistakes also stop delivery, but their cause is usually more visible and quicker to fix.

Rolling it out

  1. Publish the TLS-RPT record and read reports for a week.
  2. Check that every MX presents a publicly trusted certificate matching its MX name: openssl s_client -connect mx1.example.com:25 -starttls smtp -servername mx1.example.com
  3. Publish the MTA-STS policy with mode: testing and a short max_age of one day.
  4. Once reports are clean, switch to mode: enforce, raise max_age to one or two weeks, and change id.
  5. If you add DANE, verify your DNSSEC chain first (dig +dnssec), then publish TLSA records and keep watching reports.

Pitfalls

The policy is forgotten during an MX change. When you switch mail providers and the new MX names are not in the policy, cached enforce policies block delivery to the new servers. Add the new names, change id, wait for old caches to expire, then change MX records. Keep the old names listed until the migration is done.

The mx wildcard matches one label. mx: *.example.com covers mx1.example.com but not a.mx.example.com.

The policy host's certificate matters too. If the certificate on mta-sts is invalid, senders cannot fetch the policy. Nothing looks wrong while cached copies last; when they expire, protection silently disappears. Put that host in your certificate monitoring. The policy also cannot be served through a redirect, since senders do not follow HTTP redirects.

DANE plus ACME rotates the key under you. A 3 1 1 record pins the key. If each renewal generates a new key, which is the default in many ACME clients, the TLSA record breaks at renewal. Either reuse the key on renewal (for example Certbot's --reuse-key) or publish the new key's digest before renewal and keep both records for a while. TLSA records have a TTL too.

A DNSSEC rollover mistake stops all inbound mail. With DANE, a DNSSEC failure is no longer just a website problem. If your KSK and ZSK rollovers are not automated, do not deploy DANE.

When not to bother

If a hosting provider runs your domain's mail end to end, the MX servers and their certificates are not yours. You still publish the MTA-STS policy, listing the MX names your provider documents. If the provider changes those names without notice, enforce is risky and staying in testing while watching reports is the better call. If your domain never receives mail, what you need is a null MX record and a strict SPF and DMARC policy, not MTA-STS.

[ ← Back to burak.sh ]