How to set up MTA-STS

Make other servers use encryption with a valid certificate when they deliver mail to you. The record, the policy file and the rollout.

When another server delivers mail to you, it usually encrypts the connection with STARTTLS. But encryption is optional by default: an attacker in the middle can strip it, or present a fake certificate, and the sender falls back to plain text. MTA-STS (RFC 8461) lets you publish that your mail servers always support TLS with a valid certificate, so senders refuse to deliver otherwise.

What you publish

  1. A TXT record announcing the policy and its version:
    _mta-sts.example.com.  TXT  "v=STSv1; id=20261001"
  2. A policy file at exactly https://mta-sts.example.com/.well-known/mta-sts.txt, served as text/plain with a valid HTTPS certificate:
    version: STSv1
    mode: testing
    mx: mx1.example.com
    mx: *.mail.protection.outlook.com
    max_age: 604800
  • mx: lists every MX host, as they appear in your MX records. Wildcards cover one label. A missing MX host becomes undeliverable in enforce mode.
  • mode: testing (report problems, deliver anyway), enforce (refuse insecure delivery) or none (switch off).
  • max_age: how long senders cache the policy, in seconds. Use at least a week; up to a year (31557600) once stable.
  • id in the TXT record must change every time you change the policy file, or senders keep using their cached copy.

Rolling it out

  1. Publish a TLS-RPT record first, so you receive reports about failed deliveries.
  2. Publish the policy in mode: testing and read the TLS reports for a couple of weeks.
  3. When the reports are clean, switch to mode: enforce and update the id.
  4. Keep the certificate of mta-sts.example.com renewed. If it expires, senders can't refresh the policy.

The mta-sts host only needs to serve this one small file. Any static hosting with a valid certificate will do.