Privacy and Security

MTA-STS and TLS-RPT: Enforcing Encrypted Inbound Mail Safely

Why SMTP encryption can be stripped, how MTA-STS and TLS reporting fix it, and a step-by-step rollout from testing to enforce without losing mail.

Saizul Amin
Saizul Amin3 Nov 2026 · 3 min read
MTA-STS and TLS-RPT: Enforcing Encrypted Inbound Mail Safely

The weak spot in mail encryption

When one mail server delivers to another, it asks whether the receiver supports STARTTLS and, if so, upgrades the connection to TLS. If not, it sends in clear text. That fallback keeps mail flowing between old systems, but it also means an attacker who can tamper with traffic can remove the STARTTLS offer, or present any certificate, and most senders will carry on regardless. For a long time there was no way for a domain to say "only deliver to me over properly verified TLS".

How MTA-STS works

MTA-STS, defined in RFC 8461, gives domains that switch. You publish a small policy file at https://mta-sts.yourdomain/.well-known/mta-sts.txt. It names a mode, the MX hosts that may receive your mail and how long senders should remember the policy. A TXT record at _mta-sts.yourdomain carries an id that changes whenever the policy changes. A supporting sender, such as Gmail or Microsoft 365, fetches the policy over https, caches it, and in enforce mode refuses to deliver unless the receiving server presents a valid certificate for one of the listed hosts. Because the policy is fetched over https with normal web certificates, MTA-STS does not need DNSSEC, which makes it easier to deploy than DANE.

TLS-RPT, the feedback loop

Turning on enforcement blind would be risky. TLS reporting, RFC 8460, adds a TXT record at _smtp._tls.yourdomain with a rua address. Participating senders then email a daily JSON report listing how many TLS sessions to your servers succeeded and failed, and why. Typical failure types are certificate-host-mismatch, expired or untrusted certificates, missing STARTTLS, and problems fetching or parsing the policy itself.

Building the pieces

The MTA-STS and TLS-RPT Policy Builder writes everything you need. Enter the domain, choose testing, enforce or none, pick a max_age and list your MX hosts, as exact names or as wildcards such as *.mail.protection.outlook.com, which match exactly one extra label. A tester tells you whether a given host name would be accepted, which avoids the classic mistake of forgetting one MX. The builder outputs the policy file with the CRLF line endings the RFC specifies, the _mta-sts and _smtp._tls records, and hosting snippets for Nginx, a Cloudflare Worker or a static site. The policy id refreshes automatically when you change the mode or max_age, because senders only refetch when the id changes.

The check tab validates what you already publish: paste the live policy file and the TXT values, and every problem is listed. The reports tab opens the JSON reports, including gzipped attachments, totals successful and failed sessions, explains each failure type and lists sending IPs and MX hosts.

A rollout that does not lose mail

Start with TLS-RPT alone so reports begin arriving. Next, publish the policy in testing mode with a short max_age, a day to a week. Make sure the mta-sts host name has its own valid certificate; a missing one is the most common setup error. Read reports for two to four weeks and fix every mismatch, often a secondary MX whose certificate does not include its name. When failures are zero or understood, switch to enforce, raise max_age to weeks or months and change the id. Before changing MX providers later, add the new hosts to the policy first and wait out the old max_age. To retire the policy, publish mode none with a new id rather than deleting the file.

Where the tool stops

Browsers cannot query DNS or open SMTP connections, so the builder cannot check your live records or test your mail servers' certificates directly. Paste what you publish into the check tab, and use a command-line test or an online SMTP checker for the servers themselves. Remember too that MTA-STS protects mail coming to your domain; the security of mail you send depends on the recipients' own policies.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages