MTA-STS and TLS-RPT: require encrypted mail delivery
Want this checked on your own domain?
Join the waitlistUpdated
Message for whoever manages your DNS and email
Hi, we’d like to turn on MTA-STS and TLS reporting for our domain. Could you:
- add a TLS reporting record: TXT at _smtp._tls with v=TLSRPTv1; rua=mailto:(a mailbox we read);
- publish an MTA-STS policy in testing mode at https://mta-sts.(our domain)/.well-known/mta-sts.txt, listing every one of our current MX servers;
- add the TXT record at _mta-sts: v=STSv1; id=(today’s date, digits only).
After about two weeks of clean reports, we’ll switch the policy to enforce. Thank you.
Want this checked on your own domain? Join the waitlist.
Check yours
The full domain report (join the waitlist for access) reads your _mta-sts and _smtp._tls records, fetches your policy file, and compares it with your MX records. The MX lookup lists the mail servers your policy has to cover.
Fix it
Before you start. MTA-STS works only if every mail server in your MX records accepts encrypted connections (STARTTLS) with TLS 1.2 or later, and presents a certificate that is valid for the server’s name, issued by a trusted certificate authority, and not expired (RFC 8461 §4.2 and §7.2). If your MX records point to an email provider, it runs those servers; check its documentation. You still publish the DNS records and host the policy file yourself: Microsoft, for example, says it can’t host the policy file for Microsoft 365 customers.
Set it up in this order:
- Turn on reports. Add a TXT record at
_smtp._tlsnaming a mailbox that someone reads. Google recommends doing this before turning on MTA-STS. - Write the policy file in testing mode, with one
mx:line for each server in your MX records (example below). Google asks for theversionline first. - Host the file at
https://mta-sts.example.com/.well-known/mta-sts.txt, with your domain in place ofexample.com:- create the
mta-stshost name in DNS, pointing to the web server or service that will serve the file; - give that server a certificate valid for
mta-sts.example.com, from a trusted certificate authority (RFC 8461 §3.3); - serve the file itself with status 200, no redirects, and a
Content-Typeoftext/plain(RFC 8461 §3.2 and §3.3).
- create the
- Publish the
_mta-stsrecord with an id: 1 to 32 letters and digits, such as the date. Google and Microsoft both suggest the date and time. - Read the reports for about two weeks, as Google recommends, and fix any server the reports name.
- Switch to enforce. Change
mode: testingtomode: enforcein the file, raisemax_ageto a week or more, and save the file. Then change the id in the_mta-stsrecord.
The two DNS records:
| Type | Host | Value |
|---|---|---|
| TXT | _smtp._tls | v=TLSRPTv1; rua=mailto:tls-reports@example.com |
| TXT | _mta-sts | v=STSv1; id=20261008 |
_smtp._tls.example.com. 3600 IN TXT "v=TLSRPTv1; rua=mailto:tls-reports@example.com"
_mta-sts.example.com. 3600 IN TXT "v=STSv1; id=20261008"
The policy file, for a domain whose MX records are mx1.example.net and mx2.example.net:
version: STSv1
mode: testing
mx: mx1.example.net
mx: mx2.example.net
max_age: 604800
An mx: line can also be a wildcard such as *.example.net, which matches exactly one extra label: mx1.example.net, but not example.net or a.b.example.net (RFC 8461 §4.1). If your provider documents a policy line for its servers, use it; Microsoft documents mx: *.mail.protection.outlook.com for domains whose MX records point directly to Microsoft 365 (Exchange Online).
Changing the policy or your mail servers
- Every change to the file needs a new id in the
_mta-stsrecord; without it, senders keep the copy they cached until itsmax_ageruns out (RFC 8461 §3.1; Microsoft). Update the file first and the record second, so senders that see the new id fetch the new file (RFC 8461 §8.1). - Before you change MX records (see moving to a new email provider), add the new mail servers to the policy alongside the old ones and change the id. Change the MX records once the
_mta-stsrecord’s TTL has passed, then remove the old servers from the policy and change the id again. Senders can keep using the old policy until both the file and the record are updated and the TTL has passed (RFC 8461 §8.1). - To turn MTA-STS off, publish the file with
mode: noneand a shortmax_agesuch as 86400 (one day), and change the id. Delete the record and the file only once the longestmax_ageyou ever published has passed since that change (RFC 8461 §8.3).
The MTA-STS record is invalid
What it means. The TXT record at _mta-sts can’t be used, for one of three reasons: there is more than one record starting v=STSv1; the record isn’t in the form v=STSv1; id=…; or the id isn’t 1 to 32 letters and digits (dashes, dots, colons, and spaces aren’t allowed).
Why it matters. Senders that find anything other than exactly one valid record assume the domain has no MTA-STS policy (RFC 8461 §3.1), so your policy file is ignored.
Fix. Keep exactly one TXT record at _mta-sts, in this form:
v=STSv1; id=20261008
Confirm. The full report goes on to check the policy file.
The MTA-STS policy file can’t be fetched
What it means. Your _mta-sts record announces a policy, but we couldn’t load https://mta-sts.<your domain>/.well-known/mta-sts.txt. Possible causes: the mta-sts host name doesn’t exist in DNS; its certificate is expired, untrusted, or issued for a different name; the address redirects elsewhere; the server returns an error such as 404; the request times out; or the file isn’t served as text.
Why it matters. Senders must not follow redirects and accept only a status of 200 (RFC 8461 §3.3). If they can’t fetch the policy, senders that never cached it deliver as if you had no MTA-STS, while senders that cached an earlier version keep applying that version until it expires (RFC 8461 §3.3).
Fix. Serve the policy file at that exact address over HTTPS, with a certificate valid for mta-sts.<your domain>, status 200, no redirects, and Content-Type: text/plain. If a service hosts the file for you, the certificate must still be for your mta-sts host name, not the service’s own (RFC 8461 §8.2).
Confirm. curl -sS -D - https://mta-sts.example.com/.well-known/mta-sts.txt shows 200, a text/plain content type, and the policy. Then run the full report again.
The MTA-STS policy file is invalid
What it means. We fetched the policy file, but it breaks the format: the version line is missing or isn’t STSv1; the mode isn’t enforce, testing, or none; max_age is missing, isn’t a whole number, or is larger than 31557600; there is no mx: line in testing or enforce mode; or a line isn’t in key: value form.
Why it matters. Senders can’t apply a policy they can’t parse, so you get no protection.
Fix. Rewrite the file from this template, with your own mail servers, then change the id in the _mta-sts record. Use mode: enforce instead of testing only once reports show that all your servers pass.
version: STSv1
mode: testing
mx: mx1.example.net
mx: mx2.example.net
max_age: 604800
Field names and mode values are case-sensitive: write them in lowercase as shown, and the version as STSv1 (RFC 8461 §3.2).
Confirm. The full report shows the mode and compares the mx: lines with your MX records.
MTA-STS policy expires almost immediately
What it means. The policy’s max_age, how long senders keep it, is under 86400 seconds (one day).
Why it matters. MTA-STS protects you only while a sender holds a cached copy of your policy. An attacker who can block the policy lookup can strip the protection whenever the cached copy has expired, so RFC 8461 asks for values “in the range of weeks or greater” (§3.2) and “as long as is practical” (§10.2). Google requires at least 86400.
Fix. Set max_age to at least 604800 (one week). Google suggests 604800 to 1209600 while you test; once in enforce mode, longer values give more protection. Then change the id in the _mta-sts record.
Confirm. The full report no longer raises this.
Some mail servers aren’t in the MTA-STS policy
What it means. At least one server in your MX records doesn’t match any mx: line in a policy in testing or enforce mode.
Why it matters. In enforce mode, senders that follow MTA-STS must not deliver to a server the policy doesn’t list (RFC 8461 §5). They skip it and try the next one, so a missing backup server may go unnoticed until your main server is down (RFC 8461 §8.4). In testing mode, senders report the mismatch but still deliver.
Fix. Add an mx: line for each of those servers, exactly as it appears in your MX records (or a wildcard that matches it), then change the id in the _mta-sts record. If a listed server is no longer in use, remove it from your MX records instead.
Confirm. The full report no longer raises this.
MTA-STS is blocking mail delivery
What it means. The policy is in enforce mode, but none of your current MX servers matches any of its mx: lines. This can happen after a change of email provider.
Why it matters. Senders that enforce MTA-STS won’t deliver to any of your servers. Gmail follows enforce-mode policies, and Microsoft 365 checks them on all outbound mail and may return error 5.4.8 to the sender, with the text MX hosts of '{domain}' failed MTA-STS validation. Senders should treat this as temporary, retry, and check for a new policy before giving up (RFC 8461 §5), so fixing it quickly lets queued mail through.
Fix. Act now, in this order:
- Add your current MX servers to the policy file, or set
mode: none. - Change the id in the
_mta-stsrecord so senders fetch the corrected file.
Don’t delete the record or the file instead: senders that cached the broken policy keep applying it until it expires, and only a new policy replaces it (RFC 8461 §3.3).
Confirm. The full report no longer raises this. Send yourself a test message from a Gmail or Microsoft 365 account.
MTA-STS policy without a DNS record
What it means. A policy file is published at https://mta-sts.<your domain>/.well-known/mta-sts.txt, but there is no _mta-sts TXT record.
Why it matters. Senders discover MTA-STS through the TXT record and fetch the file only when it exists (RFC 8461 §3), so the policy isn’t used.
Fix. If you meant to turn MTA-STS on, check that the file lists all your current MX servers, then add the record:
_mta-sts.example.com. 3600 IN TXT "v=STSv1; id=20261008"
If the file is left over from turning MTA-STS off, delete it once the longest max_age you published has passed.
Confirm. The full report finds the record and checks the policy.
The TLS-RPT record is invalid
What it means. The TXT record at _smtp._tls can’t be used: there is more than one record starting v=TLSRPTv1, or the rua= tag is missing, or one of its addresses doesn’t start with mailto: or https:.
Why it matters. Senders that find anything other than exactly one record assume you don’t want reports (RFC 8460 §3), so you won’t hear about delivery problems.
Fix. Keep one record. To send reports to more than one place, list the addresses in a single rua= tag, separated by commas:
v=TLSRPTv1; rua=mailto:tls-reports@example.com,mailto:security@example.com
Confirm. The full report shows TLS reporting as on.
Technical reference
What MTA-STS protects against
SMTP encryption between servers (STARTTLS) is opportunistic: a sender uses it when offered and otherwise sends in clear text. An attacker on the path can delete the server’s STARTTLS offer, or redirect the connection to an impostor by spoofing MX records or routing (RFC 8461 §10; RFC 8460 §1). MTA-STS lets the recipient domain declare that its MX servers support TLS with valid certificates, so a sender that has cached the policy refuses to downgrade. It protects only senders that have previously obtained the policy (§10), and relies on the web certificate system (§10.1, §10.5). DANE does the same job using DNSSEC; senders that implement both “MUST NOT allow MTA-STS Policy validation to override a failing DANE validation” (§2).
The _mta-sts record
RFC 8461 §3.1:
- A TXT record at
_mta-sts.<domain>, with semicolon-separated fields. It must begin withv=STSv1, and must containid=followed by 1 to 32 letters and digits. Other fields are ignored. - Records that don’t begin with
v=STSv1;are discarded. If not exactly one remains, or it is invalid, the domain has no usable policy. - A record split into several strings is joined without spaces. The name may be a CNAME, which senders follow; that allows a provider to manage the record (§8.2).
- The id has no implied order; it only has to change whenever the policy changes.
The policy file
RFC 8461 §3.2 and §3.3:
- It is served at
https://mta-sts.<domain>/.well-known/mta-sts.txt. Senders should check that the media type istext/plain. - It contains
key: valuelines, separated by CRLF or LF.version(STSv1),mode, andmax_ageare required once each;mxis required at least once unless the mode isnone. Unknown fields are ignored, and for repeated fields other thanmxonly the first counts. max_ageis a whole number of seconds, at most 31557600 (about a year).mxvalues are host names or*.wildcards; internationalized names must be in A-label (Punycode) form.- The server’s certificate must be valid for
mta-sts.<domain>, chain to a trusted root, and not be expired. Only status 200 counts; redirects must not be followed, and HTTP caching must not be used. A one-minute timeout and a 64 KB size limit are suggested. - If a policy can’t be fetched and none is cached, the sender delivers as if MTA-STS weren’t deployed. If a fresh copy can’t be fetched but a cached one is unexpired, the sender applies the cached one. Senders should refresh cached policies before they expire, for example daily.
How senders apply a policy
RFC 8461 §4 and §5:
- A server is valid when its MX host name matches an
mxpattern (a wildcard matches only the leftmost label), it supports STARTTLS, and its certificate has a subject alternative name matching that host name, chains to a trusted root, and isn’t expired. - enforce: the sender must not deliver to a server that fails. It tries the next MX server in priority order, treats failures as temporary, and checks for a new policy before failing a message permanently.
- testing: the sender reports failures through TLS-RPT, if the domain publishes it, and delivers anyway.
- none: the sender treats the domain as having no active policy. This mode exists to remove MTA-STS cleanly (§8.3).
- Senders that support MTA-STS must support TLS 1.2 or later (§7.2), and must send SNI (Server Name Indication) with the MX host name (§7.1).
Subdomains, delegation, and wildcards
- Policies don’t inherit: mail to
user@mail.example.comuses the policy ofmail.example.com, never that ofexample.com(§3.4). - To let a provider manage your policy, point
_mta-stsat the provider’s record with a CNAME, and point or proxy themta-stshost to the provider. The certificate must still be valid formta-sts.<your domain>(§8.2). - A wildcard such as
*.example.comaccepts any host under that domain that has a valid certificate, including ones you didn’t intend as mail servers (§10.4).
TLS reporting (TLS-RPT)
RFC 8460:
- A TXT record at
_smtp._tls.<domain>:v=TLSRPTv1followed byrua=with one or more comma-separatedmailto:orhttps:addresses (§3). Records not startingv=TLSRPTv1;are discarded; if not exactly one remains, senders assume the domain doesn’t want reports. - Reports cover a full UTC day (§4.1), are JSON, normally compressed with gzip (§4.4, §5.2), and are sent by email, which must be DKIM-signed by the reporter, or by HTTPS POST (§3, §5).
- Reports cover MTA-STS and DANE policy failures, STARTTLS and certificate failures, and successful sessions as a heartbeat (§1, §4.3).
Who enforces MTA-STS when sending
- Gmail: “Gmail messages from your domain comply with MTA-STS when sent to external servers with an MTA-STS policy in enforced mode” (Google).
- Microsoft 365 (Exchange Online): validates MTA-STS on all outbound mail, “always turned on”. Failures may return error 5.4.8 when the MX host isn’t in the policy and 5.7.5 when the server’s certificate fails validation (Microsoft).
What the report checks
We run these checks only for domains that receive mail (with at least one MX record that isn’t a null MX).
- We look up TXT records at
_mta-sts.<domain>and keep those startingv=STSv1. More than one, a record that doesn’t matchv=STSv1;, or an id that isn’t 1 to 32 letters and digits: the MTA-STS record is invalid. - We always request
https://mta-sts.<domain>/.well-known/mta-sts.txtonce, verifying its certificate and without following redirects. If there is no record but the file loads and containsSTSv1: policy without a DNS record. If neither exists, we note that MTA-STS isn’t set up. - With a valid record, a failed request, a certificate that isn’t valid for the host, a non-200 status, a redirect, or a content type other than
text/plain: the policy file can’t be fetched, with the reason. - We parse the file with case-sensitive field names, using only the first of any repeated field other than
mx(RFC 8461 §3.2):versionmust beSTSv1,modeone of the three modes,max_agea whole number of at most 31557600, and testing or enforce mode needs at least onemxline. Otherwise: the policy file is invalid. - We match each MX host against the
mxpatterns using the RFC’s wildcard rule. Enforce mode with no MX host matched: MTA-STS is blocking mail delivery. Any MX host unmatched in testing or enforce mode: some mail servers aren’t in the policy. max_ageunder 86400: expires almost immediately. Under 604800, we note that the policy is cached only briefly.- A policy in testing mode is noted as testing; one in mode
noneis noted as MTA-STS switched off (senders treat it as no policy, RFC 8461 §5). An enforce-mode policy with none of the problems above is reported as secure delivery being required. - For TLS-RPT, we look up
_smtp._tls.<domain>and keep records startingv=TLSRPTv1. More than one, a missingrua=, or an address that isn’tmailto:orhttps:: the TLS-RPT record is invalid.
We don’t connect to your mail servers, so we don’t test STARTTLS, TLS versions, or their certificates. TLS-RPT reports from senders show whether those pass.
Sources
- RFC 8461, SMTP MTA Strict Transport Security (MTA-STS)
- RFC 8460, SMTP TLS Reporting
- Google Workspace Admin Help, About MTA-STS and TLS reporting
- Google Workspace Admin Help, Create an MTA-STS policy
- Google Workspace Admin Help, Publish your MTA-STS policy
- Google Workspace Admin Help, Turn on MTA-STS and TLS reporting
- Microsoft Learn, Enhance mail flow with MTA-STS
Want this checked on your own domain?
Join the waitlist