Step-by-step MTA-STS and TLS-RPT setup: host mta-sts.txt over HTTPS, publish the _mta-sts and _smtp._tls TXT records, use the right mx lines for Microsoft 365 or Google Workspace, and move safely from testing to enforce.
Home › Guides › MTA-STS and TLS-RPT setup
Last updated 17 October 2026
MTA-STS needs a small text file on a web server and one DNS record. TLS-RPT is one more DNS record that gets you reports. For a domain whose MX points at Microsoft 365, the whole setup looks like this:
https://mta-sts.example.com/.well-known/mta-sts.txt version: STSv1 mode: testing mx: *.mail.protection.outlook.com max_age: 604800 _mta-sts.example.com TXT v=STSv1; id=20261017000000Z _smtp._tls.example.com TXT v=TLSRPTv1; rua=mailto:tlsrpt@example.com
On Google Workspace, the mx line is smtp.google.com (or the older aspmx names). Start in testing mode, read the TLS reports for about two weeks, then change the file to mode: enforce and give the TXT record a new id. Build the file with the MTA-STS Policy Generator and the report record with the TLS-RPT Record Generator.
Mail servers encrypt SMTP with STARTTLS, but only when both sides offer it, and they usually don't check the certificate. If someone in the path strips the STARTTLS offer or points the sender at the wrong server, most senders still deliver the mail, unencrypted or to the wrong host.
enforce mode they refuse to deliver to an MX that doesn't match the policy, doesn't offer STARTTLS or doesn't present a valid certificate.MTA-STS protects mail sent to your domain. Senders that don't support it keep delivering as they do today, so publishing a policy never stops mail from those servers. Exchange Online and Gmail already check other domains' MTA-STS policies when they send, so those senders will apply yours once it is published.
mta-sts.<your domain>, with a certificate valid for that exact name. Exchange Online can't host the policy file, and Google's instructions have you upload it to your own web server.tlsrpt@example.com.Google recommends adding the TLS-RPT record first, then turning on MTA-STS, so reports are already flowing when the policy goes live. Add a TXT record at _smtp._tls:
Host: _smtp._tls Type: TXT Value: v=TLSRPTv1; rua=mailto:tlsrpt@example.com
v=TLSRPTv1. The rua tag is required.rua takes mailto: or https: addresses. For several destinations, separate them with commas: rua=mailto:tlsrpt@example.com,mailto:security@example.com.v=TLSRPTv1, they treat the domain as having no TLS reporting.https: endpoint receives the report as an HTTP POST (application/tlsrpt+json, or application/tlsrpt+gzip when compressed). Google Workspace doesn't provide an API for HTTPS reports, so email is the simple choice.Generate and check the value with the TLS-RPT Record Generator.
The policy is a plain text file named mta-sts.txt with one key: value pair per line:
version: STSv1 mode: testing mx: mail.example.com mx: *.example.net max_age: 604800
| Key | What to put |
|---|---|
version | Always STSv1. Google asks for it on the first line; the other keys can be in any order. |
mode | testing: senders report failures but still deliver. enforce: senders that support MTA-STS won't deliver to an MX that fails validation. none: tells senders you no longer use MTA-STS (used to turn it off). |
mx | One line per allowed MX host. Use the exact hostname, or a wildcard that replaces only the leftmost label: *.example.com matches mail.example.com but not example.com or a.b.example.com. Internationalized names go in punycode (xn--) form. Required in testing and enforce modes. |
max_age | How long, in seconds, senders may cache the policy. RFC 8461 sets the maximum at 31557600 (about a year) and expects weeks or more once you are stable. Google asks for 86400 (one day) to 31557600 and recommends 604800 to 1209600 (one to two weeks) while testing. |
mx on its own line. A comma-separated list on one line is invalid.mta-sts host, even if the contents are identical.The MTA-STS Policy Generator builds the file and a matching TXT record from your mode, MX list and max_age.
Senders fetch the policy from one fixed URL:
https://mta-sts.example.com/.well-known/mta-sts.txt
mta-sts.example.com, chain to a publicly trusted root and not be expired. A certificate for the apex or www alone doesn't count.200 OK with the file itself. Senders must not follow 3xx redirects, so a redirect to another path or host breaks the policy.text/plain. Senders should check the media type, so an HTML page that happens to contain the right text can be rejected.Any static host that serves HTTPS on a custom subdomain with an automatic certificate works. Common choices are Cloudflare Pages or Workers, GitHub Pages, Azure Static Web Apps (Microsoft's recommended option for Exchange Online customers) or a web server you already run. The steps are the same everywhere:
mta-sts.example.com as its custom domain. The host tells you which CNAME or A record to create, then issues the certificate..well-known/mta-sts.txt. Some static site builders skip folders whose names start with a dot, so confirm the folder was actually deployed.Using a hosted MTA-STS service instead? RFC 8461 allows delegation: point _mta-sts at the provider's record with a CNAME, and point mta-sts at the provider. The certificate must still be valid for mta-sts.<your domain>.
Once the policy URL works, add a TXT record at _mta-sts. This record is what tells senders a policy exists:
Host: _mta-sts Type: TXT TTL: 3600 Value: v=STSv1; id=20261017000000Z
v=STSv1.id is 1 to 32 letters and digits only. No dashes, dots, colons or spaces, so 2026-10-17 is invalid. Microsoft and Google both suggest the current UTC date and time, such as 20261017000000Z, so you can see when the policy last changed.v=STSv1. With two, senders ignore MTA-STS for the domain.Confirm both TXT records with DNS Lookup, then run the domain through the Email Deliverability Checker, which reports MTA-STS and TLS-RPT along with SPF, DKIM and DMARC.
If your MX points straight at Exchange Online (a host like contoso-com.mail.protection.outlook.com), Microsoft says you can use the same policy values as microsoft.com's own policy. This is the file we fetched from mta-sts.microsoft.com on 17 October 2026:
version: STSv1 mode: enforce mx: *.mail.protection.outlook.com max_age: 604800
mode: testing, as Microsoft recommends, and switch to enforce after validating.mta-sts certificate for you, or Azure Functions, where you bring your own certificate.Enable-DnssecForVerifiedDomain gives the domain a new MX hostname under mx.microsoft, returned as DnssecMxValue (Microsoft's example is contosotest-com.o-v1.mx.microsoft). Microsoft's order is: set the policy to testing, change the id and wait for the old max_age to pass; then replace the legacy mx line with the exact new hostname and change the id again; once mail flows, set enforce and change the id once more. Add the exact hostname, because *.mx.microsoft covers only one label and doesn't match it. If the line is missing, Microsoft reports ES001: Expected MX record missing in policy while mode is enforced.5.4.8 (MX not in the policy) or 5.7.5 (certificate failed validation). Exchange Online also sends TLS-RPT reports, in JSON.Setting up the rest of Microsoft 365 mail authentication? See the SPF, DKIM and DMARC guides.
Google says the policy needs an mx line for each MX record on the domain:
mx: smtp.google.com (current single MX) mx: aspmx.l.google.com (older MX set, common on domains set up before 2023) mx: *.aspmx.l.google.com (covers alt1 to alt4.aspmx.l.google.com)
Google's own google.com policy, fetched on 17 October 2026, lists exactly these three lines in enforce mode. Listing all three is a simple choice if you aren't sure which set your domain uses, and it keeps working if you later move from the aspmx names to smtp.google.com.
mta-sts subdomain. Each domain in the account needs its own hosted file.testing mode for two weeks, which it says is enough report data to find and fix problems.Still setting up the basics? See SPF, DKIM and DMARC for Google Workspace.
testing for about two weeks and read the TLS reports. Each report lists the policy that was applied ("policy-type": "sts"), total-successful-session-count and total-failure-session-count, plus a result-type for each failure.starttls-not-supported, certificate-host-mismatch, certificate-expired and certificate-not-trusted (an MX problem), sts-policy-fetch-error (the policy URL can't be reached), sts-policy-invalid (the file has an error) and sts-webpki-invalid (the mta-sts certificate failed).mode: enforce. You can raise max_age at the same time, for example to 1209600 (two weeks) or longer.id. Google says you must change the id when going from testing to enforce, just like any other policy change.id. Senders only fetch the file again when the id changes; otherwise they keep the cached copy until max_age runs out.id doesn't cache the old file.testing, change the id, wait for the old max_age to pass, change the MX records and the mx lines, then return to enforce with another new id.mode: none with a short max_age (for example one day) and a new id. Remove the TXT record and the file only after every older policy's max_age has expired. Deleting the TXT record alone doesn't clear senders' caches.user@mail.example.com uses only mail.example.com's own policy, so each domain that receives mail needs its own records and mta-sts host.enforce mode, MTA-STS senders won't deliver to it.*.example.com doesn't match example.com or mx1.mail.example.com, and *.mx.microsoft doesn't match a DNSSEC MX like contoso-com.o-v1.mx.microsoft.mx line, separated by commas.id with dashes or dots, such as 2026-10-17, or longer than 32 characters.id, so senders keep the cached policy.mta-sts.<your domain>.v=STSv1 or two v=TLSRPTv1 records, so senders ignore both.enforce with a long max_age before reading any reports.Need SPF, DMARC and MX checks across a whole client list? Run the Bulk SPF / DMARC / MX Auditor on Apify ($2 per 1,000 domains).
Build the policy with the MTA-STS Policy Generator and the report record with the TLS-RPT Record Generator. List every MX first with MX Record Lookup, check the certificates for your MX and mta-sts hostnames with the SSL Certificate Checker, confirm the TXT records with DNS Lookup and the DNS Propagation Checker, and audit the whole domain with the Email Deliverability Checker. Related guides: SPF, DKIM and DMARC for Microsoft 365, SPF, DKIM and DMARC for Google Workspace, and the bulk sender requirements (which list TLS for sending to Gmail).
MTA-STS (RFC 8461) publishes a policy that tells sending servers your MX hosts support TLS with valid certificates and, in enforce mode, not to deliver if that check fails. TLS-RPT (RFC 8460) is a separate DNS record at _smtp._tls that tells senders where to send daily reports about successful and failed TLS connections. Deploy them together so you can see problems before you enforce.
At https://mta-sts.yourdomain/.well-known/mta-sts.txt on any web host that serves HTTPS with a publicly trusted certificate valid for the mta-sts subdomain. A static host such as Cloudflare Pages, GitHub Pages or Azure Static Web Apps works. The URL must return the file directly with HTTP 200, not a redirect, as plain text.
If your MX points directly at Exchange Online, use mx: *.mail.protection.outlook.com, the same value Microsoft uses for microsoft.com. If you have enabled inbound SMTP DANE with DNSSEC, add the exact mx.microsoft hostname returned as DnssecMxValue, because a wildcard does not cover it. If a filtering gateway receives your mail, list the gateway MX hosts instead.
Add an mx line for each MX record on the domain: smtp.google.com for the current single MX, or aspmx.l.google.com plus *.aspmx.l.google.com for the older set. Google lists all three lines in its own google.com policy, and the Admin console under Apps, Google Workspace, Gmail, Compliance can suggest a policy for your domain.
Run in testing mode for about two weeks and fix any failures the TLS reports show. Then edit the policy file to say mode: enforce, optionally raise max_age, and change the id value in the _mta-sts TXT record to a new string of letters and digits, such as the current UTC date and time. Update the file before the TXT record.
Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.