What Is MTA-STS?
MTA-STS (Mail Transfer Agent Strict Transport Security) is an email security standard that allows you to declare that your mail servers support TLS and require sending servers to use it. It prevents downgrade attacks, where an attacker intercepts an email connection and strips TLS negotiation so the message is sent unencrypted.
Without MTA-STS, most email connections use STARTTLS — an opportunistic TLS upgrade. If either end does not support TLS, or if an attacker interferes with the TLS handshake, the connection falls back to plain text. MTA-STS closes this gap by telling sending servers: "If you cannot connect to us with valid TLS, do not send the message."
MTA-STS vs. STARTTLS
- STARTTLS
- Opportunistic TLS. Encrypts if both ends support it, but falls back to plain text if TLS fails. Vulnerable to downgrade attacks.
- MTA-STS
- Enforced TLS. Sending servers check the MTA-STS policy before connecting. If TLS cannot be established to your mail servers, they refuse to deliver rather than send unencrypted.
What MTA-STS Does Not Do
MTA-STS only protects inbound email delivery to your domain. It does not protect outbound email your servers send, nor does it authenticate the content or sender of messages. For sender authentication, see our guide on what DMARC does.
What You Need
Implementing MTA-STS requires:
- A subdomain
mta-sts.yourdomain.comwith a valid HTTPS certificate - A web server or hosting capable of serving a text file at a specific path
- Access to your DNS to publish two TXT records
- Your mail server hostnames (the values in your MX records)
Step 1: Create the MTA-STS Policy File
The policy file is a plain text file that specifies your MTA-STS mode and the mail server hostnames you require TLS for. Create a file with this format:
version: STSv1
mode: enforce
mx: mail1.yourdomain.com
mx: mail2.yourdomain.com
max_age: 86400
Policy File Fields
version: STSv1- Required. Identifies this as an MTA-STS policy file.
mode:- Required.
enforcerequires TLS; sending servers reject delivery if TLS fails.testingcollects reports without enforcement.nonedisables the policy. Start withtesting. mx:- One entry per line for each mail server hostname that accepting servers must be able to connect to with TLS. These must match your MX records exactly (not IP addresses).
max_age:- How long (in seconds) sending servers may cache this policy.
86400= 24 hours. Use a low value while testing; increase to604800(1 week) or2592000(30 days) in enforce mode.
For Microsoft 365, the MX hostnames look like yourdomain-com.mail.protection.outlook.com. For Google Workspace, they follow the pattern aspmx.l.google.com, alt1.aspmx.l.google.com, etc. Use all the hostnames from your actual MX records.
Example policy for a Google Workspace domain:
version: STSv1
mode: testing
mx: aspmx.l.google.com
mx: alt1.aspmx.l.google.com
mx: alt2.aspmx.l.google.com
mx: alt3.aspmx.l.google.com
mx: alt4.aspmx.l.google.com
max_age: 86400
Step 2: Host the Policy File at the Well-Known URL
The policy file must be accessible at exactly this URL:
https://mta-sts.yourdomain.com/.well-known/mta-sts.txt
Requirements for the hosting:
- Must be HTTPS with a valid, non-expired TLS certificate for
mta-sts.yourdomain.com - Must return HTTP 200 (not a redirect)
- Content-Type should be
text/plain - The file must not require authentication
You need to create a DNS entry for mta-sts.yourdomain.com pointing to a web server, and obtain a TLS certificate for that subdomain. Any web hosting, CDN, or static file hosting that supports custom subdomains and HTTPS will work (Cloudflare Pages, GitHub Pages with a custom domain, Netlify, your own web server).
Step 3: Publish the MTA-STS DNS Record
Create a TXT record at _mta-sts.yourdomain.com:
v=STSv1; id=20261124000000
The id is a unique identifier for the current version of your policy. Use a timestamp in the format YYYYMMDDHHMMSS. Whenever you update the policy file, change the id so sending servers know to fetch the new policy rather than using their cached version.
max_age. If you update the policy file without changing the DNS id, servers will continue using the old cached version.
Step 4: Publish the TLS-RPT DNS Record
TLS-RPT (TLS Reporting) is a companion standard that requests TLS delivery failure reports from sending mail servers. Publish a TXT record at _smtp._tls.yourdomain.com:
v=TLSRPTv1; rua=mailto:tls-reports@yourdomain.com
Replace the rua address with a mailbox you monitor. When sending servers encounter TLS failures delivering to your domain, they will send JSON reports to this address. These reports are most useful during the testing phase to identify any mail servers that have TLS issues before you switch to enforce mode.
Verifying Your MTA-STS Setup
After publishing the DNS records and hosting the policy file, verify everything is correct:
- Check the DNS record: query
_mta-sts.yourdomain.comfor TXT records - Fetch the policy file: load
https://mta-sts.yourdomain.com/.well-known/mta-sts.txtin a browser - Verify the TLS certificate is valid for the
mta-sts.subdomain - Wait for TLS-RPT reports to arrive — allow 24–48 hours
Allow 24–48 hours for DNS propagation before testing.
Moving from testing to enforce
After running in mode: testing for 1–2 weeks with no TLS-RPT failures, switch to enforce mode:
- Update the policy file: change
mode: testingtomode: enforce - Increase
max_ageto604800(1 week) or2592000(30 days) - Update the
idin the DNS record to a new timestamp
In enforce mode, sending servers that cannot establish valid TLS connections to your MX hosts will refuse to deliver rather than send unencrypted. Continue monitoring TLS-RPT reports for any new failures.
Complete Your Email Security Stack
MTA-STS protects inbound delivery. DMARC protects your domain from spoofing. Your DMARC Exposed monitors your DMARC aggregate reports so you can reach p=reject and complete your email authentication setup.
Start Your Free Trial What Is DMARC?Frequently Asked Questions
What is MTA-STS?
MTA-STS (Mail Transfer Agent Strict Transport Security) is an email security standard that allows domain owners to declare that their mail servers support TLS and require sending servers to use it. It prevents downgrade attacks where an attacker strips TLS encryption from an email connection.
Does MTA-STS affect outbound email?
No. MTA-STS only applies to inbound email delivery to your domain. It tells sending servers how to handle TLS when connecting to your mail servers. It has no effect on email your domain sends to others. For outbound email authentication, see DMARC, SPF, and DKIM.
What is TLS-RPT?
TLS-RPT (TLS Reporting) is a companion standard to MTA-STS. It requests that sending mail servers report TLS delivery failures to a specified address. Reports are JSON files showing which servers failed to establish TLS connections when delivering to your domain. TLS-RPT is valuable during the testing phase for identifying issues before switching to enforce mode.
What happens if I set mode: enforce and a sending server cannot use TLS?
The sending server will reject the delivery attempt and return a bounce to the original sender. The message will not be delivered unencrypted. The sending server should also send a TLS-RPT failure report to your rua address if TLS-RPT is configured. This is why starting with mode: testing to identify any delivery issues first is important.