# MTA-STS and TLS-RPT: enforcing TLS for inbound mail

> SPF and DMARC do not stop a message being read in transit. MTA-STS demands TLS from senders and TLS-RPT reports back. How to publish a policy safely.

## The gap this closes

SPF, DKIM and DMARC settle authenticity: who the message is from. None of them answers whether somebody read the message in transit. Encryption between mail servers exists, but by default it is optional: the sending server offers to switch to TLS, and if there is no answer it sends in the clear. That was done for compatibility, and it is exactly what an interceptor uses: remove the offer of encryption from the conversation and the message goes as it is.

MTA-STS lets a receiving domain declare that it is spoken to over TLS only, and only with a trusted certificate. A sender that understands the policy refuses to deliver insecurely instead of quietly lowering its protection.

## What MTA-STS consists of

The mechanism is described in RFC 8461 — a Proposed Standard published in September 2018, neither obsoleted nor updated. It requires two things at once: a DNS record and a file served over HTTPS.

The TXT record is placed with the name `_mta-sts` at the policy domain, so for `example.com` that is `_mta-sts.example.com`:

```
_mta-sts.example.com.  IN TXT "v=STSv1; id=20261203000000Z;"
```

The `id` field is the policy's version marker. Senders use it to tell that the policy changed, so it must be updated every time the file is edited.

The file itself lives at a fixed address — `https://mta-sts.example.com/.well-known/mta-sts.txt` — and is served only over HTTPS with a valid certificate for the name `mta-sts.example.com`:

```
version: STSv1
mode: enforce
mx: mail.example.com
mx: backupmx.example.com
max_age: 604800
```

## Three modes, and why the middle one matters

The standard defines three values for the `mode` field, and choosing between them is the risk management.

| Mode | What the sender does when TLS fails | When to use it |
| --- | --- | --- |
| `testing` | Delivers the message and reports the failure | The first weeks, while you reconcile the server list |
| `enforce` | Does not deliver the message | Once the reports are clean |
| `none` | Requires nothing | A correct way to withdraw a policy |

Starting at `enforce` is a bad idea. A mistake in the `mx` list or an expired certificate on the mail server means, in that mode, not a warning but undelivered mail — and you will hear about it from your customers.

## max\_age: how long the sender remembers

The `max_age` field is an integer number of seconds, and the standard caps it at 31557600. Senders cache the policy for that period, which is both the benefit and the risk.

The benefit: while the policy is cached, an interceptor cannot "withdraw" it, even by hijacking DNS. The risk: if you move to a different mail server, senders still remember the old list. So the order is a short period first (a day, say) while it settles in, then a week — the value 604800 in the example above — and only on a stable arrangement anything longer.

## TLS-RPT: why the reports matter

MTA-STS without reports is a policy whose behaviour you know nothing about. TLS-RPT is described in RFC 8460 (September 2018, not obsoleted) and is simpler: one TXT record with the name `_smtp._tls`.

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

Large providers will send daily summaries to that address: how many connections succeeded, how many failed and why — a name mismatch in the certificate, an expired certificate, a failed switch to TLS. This is the only way to see a problem before moving to `enforce`.

A separate mailbox for the reports is worth creating: there are not many of them, but they are machine-generated and get in the way of ordinary correspondence.

## A rollout order that does not lose mail

1. Check that every server in the `mx` list accepts TLS and that the certificate is issued for the name that appears in DNS.
2. Publish TLS-RPT and wait for the first reports.
3. Publish the policy in `testing` mode with a short `max_age`.
4. Read the reports for a couple of weeks. Failures usually turn up on a backup server somebody forgot about.
5. Move to `enforce` and raise `max_age`.

```
dig +short TXT _mta-sts.example.com
dig +short TXT _smtp._tls.example.com
curl -sS https://mta-sts.example.com/.well-known/mta-sts.txt
echo | openssl s_client -starttls smtp -connect mail.example.com:25 \
  -servername mail.example.com 2>/dev/null | openssl x509 -noout -subject -dates
```

## What MTA-STS does not do

It concerns only the mail sent to you, and only senders that support the mechanism. It does not encrypt a message on disk and does not stop it being read on the server itself. It does not replace SPF, DKIM and DMARC: those answer for authenticity, this one for the channel. And it does not protect outbound mail — there the requirements are set by the receiving side.

## What sits next to this

Message authenticity and the path to `p=reject` are in [DMARC and the Gmail requirements](https://www.zevshost.net/en/kb/dmarc-reject-rassylki-gmail/). Binding a certificate to the DNS zone, which solves the same problem another way, is [TLSA and DANE](https://www.zevshost.net/en/kb/tlsa-dane-dns/). A mail server of your own, end to end, is [Mailcow in containers](https://www.zevshost.net/en/kb/mailcow-svoy-pochtovyy-server/).

---

Source: https://www.zevshost.net/en/kb/mta-sts-tls-rpt-pochta/
Updated: 2026-12-03
