Skip to content

MTA-STS and TLS-RPT: Enforce TLS for Inbound Email

How MTA-STS stops TLS downgrade attacks on inbound mail, how to publish the policy, and how TLS-RPT reports problems.

Published 7 min read

MTA-STS (RFC 8461) lets a domain tell sending mail servers that its inbound mail must be delivered over TLS with a valid certificate, to an MX host on an approved list. You publish a TXT record at _mta-sts.example.com and a policy file at https://mta-sts.example.com/.well-known/mta-sts.txt. TLS-RPT (RFC 8460) is the companion: a TXT record at _smtp._tls.example.com that asks senders to email you daily reports about TLS failures.

This guide explains the problem both standards solve, how to publish them, how to roll out from testing to enforce, and what to look for in the reports.

Why SMTP needs MTA-STS

Server-to-server SMTP uses opportunistic TLS. A sending server connects to your MX on port 25, and if your server advertises STARTTLS, the two upgrade to an encrypted connection. If the advertisement is missing, the sender falls back to plaintext.

That design has two weaknesses an attacker on the network path can exploit:

  • Downgrade. Strip the STARTTLS advertisement from the server's response, and the sender delivers in plaintext.
  • Impersonation. Even when TLS is used, most senders do not validate the certificate, so an attacker who redirects the connection (for example by spoofing DNS for your MX records) can present any certificate.

MTA-STS fixes both for senders that support it. Once a sender has fetched and cached your policy, it requires TLS, requires a certificate that is valid for the MX hostname, and requires the MX hostname to match your policy. If any check fails in enforce mode, it does not deliver the message and retries later.

MTA-STS vs DANE

DANE for SMTP (RFC 7672) solves the same problem using TLSA records in DNSSEC-signed zones. MTA-STS was designed for domains that cannot or do not want to deploy DNSSEC, and relies on the web PKI (an HTTPS certificate) instead. They can coexist. RFC 8461 says a sender must not let MTA-STS validation override a failing DANE validation.

The three parts of MTA-STS

1. The _mta-sts TXT record

_mta-sts.example.com.  3600  IN  TXT  "v=STSv1; id=20261024T120000"
  • v=STSv1 must come first.
  • id is 1 to 32 letters or digits. It has no meaning except "the policy changed". Senders that see a new id fetch the policy again. A timestamp is a convenient choice.

If a sender finds more than one record starting with v=STSv1, or the record is malformed, it treats the domain as having no MTA-STS policy.

2. The HTTPS host

The policy is served from a fixed URL:

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

Requirements from RFC 8461:

  • The hostname is always mta-sts. plus your domain. You cannot choose another.
  • The HTTPS certificate must be valid for mta-sts.example.com, chain to a trusted root, and not be expired.
  • Only an HTTP 200 response counts. Senders do not follow redirects, so mta-sts.example.com cannot redirect to your main website.
  • Serve the file as text/plain.

Any static host works: a small web server, object storage behind a CDN, or a serverless function.

3. The policy file

version: STSv1
mode: enforce
mx: mx1.example.com
mx: mx2.example.com
max_age: 604800
Field Meaning
version Always STSv1
mode testing, enforce or none
mx One line per allowed MX hostname or pattern
max_age How long senders may cache the policy, in seconds. Maximum 31557600 (about one year).

Modes

  • testing: senders validate TLS and report failures through TLS-RPT, but still deliver mail when validation fails. Use this first.
  • enforce: senders refuse to deliver to an MX that fails validation. Mail is queued and retried, not silently dropped, but it will bounce if the problem lasts.
  • none: tells senders you no longer have a policy. Use it to retire MTA-STS cleanly before removing the records.

MX patterns

Each mx: line is an exact hostname or a wildcard that replaces only the leftmost label:

  • mx: mx1.example.com matches only mx1.example.com.
  • mx: *.example.net matches mail.example.net but not example.net and not a.b.example.net.

Your actual MX records must match one of the patterns, and each MX host's certificate must be valid for its name. Check what your MX records currently point to with an MX lookup before writing the policy.

Worked example: Google Workspace or Microsoft 365

Hosted mail providers serve valid certificates on their MX hosts, so MTA-STS is mostly a matter of listing the right patterns.

For Google Workspace, whose MX hosts are smtp.google.com or the older aspmx.l.google.com and alt*.aspmx.l.google.com names:

version: STSv1
mode: testing
mx: smtp.google.com
mx: aspmx.l.google.com
mx: *.aspmx.l.google.com
max_age: 86400

For Microsoft 365, MX hosts typically end in mail.protection.outlook.com:

version: STSv1
mode: testing
mx: *.mail.protection.outlook.com
max_age: 86400

Confirm your own MX values rather than copying these, since tenants and regions differ, and providers have introduced new MX hostnames over time.

TLS-RPT: reporting TLS failures

Without reporting, you cannot tell whether moving to enforce would block legitimate mail. TLS-RPT asks sending servers to send you a daily summary of successful and failed TLS sessions to your domain.

_smtp._tls.example.com.  3600  IN  TXT  "v=TLSRPTv1; rua=mailto:tlsrpt@example.com"
  • v=TLSRPTv1 must come first.
  • rua is one or more mailto: or https: URIs, separated by commas.

Reports are JSON, usually gzip-compressed, and cover a full UTC day. They cover both MTA-STS (policy type sts) and DANE (policy type tlsa), and also report sessions where no policy was found.

What a report tells you

A TLS-RPT report lists, per sending organization and policy:

  • the number of successful and failed sessions,
  • the failure type, for example certificate-expired, certificate-host-mismatch, starttls-not-supported, sts-policy-fetch-error, sts-policy-invalid or sts-webpki-invalid,
  • the receiving MX hostname and IP involved.

During the testing phase, a nonzero failure count is your to-do list. sts-policy-fetch-error usually means a problem with the HTTPS host (bad certificate, redirect, wrong path). certificate-host-mismatch usually means an MX hostname is missing from your policy or a certificate does not cover it.

TLS-RPT is useful even without MTA-STS: it reports on any sender that attempted TLS to your domain.

Rollout plan

  1. Publish TLS-RPT first. Add the _smtp._tls record so reports start arriving.
  2. Publish the policy in testing mode with a short max_age such as 86400 (one day).
  3. Publish the _mta-sts TXT record with a new id.
  4. Read reports for two to four weeks. Fix any certificate or MX mismatch.
  5. Switch to enforce. Update the policy file first, then change id in the TXT record.
  6. Raise max_age. RFC 8461 expects values in the range of weeks or more, because a long cache protects senders even if an attacker blocks a later policy fetch. 604800 (one week) to 31557600 (the maximum) is common.

Changing the policy later

Always update the HTTPS file before you change the TXT id. If you change id first, a sender may fetch the old file, cache it under the new id, and keep it for the full max_age.

When you change MX providers, add the new MX patterns to the policy and wait for at least the old max_age before removing the old ones, or temporarily switch to testing during the migration.

Common mistakes

  • The policy URL redirects. Senders do not follow redirects. Serve the file directly with a 200.
  • No certificate for mta-sts.example.com. A wildcard certificate for *.example.com covers it. A certificate only for example.com does not.
  • An MX record is missing from the policy. In enforce mode, senders will refuse that host.
  • Changing id without changing the file, or the other way round. Senders either miss the change or never refetch.
  • Jumping straight to enforce with a long max_age. A mistake is then cached by senders for that long.
  • Removing the records to turn MTA-STS off. Senders keep using their cached policy until max_age expires. Publish mode: none with a new id first.
  • Forgetting the policy only protects inbound mail. MTA-STS on your domain protects mail sent to you. Your outbound TLS behavior depends on your sending servers.

Does MTA-STS affect SPF, DKIM or DMARC?

No. MTA-STS protects the transport of mail to your servers. SPF, DKIM and DMARC authenticate who sent a message. They solve different problems and you should run all of them.

Which senders honor MTA-STS?

Support depends on the sending server, and not every sender implements it. Your TLS-RPT reports are the most reliable answer for your own domain: each report names the organization that sent it and the policy it applied. Google publishes MTA-STS and TLS-RPT records for gmail.com itself, and Gmail's sender guidelines require that senders use TLS when delivering to Gmail.

Key takeaways

  • MTA-STS needs a _mta-sts TXT record with an id, and a policy file at https://mta-sts.<domain>/.well-known/mta-sts.txt with a valid certificate and no redirects.
  • Start in testing with a short max_age, read TLS-RPT reports, then move to enforce and raise max_age.
  • Every MX host must match an mx: pattern and present a valid certificate for its name.
  • Publish TLS-RPT at _smtp._tls.<domain> with v=TLSRPTv1; rua=....
  • Update the policy file before changing id, and retire with mode: none, not by deleting records.
  • Run the full domain scan to check MTA-STS, TLS-RPT and MX together with your DMARC record.

Validate your MTA-STS record, policy file and TLS-RPT setup with the free MTA-STS checker.

Check your domain now