MTA-STS. Enforce TLS for Inbound Mail
SMTP encryption is opportunistic by default, attackers can strip it. MTA-STS lets you demand TLS for mail sent to your domain.
mta-sts.yourdomain.com. Start in testing mode with TLS-RPT enabled, then flip to enforce.What is MTA-STS?
When another mail server delivers email to your domain, it connects to your MX host and asks "do you support encryption?" via the STARTTLS command. If the answer is yes, the connection upgrades to TLS. The problem: that negotiation happens in plaintext. An attacker sitting on the path can simply delete the STARTTLS offer, and the sending server, designed in an era when any delivery beat no delivery, shrugs and sends your customers' password resets and invoices unencrypted.
MTA-STS (Mail Transfer Agent Strict Transport Security, RFC 8461) is your way of saying: don't fall back. You publish a policy declaring that mail to your domain must arrive over TLS 1.2+, with a valid certificate, to a specific list of MX hosts. Compliant senders, which includes Gmail, Outlook, and Yahoo, cache that policy and refuse to deliver if the requirements can't be met.
Why it matters
- It closes a real attack: STARTTLS stripping is trivial for anyone on-path (hostile networks, rogue Wi-Fi, compromised routers) and invisible to both sender and recipient.
- Inbound mail often carries your most sensitive data: password resets, legal documents, customer PII. Opportunistic encryption protects none of it against an active attacker.
- It's a maturity signal: security questionnaires and email-security scanners increasingly check for it. Gmail publishes an enforce-mode policy on gmail.com itself.
How to check it
# 1. Is the policy flag published?
dig +short txt _mta-sts.example.com
# 2. Does the policy file resolve over HTTPS?
curl https://mta-sts.example.com/.well-known/mta-sts.txtBoth must work. A TXT record with no reachable policy file is a no-op; a policy file with no TXT record is never discovered.
Setting it up, step by step
- Create the policy file and serve it at
https://mta-sts.example.com/.well-known/mta-sts.txtwith a valid certificate formta-sts.example.com(Cloudflare Pages, GitHub Pages, or a tiny static bucket all work):
Theversion: STSv1 mode: testing mx: mx1.example.com mx: mx2.example.com max_age: 86400mxlines must match your actual MX hostnames (wildcards like*.google.comare allowed). For Google Workspace usemx: *.google.com; for Microsoft 365 usemx: *.mail.protection.outlook.com. - Publish the discovery TXT record:
The_mta-sts.example.com. TXT "v=STSv1; id=20260610"idis an opaque change marker, a datestamp is the convention. Bump it every time you edit the policy file. - Publish TLS-RPT alongside it (see our TLS-RPT guide) so senders tell you when delivery fails against your policy. Don't enforce blind.
- Watch reports for 2–4 weeks in
testingmode. Failures here cost you nothing, mail still flows, but they tell you about cert mismatches or forgotten MX hosts. - Flip to
mode: enforce, bump theid, and raisemax_age(604800, one week, is a sensible production value).
mta-sts.example.com must be valid too. An expired cert on either side under mode: enforce means compliant senders queue and eventually bounce your inbound mail. This is why you monitor before and after enforcing.Common mistakes
- Forgetting to bump
idafter editing the policy. Senders keep using the cached old policy for up tomax_ageseconds. - MX list drift. You migrate mail providers, update MX records, and forget the policy file. Under enforce mode, the new MX hosts aren't on the list and inbound mail stalls.
- Serving the policy with a redirect or wrong content type. The file must be served directly, over HTTPS, as plain text. Some senders won't follow redirects.
- Self-signed or mismatched certs on MX hosts. Fine under opportunistic TLS, fatal under enforce.
- Jumping straight to enforce without TLS-RPT. You'll have no idea what broke or for whom.
Monitoring MTA-STS going forward
MTA-STS has more moving parts than most DNS-only standards: a TXT record, an HTTPS endpoint, a certificate on that endpoint, certificates on every MX, and a policy file that must stay in sync with your actual MX records. Any one of them can rot independently.
DomainsDoc checks the whole chain continuously: the TXT record, the policy file's reachability and syntax, whether the listed MX hosts match your live MX records, and the certificates involved. The moment something drifts, you get one alert instead of a slow trickle of mysteriously delayed mail. Add your domain to start, and see pricing for plans.
Frequently asked questions
What is MTA-STS in plain English?
Why do I need both a DNS record and an HTTPS file?
What is the difference between mode: testing and mode: enforce?
Do I need to update the DNS record when I change the policy?
Does Google Workspace or Microsoft 365 support MTA-STS?
How does MTA-STS relate to DANE?
Continuous SPF, DKIM, DMARC, blacklist, SSL, and uptime checks. Alerts the moment something breaks.