Setting Up MTA-STS and TLS-RPT
MTA-STS (SMTP MTA Strict Transport Security) is an open standard that tells sending mail servers that your domain accepts mail only over an authenticated TLS connection. It protects incoming mail to your domain against downgrade and man-in-the-middle attacks, in which an attacker strips the TLS negotiation and the message is delivered in plain text.
Who configures itMTA-STS applies to mail that other servers deliver to your domain. The domain administrator sets it up at the mail hosting provider, the DNS provider, and the web server — there is no MTA-STS screen in a marketing platform, so do not look for one in the interface. Only mail servers that support MTA-STS enforce the policy; other servers keep delivering mail without the extra MTA-STS check.
MTA-STS and DMARC
MTA-STS and DMARC solve different problems and are configured independently. DMARC helps receiving servers detect email that uses your domain as a forged sender domain; MTA-STS protects the delivery of email to your domain against attacks on the TLS connection.
MTA-STS requires neither DMARC nor a specific DMARC policy. Sender authentication is set up separately — see Setting Up Email Domain Authentication.
What the Setup Consists Of
A working MTA-STS setup has four parts:
- A working web host on the
mta-sts.<yourdomain>subdomain, with a valid TLS certificate. - A policy file published over HTTPS at
https://mta-sts.<yourdomain>/.well-known/mta-sts.txt. - A
TXTrecord at_mta-sts.<yourdomain>that announces the policy and its version. - A
TXTrecord at_smtp._tls.<yourdomain>that asks reporting senders to send you TLS reports (TLS-RPT).
Your domain must also have MX records — MTA-STS describes how mail to those hosts must be delivered. If the domain has no mail hosting, set that up first.
Before you start, check that every MX host of your domain supports STARTTLS and uses a valid TLS certificate. If inbound mail passes through a third-party gateway, filtering service, or forwarder, ask its provider which MX hosts belong in the MTA-STS policy.
Setup Order
Publish the policy file before the DNS record that announces it. Once _mta-sts is published, sending servers start looking for the policy, so the file has to be in place and correct by then. The order below follows the recommendations of Google Workspace and Microsoft.
- Enable TLS reports.
- Create the
mta-stssubdomain and its hosting. - Publish the policy file in
testingmode and check it. - Publish the
_mta-stsDNS record. - Review the reports and switch to
enforce.
1. Enable TLS Reports (TLS-RPT)
TLS-RPT (RFC 8460) asks sending servers to report the outcome of TLS negotiation with your mail hosts. Enable it first, so the reports cover the whole testing period.
Add a TXT record:
| Field | Value |
|---|---|
| Host | _smtp._tls |
| Type | TXT |
| Value | v=TLSRPTv1; rua=mailto:[email protected] |
Reports arrive as daily aggregate files. They show which senders failed to establish a compliant connection and why.
Typical failure reasons in the reports:
- the MX host is not in the policy;
- the certificate has expired;
- the certificate was not issued for that MX host;
- the certificate chain is not trusted;
- STARTTLS is unavailable;
- the TLS negotiation failed.
Reports to an address in another domainIf the report address belongs to a different domain than the one being reported on, that domain has to confirm it agrees to receive the reports with an additional DNS record. The requirement is described in RFC 8460; a reporting service will tell you the exact record to add.
2. Create the mta-sts Subdomain
The policy file is served over HTTPS from a dedicated subdomain named mta-sts, so that subdomain has to exist as a working web host:
- Create an
A,AAAA, orCNAMErecord formta-sts.<yourdomain>pointing at the web server or hosted service that will serve the file. - Configure that server to serve the
/.well-known/path. - Issue a TLS certificate valid for
mta-sts.<yourdomain>.
Without these three steps the policy URL does not exist, and everything that follows fails.
3. Publish the Policy File
The policy file is a plain-text file served over HTTPS at:
https://mta-sts.<yourdomain>/.well-known/mta-sts.txt
Requirements for the file:
- It must be served over HTTPS with a valid certificate issued for
mta-sts.<yourdomain>. - It must be returned with the
text/plaincontent type. - Redirects to another host are not allowed.
File contents:
version: STSv1
mode: testing
mx: mail.yourdomain.com
mx: *.mailprovider.com
max_age: 604800version— alwaysSTSv1.mode— the policy mode, see below. Start withtesting.mx— one line per mail host allowed to receive mail for the domain. The values must match your MX records. Wildcards are allowed for the first label.max_age— how long, in seconds, a sending server may cache the policy. A week (604800) is a common starting value; a month (2592000) is typical for a stable policy.
Check the file as described in Verify before moving on.
4. Publish the DNS Record
Once the policy file is reachable and correct, announce it with a TXT record:
| Field | Value |
|---|---|
| Host | _mta-sts |
| Type | TXT |
| Value | v=STSv1; id=20260101000000 |
v— the version of the standard. AlwaysSTSv1.id— an identifier of the current policy version.
Change the id value every time you edit the policy file. Sending servers cache the policy and re-read the file only when the id changes.
According to RFC 8461, id is 1 to 32 characters long and contains only Latin letters and digits. It does not have to be a date — a timestamp is simply a convenient way to produce unique values.
5. Choose the Policy Mode
| Mode | What a sending server does |
|---|---|
none | The domain has no active policy. Used to withdraw a published policy without breaking caches. |
testing | The policy is evaluated but not enforced. Failures are reported and mail is still delivered. |
enforce | The policy is enforced. A message is not delivered if TLS or the host validation fails. |
Start with testing. Keep the policy in testing for at least several days, and for domains with low or irregular mail volume, several weeks. Switch to enforce only once the reports cover every significant source of inbound mail and show no systematic failures.
In enforce mode, errors in the mx list or in the TLS certificates of those hosts can delay or prevent delivery of incoming email. The exact caching and retrieval logic is defined by RFC 8461.
Verify
Check the policy file:
curl -I https://mta-sts.yourdomain.com/.well-known/mta-sts.txtThe response must be 200, with Content-Type: text/plain and no redirect. Then read the file itself and confirm the syntax is valid and the mx lines match your real MX records:
curl https://mta-sts.yourdomain.com/.well-known/mta-sts.txt
dig +short MX yourdomain.comCheck both TXT records, and repeat the query against a second resolver to confirm the records have propagated:
dig +short TXT _mta-sts.yourdomain.com
dig +short TXT _smtp._tls.yourdomain.com
dig +short TXT _mta-sts.yourdomain.com @1.1.1.1Confirm that every host listed in mx accepts STARTTLS with a valid certificate, and wait for the first TLS reports before switching the mode to enforce. An online MTA-STS validator is a useful extra check, but treat it as a second opinion rather than as proof that the setup is correct.
Repeat the check after any change to the domain's MX records — an outdated mx list in an enforced policy causes delivery failures for mail sent to your domain.
If Something Breaks After You Switch to enforce
- Change
mode: enforcetomode: testingin the policy file. - Publish the updated file.
- Change the
idin the_mta-stsDNS record so senders fetch the new version. - Read the TLS reports and fix the MX hosts or certificates.
Because of caching, the change does not take effect immediately. Don't delete the DNS record instead: senders can keep using the cached policy until max_age expires.
Changing Your MX Servers
Change the MX records and the policy together:
- Put the policy back into
testingmode and change itsid. - Add the new MX hosts to the policy file before you change DNS.
- Check their TLS certificates and STARTTLS.
- Change the domain's MX records.
- Read the TLS reports.
- Return to
enforceand update theidagain.
Account for the previous max_age: some senders may keep applying the cached policy until that period ends.
Related Articles
Updated about 3 hours ago
