How to Set Up MTA-STS and TLS-RPT

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

Quick answer

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.

What MTA-STS and TLS-RPT do

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.

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.

Before you start

Step 1: Turn on TLS reporting

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

Generate and check the value with the TLS-RPT Record Generator.

Step 2: Write the policy file

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
KeyWhat to put
versionAlways STSv1. Google asks for it on the first line; the other keys can be in any order.
modetesting: 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).
mxOne 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_ageHow 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.

The MTA-STS Policy Generator builds the file and a matching TXT record from your mode, MX list and max_age.

Step 3: Host the policy on mta-sts.<your domain>

Senders fetch the policy from one fixed URL:

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

Hosting options

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:

  1. Create a site or project and add mta-sts.example.com as its custom domain. The host tells you which CNAME or A record to create, then issues the certificate.
  2. Upload the file as .well-known/mta-sts.txt. Some static site builders skip folders whose names start with a dot, so confirm the folder was actually deployed.
  3. Open the URL in a browser. You should see only the policy text, with no redirect and no certificate warning. Some hosts answer unknown paths with their home page and HTTP 200, so check that the content is your policy, not just that the page loads.

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>.

Step 4: Publish the _mta-sts TXT record

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

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.

Microsoft 365 (Exchange Online)

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

Setting up the rest of Microsoft 365 mail authentication? See the SPF, DKIM and DMARC guides.

Google Workspace

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.

Still setting up the basics? See SPF, DKIM and DMARC for Google Workspace.

Step 5: Test, then switch to enforce

  1. Check that the policy URL returns the file and that both TXT records resolve. On Google Workspace, also run the Admin console validation.
  2. Leave the policy in 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.
  3. Fix what the reports show. Common result types are 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).
  4. Change the file to mode: enforce. You can raise max_age at the same time, for example to 1209600 (two weeks) or longer.
  5. Update the TXT record with a new id. Google says you must change the id when going from testing to enforce, just like any other policy change.

Changing the policy later

Common mistakes

Audit hundreds of domains at once

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).

Related tools and guides

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).

FAQ

What is the difference between MTA-STS and TLS-RPT?

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.

Where do I host the MTA-STS policy file?

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.

What mx value do I use for Microsoft 365 in an MTA-STS policy?

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.

What mx values do I use for Google Workspace in an MTA-STS policy?

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.

How do I switch MTA-STS from testing to enforce?

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.

Want the full kit?

Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.