SMTP encryption between mail servers is normally opportunistic: if a server offers STARTTLS it is used, but an attacker in the middle can strip it and read the mail. MTA-STS (Mail Transfer Agent Strict Transport Security) lets you tell senders "only deliver to my MX servers over valid TLS". TLS-RPT sends you reports when that fails. This guide sets up both.
Before you start
- Your MX servers must support STARTTLS with a valid, publicly trusted certificate whose name matches the MX hostname.
- You need to host a small file over HTTPS on
mta-sts.yourdomain.com. - Access to your DNS zone.
How MTA-STS works
- A sending server sees your
_mta-stsTXT record. - It fetches your policy from
https://mta-sts.example.com/.well-known/mta-sts.txt. - It caches the policy and, in enforce mode, refuses to deliver unless the MX matches the policy and TLS is valid.
Create the policy file
Create mta-sts.txt (plain text, CRLF or LF line endings):
version: STSv1
mode: testing
mx: mail.example.com
mx: *.mailprovider.example
max_age: 86400- mode –
testing(report only),enforce, ornone(to retire the policy). - mx – one line per allowed MX host; wildcards match one label.
- max_age – how long senders cache it in seconds; start short, raise to weeks once stable.
Host the policy over HTTPS
- Create a subdomain
mta-sts.example.com(in cPanel: Domains → Domains → Create A New Domain) and make sure it has a valid SSL certificate (AutoSSL covers it). - Upload the file to
.well-known/mta-sts.txtin the subdomain's document root. - Check:
curl https://mta-sts.example.com/.well-known/mta-sts.txtreturns the file with no redirects.
Publish the DNS records
| Name | Type | Value |
|---|---|---|
_mta-sts.example.com | TXT | v=STSv1; id=20260101T000000 |
_smtp._tls.example.com | TXT | v=TLSRPTv1; rua=mailto:tlsrpt@example.com |
The id is any string that changes whenever you change the policy file – a timestamp works well.
Move from testing to enforce
- Run in
testingmode for a few weeks and read the TLS-RPT reports (JSON, often gzipped) sent to yourruaaddress. - Fix any MX certificate issues they reveal.
- Change
mode: enforce, raisemax_age(for example 604800 or more) and update theidin DNS.
Warning: In enforce mode, an expired MX certificate or a new MX host not listed in the policy means senders hold or bounce your mail. Update the policy before changing MX records, and monitor certificate expiry.
Troubleshooting
- Policy not found: the file must be served at the exact path over HTTPS with a valid certificate and no redirect.
- Reports show certificate errors: the MX certificate doesn't match the MX hostname or is self-signed.
- Changes ignored: you didn't update the
idin the TXT record.
FAQ: MTA-STS and TLS-RPT
Is MTA-STS the same as DANE?
Both enforce TLS for mail. DANE relies on DNSSEC and TLSA records; MTA-STS relies on HTTPS and the web PKI, which makes it easier to deploy without DNSSEC.
Does MTA-STS protect mail I send?
No. It protects mail sent to your domain by servers that support MTA-STS. Your outgoing mail follows the recipient's policy.
Do I need TLS-RPT?
It's optional but strongly recommended, because it shows delivery problems before you switch to enforce.
