b2KIT

MTA-STS Policy Generator

Generate MTA-STS policy files and DNS records to enforce TLS for incoming email connections.

Tested tool guide Tested browser tools Checked August 16, 2026

What MTA-STS Policy Generator does, with a checked example

MTA-STS is the inbound-mail equivalent of a 'no plaintext' sign on your front door: it tells other mail servers that connections to your domain's mail exchangers must be TLS-encrypted, and that unencrypted delivery should be refused rather than accepted. This generator produces the two artifacts the standard requires - the DNS TXT record under _mta-sts.yourdomain and the policy file that must be served over HTTPS from mta-sts.yourdomain. The usual surprise: it governs mail arriving at your domain, not mail you send.

Worked example

A concrete input and expected output from the current implementation.

Input

Domain: example.com. MX records: mail.example.com (priority 10), mx2.example.com (priority 20). Mode: enforce.

Expected output

DNS TXT record:
_mta-sts.example.com. 3600 IN TXT "v=STSv1; id=20260816000000"

Policy file, to be served at https://mta-sts.example.com/.well-known/mta-sts.txt:
version: STSv1
mode: enforce
mx: mail.example.com
mx: mx2.example.com
max_age: 604800

The TXT record carries the policy id that sending servers read first; the HTTPS file carries the actual rules. The mx lines must mirror the domain's MX hostnames exactly, and max_age of 604800 seconds (one week) tells senders how long to cache the policy. The id is tool-generated and should change whenever the policy content changes.

How the result is produced

1

Two artifacts, one contract

RFC 8461 couples a DNS TXT record with an HTTPS-hosted policy file. A sending server first reads the TXT record at _mta-sts.yourdomain, which carries the current policy id, then fetches the policy from https://mta-sts.yourdomain/.well-known/mta-sts.txt over a certificate-validated TLS connection. Only when both succeed does the policy take effect; any failure leaves the domain treated as if it had no policy.

2

What the policy commands

The file declares a mode (enforce, testing, or none), the mx hostnames senders may connect to, and max_age, the number of seconds senders cache the policy. In enforce mode, MTA-STS-aware senders refuse delivery unless the connection is TLS-protected and terminates at a listed mx host, closing the STARTTLS-downgrade hole where a mid-connection attacker could strip encryption.

Good uses

  • You host mail for a domain and want senders to stop accepting plaintext fallback when STARTTLS negotiation fails.
  • You are migrating a domain's mail to a new provider and want to observe TLS behavior in testing mode, with TLSRPT reports, before flipping to enforce.
  • Your domain's MX records point at a hosted service and you need the exact DNS record and policy file text to paste into registrar and web-hosting controls.

Limits and checks

  • The mx lines must mirror the hostnames in your MX records. In enforce mode, senders connect only to listed hosts, so a typo, a dropped host, or an IP address in the mx field can fail delivery outright rather than fall back to plaintext.
  • max_age is a promise about how long senders keep your policy; the ceiling is 31557600 seconds (one year). A long value locks in mistakes, and if the policy content changes without a fresh id in the TXT record, senders may keep applying the cached copy.
  • MTA-STS binds only senders that implement it and only after they have successfully fetched and validated your policy. It does not protect mail your own servers send, and a broken certificate or unreachable mta-sts host silently means 'no policy' rather than a warning.

Common questions

Does MTA-STS protect mail my domain sends?

No. The policy governs inbound delivery - connections other servers make to your MX records - and it is enforced by the sending side. Outbound mail from your own servers is outside its scope, and so is inbound mail to a domain that has not published a policy. If you want outbound protection, MTA-STS does not apply; other mechanisms would.

I set mode: enforce, but senders still deliver without TLS. Why?

Enforcement binds only senders that implement MTA-STS and have successfully fetched your policy over HTTPS with a valid certificate for mta-sts.yourdomain. Senders that cannot fetch the policy, that predate the standard, or that fail certificate validation simply deliver without it. Running mode: testing with TLSRPT reporting (RFC 8460) shows what senders would do before you enforce.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools