The problem: STARTTLS is only an offer
SMTP between mail servers is historically unencrypted. STARTTLS lets the sending server upgrade to TLS, but only if the receiving server offers it and both agree. If the handshake fails or the offer is missing, the sender continues in plain text. This is called opportunistic, and it means encryption happens as long as nobody interferes.
An attacker on the network path can exploit exactly that. They strip the STARTTLS offer from the server response and the sender falls back to plain text. Or they tamper with the DNS answer to the MX query and redirect mail to their own server with a valid certificate for their own domain. With classic STARTTLS, the sending server verifies neither the certificate name nor the origin of the MX record.
How MTA-STS works
MTA-STS (RFC 8461) lets the receiving domain publish a policy: these MX hosts are valid, they must offer TLS with a valid certificate, and this rule applies for the given time. Sending servers that support MTA-STS fetch the policy once, cache it and abort delivery if a later connection violates it. A downgrade to plain text is no longer possible.
The policy has two parts. A TXT record at _mta-sts.your-domain.com signals that a policy exists and carries an id that changes with every update. The policy itself is a text file served over HTTPS at mta-sts.your-domain.com/.well-known/mta-sts.txt. The certificate of that host must be valid and issued for the name mta-sts.your-domain.com, otherwise the policy is ignored.
_mta-sts.example.com. IN TXT "v=STSv1; id=20260911120000"
https://mta-sts.example.com/.well-known/mta-sts.txt
version: STSv1
mode: enforce
mx: mail1.example.com
mx: mail2.example.com
max_age: 604800The fields: mode is none, testing or enforce. mx lines name the permitted hosts; wildcards such as *.mail.protection.outlook.com are allowed for the leftmost label. max_age states in seconds how long senders may cache the policy; one to four weeks is common, one year is the maximum. The file must be served with Content-Type text/plain.
TLS-RPT: reports about failures
Without a feedback channel you do not know whether senders read your policy and whether connections fail. TLS-RPT (RFC 8460) is that channel: a TXT record at _smtp._tls.your-domain.com names an address to which supporting senders mail a daily JSON report. It lists how many connections succeeded and which ones were aborted with which error, for example an expired certificate or an MX host not in the policy.
Google, Microsoft and other large senders deliver these reports. Set up TLS-RPT before MTA-STS so you already receive data in testing mode.
_smtp._tls.example.com. IN TXT "v=TLSRPTv1; rua=mailto:tlsrpt@example.com"Rollout in three stages
The most important advice: never start with enforce. In testing mode senders check the policy and report violations via TLS-RPT but still deliver. Only when the reports show no errors for at least one to two weeks do you switch.
- Create the TLS-RPT record and set up a mailbox or reporting service for the reports.
- Determine all MX hosts of the domain and verify that each presents a valid certificate for its hostname. The MX checker shows both.
- Publish the policy file with mode: testing and a short max_age of one day at mta-sts.your-domain.com over HTTPS with a valid certificate.
- Create the _mta-sts TXT record with an id, for example a timestamp.
- Read the reports for two weeks. If errors appear, correct the MX list or the certificates.
- Set mode to enforce and max_age to at least one week, and change the id in the TXT record.
The most common mistakes
Almost every MTA-STS problem has one of a handful of causes, and all of them are harmless in testing mode but delivery-critical in enforce mode.
- The mx lines do not match the real MX hosts: one typo or a forgotten backup MX, and senders refuse delivery to that host.
- The policy is served over HTTP, via a redirect or with Content-Type text/html: senders ignore it or treat it as invalid.
- The certificate on mta-sts.your-domain.com has expired or only covers the main domain: the policy is no longer fetched, cached policies stay valid until max_age.
- The id was not changed after an update: senders keep the old policy in their cache and never notice the new one.
- MX migration without a policy update: the new hosts are not in the policy, and senders in enforce mode stop delivering.
Google Workspace and Microsoft 365
With hosted mail providers you list their MX hosts. For Google Workspace these are, depending on the setup, smtp.google.com or the older hosts aspmx.l.google.com and alt1 to alt4.aspmx.l.google.com; the lines mx: smtp.google.com, mx: aspmx.l.google.com and mx: *.aspmx.l.google.com cover both. For Microsoft 365 the MX is tenant-tld.mail.protection.outlook.com, and the matching line is mx: *.mail.protection.outlook.com.
You still have to host the policy file yourself because it must live under your domain. Static hosting, a Cloudflare Worker or a Pages project with automatic certificates is enough. After every provider change, verify that the policy still matches the MX records.
MTA-STS and DANE
DANE solves the same problem in a different way: instead of an HTTPS file, the domain publishes TLSA records in DNS, secured by DNSSEC, which bind the certificate directly to the MX host. DANE is technically cleaner but requires DNSSEC for the domain and the MX host, and Google does not evaluate it. Microsoft has supported DANE for inbound mail for a few years now.
The two do not exclude each other. If you already have DNSSEC, you can run DANE and MTA-STS in parallel. For domains on Google Workspace and for most agency clients, MTA-STS is the pragmatic first step.