Setting up MTA-STS the right way on your domain

To set up MTA-STS you publish three things that work together: a small policy file, a DNS TXT record at _mta-sts.yourdomain, and that same policy served over HTTPS at a fixed well-known URL. Get all three right and other mail servers will refuse to deliver to you over an unencrypted or tampered connection.

How to fix6 min read

MTA-STS (Mail Transfer Agent Strict Transport Security) is the one email record most guides skip. SPF, DKIM and DMARC get all the attention, but MTA-STS is the piece that stops inbound mail being silently downgraded to plain text in transit. If our free scan flagged it as missing, this page walks you through publishing it correctly, including the mistake that quietly breaks it.

This is a passive external scan talking, so a quick honesty note up front: our check confirms your policy record and file exist and are well-formed. It does not watch your mail server complete a real TLS handshake, and it has nothing to do with DKIM.

What MTA-STS is actually for

When one mail server delivers to another, it normally tries STARTTLS to encrypt the connection. The weakness is that STARTTLS is opportunistic: if an attacker sitting between the two servers strips the TLS offer, the sending server quietly falls back to plain text and delivers your mail unencrypted. Nobody gets an error. Nobody notices.

MTA-STS closes that gap. It lets you publish a policy that says: for this domain, mail must be delivered over TLS to these named mail hosts, and the certificate must be valid. A sending server that supports MTA-STS reads your policy, and if TLS cannot be established properly it refuses to deliver rather than downgrading. In short, it forces inbound mail over TLS so the connection cannot be silently downgraded. A working setup is always three coordinated parts, and missing any one makes supporting servers ignore the policy entirely.

  • A policy file: a short plain-text file listing your mail hosts and the enforcement mode.
  • A DNS TXT record at _mta-sts.yourdomain that announces a policy exists and carries a version id.
  • A HTTPS host at mta-sts.yourdomain that serves the policy file at a fixed well-known path over a valid certificate.

Step 1: write the policy file

Create a plain-text file with these lines, listing the mail servers that receive your domain's mail (check your MX records to confirm the hostnames):

version: STSv1 / mode: enforce / mx: mail.yourdomain.co.uk / mx: *.yourdomain.co.uk / max_age: 604800

Start with mode: testing while you confirm everything resolves, then switch to mode: enforce once you are confident. In testing mode, senders honour the policy but report failures instead of blocking, which is a safe way to catch a wrong MX entry. The max_age value, in seconds, is how long senders cache the policy; 604800 is one week, a sensible starting point.

Step 2: publish the _mta-sts DNS record

Add a DNS TXT record so senders know a policy exists. The host is _mta-sts.yourdomain.co.uk and the value looks like this: v=STSv1; id=20260707120000

The id is any string you choose, but it must change every time you edit the policy file. A common convention is a timestamp. This id is how sending servers detect that your policy has been updated: if you change the file but leave the id the same, cached copies stay stale and your change never takes effect.

Step 3: serve the policy over HTTPS at the well-known URL

The policy file must be reachable at exactly this address, with the hostname and path spelled precisely: https://mta-sts.yourdomain.co.uk/.well-known/mta-sts.txt

That means creating an mta-sts subdomain, pointing it at a web server or host, and placing the file under a .well-known directory. The subdomain needs a valid TLS certificate that matches its name, because senders will reject a policy fetched over a certificate they cannot trust. Serve the file as plain text (content type text/plain) and you are done.

Free, instant, no account

See your site's security grade in seconds.

Free, instant, and no account needed to see your grade.

Scan my site free

Plain-English A to E grade in about 10 seconds. No account needed to see it.

The common mistake: policy served over plain HTTP

The single most frequent error is serving the policy over http:// instead of https://, or over HTTPS with a certificate that does not cover the mta-sts subdomain. The specification requires the policy to be fetched over HTTPS with a valid, matching certificate, precisely because the whole point is to resist tampering. A policy delivered over plain HTTP could be altered in transit, so compliant senders ignore it outright.

Two related slips catch people out: forgetting to issue or extend a certificate for the mta-sts subdomain, and editing the policy file without bumping the id in the DNS record so nothing refreshes. If your scan still shows MTA-STS missing after publishing, check the certificate on the mta-sts host and confirm the well-known URL loads over HTTPS in a browser.

What our free scan checks, and what it does not

Our scan looks up the _mta-sts DNS record and fetches the policy file, then confirms both exist and are well-formed: the version, mode, mx entries and max_age are present and readable. That tells you the policy is published correctly and discoverable, which is the part most people get wrong.

Be clear on the limits, though. The scan does not open an SMTP session with your mail server or observe a live TLS handshake, so it cannot prove your actual mail delivery is encrypted end to end; it confirms the policy you have published. It also does not touch DKIM. For DKIM you sign outgoing mail and publish a separate key record, which is a different job from MTA-STS entirely.

MTA-STS forces inbound mail over TLS so it cannot be silently downgraded. Publish all three parts (the policy file, the _mta-sts TXT record, and the policy served over HTTPS at the well-known URL), and never serve the policy over plain HTTP.

Common questions

What is the difference between MTA-STS and DMARC?
They solve different problems. DMARC tells receiving servers what to do with mail that fails SPF or DKIM checks, protecting against spoofing of your domain. MTA-STS protects the connection itself, forcing inbound mail to arrive over encrypted TLS so it cannot be intercepted or downgraded in transit. You want both; neither replaces the other.
Do I need MTA-STS if I already have SPF, DKIM and DMARC?
Yes, because those three do not encrypt the transport. SPF, DKIM and DMARC verify who sent a message and whether it was tampered with, but they do not stop the connection being downgraded to plain text. MTA-STS is the piece that enforces encryption on the delivery itself, so it complements the others rather than duplicating them.
Why does my policy still fail after I published everything?
The usual causes are the policy being served over plain HTTP instead of HTTPS, a missing or mismatched TLS certificate on the mta-sts subdomain, or editing the policy file without changing the id in the DNS TXT record so cached copies stay stale. Load the well-known URL in a browser over HTTPS to confirm it resolves cleanly.
Should I start MTA-STS in testing or enforce mode?
Start in testing mode. In testing, sending servers honour your policy but report failures instead of blocking mail, so a wrong MX entry or certificate issue surfaces without bouncing legitimate mail. Once you have confirmed everything resolves and reports cleanly, switch the policy file to enforce mode and bump the id in your DNS record.
Does the free scan check that my mail is actually encrypted?
No. The scan confirms your _mta-sts DNS record and policy file exist and are well-formed, which proves the policy is published and discoverable. It does not open an SMTP session or observe a live TLS handshake with your mail server, so it verifies the policy rather than the real-time delivery. It also does not check DKIM.

How safe is your website?

A free A to E grade in about 10 seconds. No account needed.

Check my site