MTA-STS & TLS-RPT: Enforcing In-Transit SMTP Encryption
Opportunistic STARTTLS is a lie; MTA-STS fixes it by making inbound TLS mandatory, not optional.

That little lock icon in your email client? It’s a comforting lie. It tells you the final hop of your email’s journey—from the mail server to your laptop—was encrypted. It says nothing about the server-to-server hops that came before. For decades, the backbone of email, SMTP, has treated encryption as a nice-to-have, not a necessity. The `STARTTLS` command, which initiates encryption between mail servers, is entirely opportunistic. An active network attacker can simply intercept that command, force a downgrade, and read all your inbound mail in plaintext. No warnings, no errors. Just silence.
This is not a theoretical vulnerability. It’s a fundamental design flaw of internet email. While standards like SPF, DKIM, and DMARC protect against sender forgery, they do nothing to protect the confidentiality of email content in transit. A well-placed Man-in-the-Middle (MITM) attack between legitimate mail servers can expose everything from financial reports to password resets.
MTA-STS, defined in RFC 8461, finally addresses this. It’s a mechanism for your domain to declare, “I only accept email over an authenticated, encrypted TLS connection.” It moves SMTP from a world of “let’s try to encrypt” to “we must encrypt.” Paired with TLS-RPT for failure reporting, it's a powerful tandem you can deploy in an afternoon.
The STARTTLS Stripping Attack You're Vulnerable To
Let’s be precise about the threat model. Imagine a vendor is sending your company a critical contract renewal. Their mail server (MTA) performs a DNS lookup for your domain’s MX records and opens a connection to your mail server. It sends an `EHLO` greeting, and your server responds with its capabilities, including the `250-STARTTLS` verb, advertising its ability to upgrade the connection to TLS.
An attacker sitting on the network path between those two servers—at an internet exchange, a compromised ISP, or a nation-state gateway—can intercept this traffic. The attacker simply modifies the server's response, removing the `250-STARTTLS` line. The sending MTA, following the SMTP protocol to the letter, sees that your server doesn't support TLS. It shrugs and proceeds to send the entire email, contract and all, over the unencrypted plaintext connection. The attacker gets a full copy. Neither the sender nor the recipient is ever alerted to the downgrade.
MTA-STS (Mail Transfer Agent Strict Transport Security) foils this by providing an out-of-band policy. Before a sending server even connects, it checks for an MTA-STS policy for your domain. That policy, fetched over HTTPS, tells the sender the expected TLS certificate details and that encryption is mandatory. If the sender then tries to connect and `STARTTLS` is missing, it knows something is wrong. Instead of downgrading, it aborts the connection and treats it as a transient delivery failure, queuing the email to try again later. The attack is stopped dead.
Policy Deployment: A Tale of Two DNS Records
Implementing MTA-STS involves creating two things: a DNS record that points to a policy file, and the policy file itself, hosted on a web server. This separation is intentional; DNS is slow to update, while web files can be changed quickly.
The DNS Pointer Record
First, you create a TXT record at the `_mta-sts` subdomain for your domain. This record doesn't contain the policy itself, but acts as a signal to sending MTAs that you have one. It contains a version tag (`v=STSv1`) and a policy ID. This ID can be any string, but using a timestamp like `2024052101` is a common convention. Every time you update your policy file, you must also update this ID to signal to senders that they need to refetch it.
A typical `_mta-sts.yourdomain.com` record looks like this: `v=STSv1; id=2024052101;`. That's it. It’s a simple advertisement.
The Web-Hosted Policy File
The DNS record points implicitly to a specific URL: `https://mta-sts.yourdomain.com/.well-known/mta-sts.txt`. You must host a plaintext file at this exact location. Note the `https://`—the policy itself must be served over a secure connection to prevent an attacker from tampering with it. This requires a valid TLS certificate for the `mta-sts.yourdomain.com` hostname.
version: STSv1
mode: testing
max_age: 86400
mx: mx1.yourdomain.com
mx: mx2.yourdomain.com
Let’s break down the directives. `version` is self-explanatory. `mode` is the most critical setting; it can be `testing`, `enforce`, or `none`. Always, always start with `testing`. In this mode, senders will still deliver mail if the policy fails, but they'll send you a TLS-RPT report (more on that next). `enforce` means failed connections are blocked. `none` disables the policy entirely. `max_age` is the lifetime of the policy in seconds (86400 is one day); it tells senders how long to cache it. Finally, the `mx` patterns specify the authorized hostnames for your mail servers. These must match the names on your MX servers' TLS certificates. Wildcards like `*.mail.yourdomain.com` are permitted.
Getting Feedback with TLS-RPT
Flying blind is a recipe for disaster. Switching your MTA-STS policy to `enforce` without knowing if it's working correctly could cause you to silently drop legitimate email. This is where TLS Reporting (TLS-RPT), defined in RFC 8460, becomes essential. It’s the feedback mechanism for MTA-STS, much like RUA/RUF reports are for DMARC.
To enable it, you create another TXT record, this time at `_smtp._tls.yourdomain.com`. The format is simple: `v=TLSRPTv1; rua=mailto:tls-reports@yourdomain.com`. The `rua` tag specifies the URI (almost always a `mailto:` address) where participating senders should send their aggregate reports.
These reports are JSON files, usually compressed, that arrive daily. They contain statistics on connection attempts to your domain from that sender. You'll see which of your MX hosts were contacted, how many connections succeeded, and details on any failures. A failure report will include the reason, such as `starttls-not-supported` (the classic downgrade attack) or `certificate-mismatched` (a configuration error on your end).
These reports are your ground truth. While in `testing` mode, monitor them closely. Are major partners like Google and Microsoft successfully negotiating TLS? Do you see unexpected failures? These reports will tell you exactly what would have been blocked if your policy were set to `enforce`. Don't even consider switching modes until your TLS-RPT reports are clean and only show successes.
Triaging Common Deployment Errors
The theory is simple, but the real world is messy. Mail infrastructure has layers of load balancers, forwarders, and legacy servers that can complicate an MTA-STS deployment. Most errors boil down to a mismatch between what your policy promises and what your server actually presents.
Certificate Hostname Mismatches
This is the number one cause of failure. The `mx` values in your `mta-sts.txt` policy are not your MX record hostnames. They are the hostnames that must appear in the Subject Alternative Name (SAN) or Common Name (CN) of the TLS certificate presented by your mail server. For example, if your MX record is `mx.yourdomain.com` which is a CNAME to `server123.provider.net`, the TLS certificate on `server123.provider.net` must be valid for `mx.yourdomain.com`. If the server just presents a cert for `server123.provider.net`, MTA-STS validation will fail. Your policy must list the name the server proves it owns via its cert.
Policy Caching and `max_age` Agony
Senders cache your policy for the duration specified by `max_age`. If you set this to a high value like 30 days and then accidentally push a broken policy to `enforce` mode, you've just blocked a month's worth of email from anyone who cached it. Even if you fix it immediately, they won't check for a new policy until the old one expires.
Start with a low `max_age`, like 86400 (one day), while in `testing`. Once you are confident and have moved to `enforce`, you can gradually increase it to a week (`604800`) or more to reduce the load on your web server and protect against short-term DNS or web server outages. But remember to refresh the policy ID and file well before the old one expires.
Load Balancers and Mixed Environments
Complex environments often have issues. If your MX records point to a cloud load balancer that then distributes traffic to a pool of mail servers, every single one of those servers must present a certificate that matches an `mx` entry in your policy. If one server in the pool has an expired or mismatched cert, deliveries to it will fail. This can be infuriating to debug because the failures will be intermittent, depending on which backend server the sender's MTA happens to hit.
Is Anyone Actually Using This?
A security standard is only as good as its adoption. For MTA-STS, we need both senders to check policies and receivers to publish them. The good news is that we've reached critical mass on the sender side. Major providers like Google, Microsoft, and Yahoo all honor MTA-STS policies when sending email. This means that by publishing a policy for your domain, you're immediately hardening your inbound mail channel against downgrade attacks from a huge fraction of the internet.
Adoption on the receiving side is growing, but it’s far from universal. Many organizations still haven't implemented it. But this creates an opportunity for you to be ahead of the curve. Publishing a policy is a clear signal that you take transport layer security seriously.
It's important to understand what MTA-STS does not do. It does not protect outbound mail from your domain. It does not stop spam where attackers connect directly to your server's IP, bypassing your MX records. And it only works if the sender's MTA actually implements the MTA-STS specification. But it's not meant to be a panacea. It's a targeted control that perfectly solves a specific, dangerous problem: opportunistic downgrade attacks on the core SMTP pathways.
The takeaway
For years, we've layered authentication standards like DMARC on top of a foundation that allowed for trivial, silent content interception. MTA-STS finally rebuilds that foundation. It replaces a flimsy, opportunistic handshake with an enforced, authenticated TLS requirement, closing a security gap that has existed for decades.
Setting it up is not a massive project. You need two DNS records and a simple text file. By starting in `testing` mode and using TLS-RPT to validate your configuration, you can safely deploy it without risking mail flow. Once you're confident, switching to `enforce` upgrades your domain's email security posture from wishful thinking to a verifiable guarantee. Tools like MailSleuth.AI can help you monitor not just your own configuration but also see which of your critical partners have—or haven't—taken this crucial step.
We dissect phishing campaigns and email infrastructure so you don't have to.


