Skip to content
All field notes

MTA-STS Testing to Enforce: Switching Without Losing Mail

How to move an MTA-STS policy from mode: testing to enforce: what TLS-RPT must show first, the order of the switch, max_age choices, and how to roll back.

PlatOps Security TeamSecurity9 min read
The short version
In testing mode a sender reports a failed TLS check and delivers anyway. In enforce mode it does not deliver. Every failure in your TLS-RPT reports during testing is a message enforce would have held back.
Switch only when the reports name your current mx list, show no unexplained failures for at least two weeks, and every MX host, backup MX included, matches the policy and presents a valid certificate.
Change the policy file first, then the id in the _mta-sts TXT record. Keep max_age at one day for the first weeks of enforce, then raise it.
To roll back, publish mode: testing with a new id. Senders that follow RFC 8461 check for a new policy before they give up on a message.

MTA-STS has two working modes, and the gap between them is the whole risk. In testing, a sending server that cannot validate your MX host reports the problem and delivers the message anyway. In enforce, it does not deliver.

A policy can sit in testing for years. That gives you reports, but no protection: an attacker who strips STARTTLS from the connection still gets the message in clear text. The protection only starts at enforce, and the switch is a single word in a text file. This post covers what to confirm before you change that word, the order of the change, and how to undo it.

If MTA-STS is new to you, start with what MTA-STS is and the setup guide. This post assumes a policy in testing mode and a TLS-RPT record already published.

What each mode does

RFC 8461, section 5 defines the modes. A sending server that honors MTA-STS checks two things for each MX host: that the host name matches one of the policy's mx patterns, and that the host offers STARTTLS with a certificate that is valid for that name.

Mode When the check fails, the sender What you see
testing Delivers as if there were no policy, and reports the failure if it supports TLS-RPT A failure line in the next daily report
enforce Does not deliver to that host, and treats it as a temporary failure Queued mail at the sender, then a bounce if nothing changes
none Treats your domain as having no policy Nothing; used to retire MTA-STS

The practical reading: every failure in a testing-mode report is a session that enforce mode would have stopped. The reports are a preview of the outage.

What the reports must show before you switch

TLS-RPT reports arrive once a day per sending organization, as gzipped JSON. The parts that matter for this decision look like this:

"policy": {
  "policy-type": "sts",
  "policy-string": ["version: STSv1", "mode: testing",
                    "mx: mx1.example.com", "mx: mx2.example.com",
                    "max_age: 86400"],
  "policy-domain": "example.com"
},
"summary": {
  "total-successful-session-count": 4180,
  "total-failure-session-count": 12
},
"failure-details": [{
  "result-type": "certificate-host-mismatch",
  "receiving-mx-hostname": "mx2.example.com",
  "failed-session-count": 12
}]

Four checks, in order.

1. The reports show the policy you think you published. policy-string is the policy the sender applied. If it still shows an old mx list or an old max_age, the sender has not picked up your latest change, usually because the id did not change.

2. Reports come from the senders that matter to you. Google, Microsoft and other large providers send reports. A domain that mainly receives mail from one provider needs that provider in the set. Google suggests starting with two weeks in testing mode; two weeks of reports from your main senders is a sensible minimum.

3. Every failure has an explanation. The result types are defined in RFC 8460, section 4.3:

result-type Usual cause Fix
certificate-host-mismatch The certificate does not cover the MX host name, or the host is missing from the mx lines Reissue the certificate or add the host to the policy
certificate-expired Renewal failed on one MX host Fix the renewal job and monitor expiry
certificate-not-trusted Self-signed certificate or incomplete chain Serve the full chain from a public CA
starttls-not-supported A host, often an old backup MX, does not offer STARTTLS Enable TLS or remove the host from MX
sts-policy-fetch-error The policy host was unreachable, redirected, or returned an error Serve the file directly with a 200 response
sts-webpki-invalid The certificate on mta-sts.example.com is not valid Fix the policy host certificate

A handful of failures from one sending IP on one day can be a misconfigured sender. A steady count against one of your own MX hosts is your problem, and enforce mode turns it into lost sessions.

4. Every MX host matches. Compare the mx lines with the MX records you publish today. A wildcard covers exactly one label: *.example.com matches mx1.example.com, but not example.com and not a.mx.example.com (section 4.1). Check the backup MX by hand. Section 8.4 warns that senders may never reach a lower-priority MX while the primary is up, so its problems stay out of the reports until the day the primary fails:

openssl s_client -starttls smtp -connect mx2.example.com:25 \
  -servername mx2.example.com -verify_hostname mx2.example.com \
  -verify_return_error </dev/null

A Verify return code: 0 (ok) line is what you want: the chain is trusted and the certificate names mx2.example.com. The same applies to a filtering gateway in front of your mailboxes: if mail arrives through a security vendor, its MX host names and certificates are the ones senders check.

Reading these reports one JSON file at a time works for one domain. In DDMARC, the TLS Reports page (Protect plan and above) adds the sessions up per domain and ranks the failure types by how many sessions each one cost, so an expiring certificate on one MX host shows up as a spike.

The switch, in order

RFC 8461, section 8.1 sets the order: update the policy file before the TXT record. A sender that sees a new id and fetches the old file caches the old policy.

Step 1. Edit the policy file. Keep max_age short for now:

version: STSv1
mode: enforce
mx: mx1.example.com
mx: mx2.example.com
max_age: 86400

Step 2. Confirm what senders will get. The response must be a 200 with no redirect, since senders do not follow redirects (section 3.3), and the content type should be text/plain:

curl -sS -D - https://mta-sts.example.com/.well-known/mta-sts.txt

Step 3. Change the id:

_mta-sts.example.com.  TXT  "v=STSv1; id=20261027T1400Z"

The id is 1 to 32 letters and digits. A value like 2026-10-27 has hyphens, which makes the record invalid, and senders then act as if your domain has no new policy. The MTA-STS checker shows the record and the published mode and mx lines. It does not compare them with your live MX records, so do that comparison yourself.

Step 4. Watch the next two or three days of reports. policy-string should now show mode: enforce, and the failure count should stay where it was in testing.

Step 5. Raise max_age. RFC 8461 expects values "in the range of weeks or greater". Microsoft publishes 604800 (one week) for its own domains. Change the file, then the id, as before.

max_age decides how long a mistake lasts

max_age is how long a sender may keep using your policy without fetching it again, up to 31557600 seconds. Senders should refresh before it runs out, and RFC 8461 suggests once a day. The catch is the direction of the cache: a sender applies a cached policy even when your DNS or policy host is unreachable (section 3.3). That is what makes MTA-STS resistant to an attacker who blocks the policy fetch. It also means a wrong enforce policy cached for a month stays wrong for that sender until it next fetches a new one.

A short max_age during the first weeks of enforce limits that exposure. Short values are not unusual in production. On 27 October 2026, Gmail served mode: enforce with max_age: 86400, Microsoft served mode: enforce with max_age: 604800 for *.mail.protection.outlook.com, and Yahoo still served mode: testing.

Changing MX hosts while enforced

The common way to break an enforced policy is a mail migration. A new provider, a new filtering gateway or a new backup MX goes into DNS, and the policy still lists only the old hosts. Senders that enforce refuse the new host. Exchange Online, for example, returns 5.4.8 when an MX host fails MTA-STS validation.

The order that avoids it:

  1. Add the new host to the policy next to the old ones, then change the id.
  2. Wait at least the TXT record TTL plus a day, so senders that refresh daily hold the new list.
  3. Change the MX records.
  4. When the old hosts are gone from MX, remove them from the policy and change the id again.

If the migration is large or the new certificate setup is uncertain, go back to testing for the cutover and return to enforce once the reports are clean.

Rolling back

Microsoft's own guidance for incidents is to switch the policy back to testing: change the file, then the id. It works quickly for a reason in the standard. A sender that fails to deliver because of an enforce policy must check DNS for a new id before it fails the message permanently (section 5.1), and should treat the failure as temporary until then. Mail queued at a compliant sender is delayed, not lost, as long as the fix lands within its retry period.

Two exceptions. Senders that ignore a new id keep the cached policy until max_age runs out, which is the other reason to keep it short at first. And mail for a subdomain such as user@eu.example.com follows the policy at eu.example.com only; RFC 8461 never applies the parent domain's policy to it, so each receiving subdomain needs its own records and its own rollout.

When the policy host is the hard part

Enforce mode makes the policy host part of your inbound mail path: its certificate on mta-sts.example.com has to stay valid, it must answer without redirects, and every policy change needs a matching id change. On the Growth plan and above, DDMARC hosts the policy file and the id record for you through two CNAME records. Managed policies start in testing, and DDMARC refuses the switch to enforce until every live MX host matches the policy's mx patterns, and names the hosts that do not. An override exists, and it is recorded. The pricing page lists what each plan includes.

Questions we get asked

Google suggests starting with two weeks in testing mode. Use the TLS-RPT reports, not the calendar, to decide: switch once reports from the providers that send you mail show your current policy and no failures you cannot explain.

Field notes, twice a month.

When a mailbox provider changes the rules, you hear it here with the record you need to change. No digest, no roundup, no product news.

Field Notes, our DMARC newsletter, twice a month, from PlatOps Security, LLC (Gaithersburg, MD). We use your address only to send it. Unsubscribe with one click in any issue. Privacy policy.