ENCRYPT INBOUND MAIL

MTA-STS setup: the _mta-sts record, the policy file, testing and enforce modes, and TLS-RPT reports

Mail servers fall back to plaintext when TLS is missing or broken, and an attacker on the path can force that fallback. MTA-STS lets your domain publish a rule that sending servers must use TLS with a valid certificate. This guide covers the TXT record, the policy file, the move from testing to enforce, TLS-RPT reports and the mistakes that break delivery.

Concept illustration of an ivory ceramic envelope on a copper rail heading into a translucent glass tunnel glowing mint, beside an ivory pedestal holding a folded card with a copper clip, while a branching side track ends at a closed copper gate.
Concept illustration

Email between mail servers travels over SMTP, a protocol designed long before encryption was common. STARTTLS added encryption later, but only opportunistically: if the receiving server does not offer TLS, or the TLS handshake fails, most sending servers simply deliver the message in plaintext. They also rarely check whether the certificate they receive belongs to the server they meant to reach. Someone positioned on the network path can exploit both habits to read or alter mail addressed to your domain.

MTA-STS, defined in RFC 8461, lets a receiving domain publish a simple rule: my mail servers support TLS with valid certificates, so do not deliver to me any other way. It consists of a DNS TXT record at _mta-sts.example.com and a policy file served over HTTPS at mta-sts.example.com. Its companion, SMTP TLS Reporting (TLS-RPT, RFC 8460), asks sending servers to send you daily reports about successful and failed TLS connections, so you can see problems before you enforce anything.

This guide walks through the full setup with example.com: prerequisites, the policy file, hosting, the TXT record, TLS-RPT, the move from testing to enforce mode, safe changes and removal, the common mistakes and how to verify each piece. It also explains the Sitelemetry finding dns.email.mta-sts.missing and what that check does and does not cover.

Scope of this guide

This guide covers inbound mail to domains you own and what is visible in public DNS and HTTPS. Automated checks cannot see how individual senders apply your policy; TLS-RPT reports show that. Sitelemetry is not a pentest or a compliance attestation.

1. What MTA-STS protects against

When a server delivers mail to you@example.com, it looks up the MX records of example.com, connects to one of those hosts on port 25 and, if the host advertises the STARTTLS extension described in RFC 3207, upgrades the connection to TLS. Two weaknesses follow from the opportunistic design:

  • Downgrade. The STARTTLS offer is sent in plaintext. An attacker on the path can remove it from the server's EHLO response or break the handshake, and a typical sender then falls back to unencrypted delivery.
  • No authentication. Without a policy, senders usually accept any certificate, including self-signed or mismatched ones, because refusing would bounce too much legitimate mail. A connection redirected to an impostor server can therefore still look encrypted.

MTA-STS changes the rules for senders that implement it. The sender fetches your policy over HTTPS, where the ordinary web PKI authenticates it, and caches it. While the policy is in enforce mode, the sender delivers only to MX hosts whose names match the patterns in the policy, only over TLS, and only when the host presents a valid certificate for its MX hostname. If none of your MX hosts passes, the message is not delivered to an unverified host; it stays queued for retry.

Keep the limits in mind:

  • It protects inbound mail to your domain, and only from sending servers that support RFC 8461. Whether your own outbound server honours other domains' policies is a separate setting in your mail software or provider.
  • It is trust on first use: a sender that has never cached your policy can be blocked from fetching it. A long max_age reduces that window for returning senders.
  • It encrypts the hop between mail servers. It is not end-to-end encryption, and it does not stop spoofing of your domain; that is the job of SPF, DKIM and DMARC.
  • DANE for SMTP (RFC 7672) solves the same problem with TLSA records, but requires DNSSEC on your zone. The two can be deployed side by side.

2. Prerequisites and the four pieces you publish

Before you write a policy, confirm that every MX host can pass an enforce-mode check. For each hostname returned by dig +short MX example.com, the host must:

  • offer STARTTLS on port 25;
  • present a certificate from a publicly trusted certificate authority, with the complete chain;
  • have the MX hostname itself, exactly as it appears in the MX record, in the certificate;
  • renew that certificate before it expires, ideally automatically.

Hosted mailbox providers manage their MX certificates for you. Self-hosted servers are where problems hide: a Postfix or Exim server with a self-signed certificate, or a certificate issued for host1.provider.net while the MX record says mail.example.com, works today with opportunistic TLS but fails once you enforce.

The full setup consists of four DNS or HTTPS objects:

PieceLocationExample contentRole
MX recordsexample.com10 mx1.example.com.Already exist; the policy must list these hosts
Policy filehttps://mta-sts.example.com/.well-known/mta-sts.txtversion, mode, mx, max_age linesThe rules senders apply
Discovery TXT record_mta-sts.example.comv=STSv1; id=20260115T1200;Announces that a policy exists and which version is current
TLS-RPT TXT record_smtp._tls.example.comv=TLSRPTv1; rua=mailto:tls-reports@example.comTells senders where to send daily TLS reports

Note the two different names: the TXT record lives at _mta-sts with an underscore, while the policy is served from the host mta-sts without one.

3. Write the policy file

The policy is a short plain-text file of key/value pairs, one per line. RFC 8461 specifies CRLF line endings, so save it that way to avoid surprises with strict parsers. A first version in testing mode looks like this:

version: STSv1
mode: testing
mx: mx1.example.com
mx: mx2.example.com
max_age: 86400
  • version must be STSv1.
  • mode is testing, enforce or none (section 7 explains each).
  • mx appears once per allowed MX pattern. List every host your MX records can point to, including backup MX hosts. A wildcard is allowed only as the left-most label: *.mail.example.net matches in1.mail.example.net but not mail.example.net itself and not a.b.mail.example.net. If your provider uses both a bare name and numbered siblings, list both forms.
  • max_age is how many seconds senders may cache the policy, up to a maximum of 31557600 (about one year). RFC 8461 expects values in the range of weeks or more for real protection, because the cached copy is what defends against an attacker who blocks later policy fetches. Start short while testing.

Copy MX hostnames from your live DNS, not from memory or an old onboarding email. Your mail provider's documentation is the right place to confirm which hostnames and wildcard patterns it supports.

4. Host the policy at mta-sts.<domain>

Senders fetch exactly https://mta-sts.example.com/.well-known/mta-sts.txt. The response has to meet four conditions:

  • Valid HTTPS. A publicly trusted certificate that covers mta-sts.example.com. A wildcard certificate for *.example.com covers it; a certificate for www.example.com only does not.
  • Status 200. RFC 8461 says senders must not follow HTTP redirects, so a 301 to another host or path counts as a failed fetch. A redirect on port 80 is harmless because senders never use plain HTTP for the policy.
  • Content type text/plain.
  • A DNS record for the host. An A, AAAA or CNAME record for mta-sts.example.com.

On nginx, a dedicated server block keeps the policy host isolated from the main site:

server {
    listen 443 ssl;
    server_name mta-sts.example.com;
    ssl_certificate     /etc/ssl/mta-sts.example.com/fullchain.pem;
    ssl_certificate_key /etc/ssl/mta-sts.example.com/privkey.pem;

    location = /.well-known/mta-sts.txt {
        root /var/www/mta-sts;
        default_type text/plain;
    }

    location / {
        return 404;
    }
}

The file then lives at /var/www/mta-sts/.well-known/mta-sts.txt. Static hosting services and CDNs work too, as long as they serve the custom domain over HTTPS without redirecting the path. Some static site generators skip folders whose names start with a dot, so confirm that .well-known was actually published rather than assuming it. If a hosted MTA-STS service runs the file for you, you typically point mta-sts.example.com at it with a CNAME; follow that service's documentation.

5. Publish the _mta-sts TXT record

The discovery record tells senders that a policy exists and identifies its version:

_mta-sts.example.com.   3600 IN TXT "v=STSv1; id=20260115T1200;"
mta-sts.example.com.    3600 IN A   192.0.2.10
  • The value must start with v=STSv1.
  • The id is 1 to 32 letters and digits only. A timestamp such as 20260115T1200 is a convenient habit; 2026-01-15 is invalid because of the hyphens.
  • Publish exactly one TXT record starting with v=STSv1 at that name. If senders find more than one, RFC 8461 tells them to treat the domain as having no policy.
  • Every time you change the policy file, change the id. Senders that have a cached policy compare the id to decide whether to fetch a new copy; an unchanged id means they may keep using the old policy until it expires.

In DNS dashboards that ask for a host name and add the zone automatically, enter _mta-sts rather than the full name, otherwise you may end up with _mta-sts.example.com.example.com.

6. Add TLS-RPT reporting

TLS-RPT, defined in RFC 8460, is what makes a safe rollout possible. Publish one more TXT record:

_smtp._tls.example.com. 3600 IN TXT "v=TLSRPTv1; rua=mailto:tls-reports@example.com"

The rua value can be a mailto: address or an https: endpoint, and you can list more than one separated by commas. Participating senders send a report covering a period of usually one day, as JSON, normally compressed with gzip. Each report counts successful and failed TLS sessions per policy and, for failures, names the reason with result types such as:

  • starttls-not-supported: the MX host did not offer STARTTLS;
  • certificate-host-mismatch, certificate-expired, certificate-not-trusted: the MX certificate would fail validation;
  • sts-policy-fetch-error, sts-policy-invalid, sts-webpki-invalid: the sender could not fetch or parse your policy, or the policy host's certificate was not valid.

Use a dedicated mailbox or a report-processing service rather than a personal inbox; reports arrive daily from each participating sender. TLS-RPT also covers DANE, so the same record serves both if you deploy DANE later.

7. From testing to enforce, and how to change or remove a policy

ModeWhat a supporting sender does when validation failsWhen to use it
testingDelivers anyway and reports the failure through TLS-RPTFirst deployment and after major mail changes
enforceDoes not deliver to hosts that fail; tries other matching MX hosts, otherwise keeps the message queuedOnce reports show clean results for your MX hosts
noneTreats the domain as having no active policyRemoving MTA-STS cleanly

A calm rollout looks like this:

  1. Publish the policy in testing with a short max_age such as 86400, plus the TLS-RPT record.
  2. Read the reports for a couple of weeks. Every failure type pointing at your MX hosts or your policy host needs a fix before you go further.
  3. Switch to mode: enforce, raise max_age (for example 604800, later 1209600 or more), and change the id in the TXT record.
  4. Keep reading reports. Certificate expiry on an MX host now delays mail from supporting senders instead of silently downgrading it.

Order of operations for any change: update the policy file first, then the id. If you change the id first, a sender may fetch the old file, cache it under the new id and keep it.

Changing mail providers is the classic way to break an enforced policy. Add the new provider's MX patterns to the policy alongside the old ones, bump the id, and wait at least the previous max_age before you switch the MX records. Remove the old patterns afterwards.

Removing MTA-STS: publish mode: none with a new id, keep the file and record online for at least the longest max_age you ever published, then delete them. Deleting everything at once leaves cached enforce policies in place at senders until they expire.

8. Common mistakes and their symptoms

MistakeSymptomFix
TXT record at mta-sts instead of _mta-stsSenders and checkers find no policyMove the record to _mta-sts.example.com
Two v=STSv1 TXT recordsPolicy ignored entirelyKeep exactly one record
Hyphens or dots in idRecord rejected as invalidLetters and digits only, 32 characters at most
Policy URL redirectssts-policy-fetch-error in reportsServe the file directly with status 200
No certificate for mta-sts.example.comsts-webpki-invalid in reportsIssue a certificate covering that host
Wildcard expected to match the bare name*.mail.example.net fails for mail.example.netList the bare name as its own mx line
File edited, id unchangedSenders keep the old cached policyChange the id after every edit
Self-signed or mismatched MX certificatecertificate-not-trusted or certificate-host-mismatchPublicly trusted certificate naming the MX hostname
MX provider switched under an enforce policyMail from supporting senders queues or bouncesAdd new patterns first, wait max_age, then switch

Most of these show up as named failure types in TLS-RPT reports, which is why the record is worth publishing even before the policy.

9. How to verify every piece

Run these checks from a terminal against your own domain:

dig +short MX example.com
dig +short TXT _mta-sts.example.com
dig +short TXT _smtp._tls.example.com
curl -sS -D - https://mta-sts.example.com/.well-known/mta-sts.txt
  • The MX output gives the hostnames your mx lines must match.
  • The _mta-sts query should return a single record starting with v=STSv1 and a valid id.
  • The curl output should show status 200, content-type: text/plain, no location header and the policy body. Because curl validates certificates by default, a certificate problem on the policy host shows up as an error here.

To check an MX host's certificate the way an enforcing sender would, use openssl s_client:

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

A clean run reports a verified connection; a hostname or chain problem ends with a verification error. Many home and cloud networks block outbound port 25, so run this from a host that is allowed to make SMTP connections, or rely on TLS-RPT reports. Finally, send a test message from an external mailbox and confirm delivery, then watch the next day's TLS-RPT reports for your policy.

10. What Sitelemetry checks for MTA-STS

The dns-email security module looks up the MX records and the _mta-sts TXT record of the exact hostname you scan. When that hostname has MX records and no TXT record starting with v=STSv1 is observed, it reports dns.email.mta-sts.missing: severity low, confidence medium, target _mta-sts.<domain>, with the evidence “no v=STSv1 in the _mta-sts TXT record” and a remediation that points to the TXT record, the policy file at https://mta-sts.<domain>/.well-known/mta-sts.txt and TLS-RPT. A domain without MX records does not get this finding. Scan the mail domain itself, such as example.com; a host such as www.example.com usually has no MX records, so the check does not apply to it. The scanned name must also resolve to an address: if it has no A or AAAA record, as on some mail-only domains, the scan stops at the DNS step with dns.resolve.failed and this check does not run, so verify the records with the steps in section 9.

The finding is about the discovery record. Confirm the policy file, its mode, the mx patterns, your MX certificates and the TLS-RPT record with the steps in section 9. The same module also reports on SPF, DMARC and CAA records; the CAA record guide and the DNS and email security guide cover those, and the TLS guide covers certificates on the web side. The SPF and DMARC check guide shows how to look up these records yourself.

The check is passive and runs in every scan profile on every plan: Free ($0), Starter ($49/month), Professional ($149/month) and Enterprise ($249/month); see pricing. It needs no ownership verification by itself: the free Launch Readiness Snapshot and a Free account's security audit of an unverified site both run it, while a default security audit on a paid plan also runs checks that need a verified target. You can also try the free SPF and DMARC checker. Sitelemetry is an automated audit tool, not a penetration test or a compliance attestation.

Common questions

What is the MTA-STS record?

It is a DNS TXT record at _mta-sts.yourdomain, for example "v=STSv1; id=20260115T1200;". It tells sending servers that a policy exists and which version is current. The rules themselves live in the policy file at https://mta-sts.yourdomain/.well-known/mta-sts.txt, and you change the id every time that file changes.

Does MTA-STS protect the email I send?

No. Your MTA-STS policy protects mail that other servers deliver to your domain. Whether your outgoing mail respects other domains' MTA-STS policies depends on your own mail server or provider supporting RFC 8461 as a sender.

Do I still need MTA-STS if I use a hosted mail provider?

The provider manages the MX servers and their certificates, but the policy belongs to your domain, so you publish the TXT record, the policy file and ideally the TLS-RPT record yourself or through a hosted service. Take the exact mx hostnames or patterns from your provider's documentation and your live MX records.

What max_age should I use?

Use a short value such as 86400 seconds while in testing mode. For enforce mode, RFC 8461 expects values of weeks or more, up to a maximum of 31557600 seconds, because the cached policy is what protects returning senders if an attacker blocks a later policy fetch. Remember that a long max_age also delays removal and provider changes.

What is the difference between MTA-STS and DANE?

Both require senders to use authenticated TLS to your MX hosts. DANE publishes certificate information in TLSA records and depends on DNSSEC. MTA-STS uses an HTTPS-hosted policy and the web PKI, so it works without DNSSEC but relies on trust on first use. You can deploy both, and TLS-RPT reports cover both.

Sources & further reading

  1. RFC 8461: SMTP MTA Strict Transport Security (MTA-STS)www.rfc-editor.org
  2. RFC 8460: SMTP TLS Reportingwww.rfc-editor.org
  3. RFC 3207: SMTP Service Extension for Secure SMTP over TLS (STARTTLS)www.rfc-editor.org
  4. RFC 7672: SMTP Security via Opportunistic DANE TLSwww.rfc-editor.org
  5. Google Workspace Help: About MTA-STS and TLS reportingknowledge.workspace.google.com
  6. OpenSSL documentation: openssl-s_clientdocs.openssl.org
Sitelemetry team

Prepared by the Sitelemetry editorial team. Explore the linked sources for further detail.

SITELEMETRY

Put what you learned to work.

Explore your website’s structure, settings and signals with Sitelemetry.