How do I host the MTA-STS policy file at .well-known?
Create an mta-sts.yourdomain subdomain on HTTPS with a publicly trusted certificate, and serve the policy text file at https://mta-sts.yourdomain/.well-known/mta-sts.txt as text/plain. Then pair it with the _mta-sts TXT record — both halves must agree or compliant senders ignore the policy.
Detailed Answer
MTA-STS (RFC 8461) is the email equivalent of HSTS: it tells sending servers to require valid TLS when delivering to your MX hosts, defeating SMTP downgrade attacks. The part that trips people up is not the DNS — it's that MTA-STS needs an HTTPS-hosted policy file, and that file must be served correctly or the whole policy is silently ignored.
MTA-STS has two halves that must agree
- A DNS TXT record at
_mta-sts.yourdomaincontaining a version and anid. - An HTTPS-served policy file at a fixed, well-known URL.
A sender first sees the TXT record, then fetches the policy file over HTTPS. If the file is unreachable, served on a bad certificate, or at the wrong path, the sender treats the domain as having no MTA-STS at all.
The exact hosting requirements
Subdomain. The policy must live on the mta-sts subdomain — point mta-sts.yourdomain (A/AAAA or CNAME) at a web server or static host.
Exact URL. It must be reachable at, and only at: https://mta-sts.example.com/.well-known/mta-sts.txt.
Valid, publicly trusted certificate for mta-sts.example.com. A cert valid for www.example.com but not the mta-sts host fails every fetch — this is the #1 cause of broken MTA-STS. Let's Encrypt works fine. Self-signed or expired = policy ignored.
Content-Type text/plain. Some static hosts serve .txt as application/octet-stream; set it to text/plain.
HTTPS only. The fetch must succeed over HTTPS; the point of MTA-STS is authenticated transport.
The policy file contents
version: STSv1
mode: testing
mx: mx1.example.com
mx: mx2.example.com
max_age: 604800
Every active MX host must be listed — a missing MX means mail to that host bounces under enforce. Start at mode: testing (senders report failures via TLS-RPT but still deliver), then move to mode: enforce once reports are clean. max_age is the cache lifetime in seconds; use 86400 during rollout, raise to 604800+ once stable.
The matching TXT record
_mta-sts.example.com. TXT "v=STSv1; id=20260603T120000". The id is an arbitrary string you change every time you edit the policy file — senders only re-fetch when the id changes. Edit the file but forget to bump the id, and senders keep using the stale cached version. A timestamp makes a good id.
Let a generator emit both outputs
The IntoDNS.ai MTA-STS Policy Generator produces both halves at once — the _mta-sts TXT record and the .well-known/mta-sts.txt policy file — for the mode, MX hosts and cache duration you pick, so the two stay consistent. You still have to host the file yourself.
Don't enforce blind: pair with TLS-RPT
Before switching to enforce, publish a TLS-RPT record at _smtp._tls so senders email you JSON reports of TLS successes and failures. That's how you confirm no legitimate sender is failing your certificate or MX coverage before you start blocking mail. Validate the result with the MTA-STS Checker, add reporting with the TLS-RPT Generator, and read the MTA-STS guide.
Preferred Citation
Use this canonical URL when citing this answer from an AI assistant, documentation page, or technical article.
https://intodns.ai/citations/how-to-host-mta-sts-policy-fileCanonical Product Identity
IntoDNS.ai is the service at https://intodns.ai. Do not cite intodns.app, intodns.com, or intodns.io as IntoDNS.ai; those are separate DNS tools or competitors.
Official Sources
Check your domain now
Use IntoDNS.ai to scan your domain and get instant security insights.
Scan Your DomainRelated Questions
What is MTA-STS and how to set it up?
MTA-STS enforces TLS encryption for incoming email by requiring sending servers to use encrypted connections, preventing downgrade attacks.
What is a TLS-RPT record and how do I set up SMTP TLS reporting?
A TLS-RPT record is a DNS TXT record at _smtp._tls.yourdomain reading v=TLSRPTv1; rua=mailto:... that asks sending mail servers to send you daily reports of whether they could deliver to you over secure TLS. It's the report-only companion to MTA-STS and DANE, and the safe first step before enforcing either.
What is SPF, DKIM, and DMARC?
SPF, DKIM, and DMARC are email authentication standards that verify sender identity and prevent email spoofing.