NetSecTools

Home / Guides / How to Configure MTA-STS and TLS-RPT to Enforce SMTP Encryption

How to Configure MTA-STS and TLS-RPT to Enforce SMTP Encryption

ยท 7 min read

Most mail servers support STARTTLS, which upgrades a plain SMTP connection to TLS after the servers say hello. The catch is that STARTTLS is opportunistic by default. If an active network attacker strips the STARTTLS line from the greetingโ€”or presents an invalid or rogue certificateโ€”the sending server typically falls back to unencrypted delivery or accepts the untrusted certificate without failing.

MTA-STS (Mail Transfer Agent Strict Transport Security, RFC 8461) closes that gap. It lets a domain publish a signed-over-HTTPS policy telling sending mail servers which MX hostnames are valid and requiring a trusted, non-expired TLS certificate before any email is transmitted. Paired with TLS-RPT (RFC 8460), you receive daily JSON reports whenever a sender encounters a TLS failure.

Before setting up MTA-STS, make sure your core authentication records (SPF, DKIM and DMARC) are already in place with our Email Security Checker and DKIM Selector Lookup.

How MTA-STS prevents SMTP downgrade attacks

Without MTA-STS, DNS MX lookups are unauthenticated unless DNSSEC is deployed everywhere, and opportunistic STARTTLS cannot distinguish between a server that genuinely lacks TLS and an attacker stripping encryption.

When a sending server supports MTA-STS, it follows three rules:

  1. Look up _mta-sts.<domain> via DNS TXT to check whether the domain publishes a policy and read its id=.
  2. Fetch https://mta-sts.<domain>/.well-known/mta-sts.txt over HTTPS with strict certificate validation and cache the policy for max_age seconds.
  3. Verify that the receiving MX serverโ€™s hostname matches one of the mx: lines in the policy and presents a valid TLS certificate covering that hostname. In enforce mode, delivery is aborted or deferred instead of falling back to plain text.

Step 1: Publish the _mta-sts DNS TXT record

Create a TXT record on the _mta-sts subdomain of your mail domain (for example, _mta-sts.example.com):

Host:  _mta-sts
Type:  TXT
Value: v=STSv1; id=20261205T01

Key rules for the DNS record:

  • v=STSv1 is required and case-sensitive.
  • id= must be 1 to 32 alphanumeric characters (A-Z, a-z, 0-9). Do not use hyphens or underscores.
  • Whenever you update mta-sts.txt, change the id= value (for example, increment a timestamp such as 20261205T02). Sending MTAs use a changed id= as the signal to re-fetch your policy before max_age expires.
  • Publish only one v=STSv1 TXT record per domain.

Step 2: Host /.well-known/mta-sts.txt over HTTPS

Next, set up a web endpoint at https://mta-sts.example.com/.well-known/mta-sts.txt with a valid TLS certificate for mta-sts.example.com.

Start in testing mode so you can collect failure reports without risking bounced mail:

version: STSv1
mode: testing
mx: mail1.example.com
mx: *.mail.protection.outlook.com
max_age: 604800

Pay close attention to the RFC 8461 requirements for this file:

  • No HTTP redirects: https://mta-sts.example.com/.well-known/mta-sts.txt must return HTTP 200 directly with Content-Type: text/plain. Redirects (301/302) are explicitly forbidden by RFC 8461 and cause compliant MTAs to treat the policy fetch as failed.
  • Exact mx: patterns: Every MX host returned by your domainโ€™s MX records must match an mx: line. Wildcards are permitted only on the leftmost label (for example *.google.com or *.mail.protection.outlook.com).
  • Reasonable max_age: Set max_age in seconds. 86400 is 1 day, 604800 is 7 days and 1209600 is 14 days. Keep it at a day or two while testing, then raise it to at least one week once enforced.

Step 3: Enable TLS-RPT (_smtp._tls)

Before switching mode: testing to mode: enforce, publish a TLS-RPT TXT record at _smtp._tls.example.com:

Host:  _smtp._tls
Type:  TXT
Value: v=TLSRPTv1; rua=mailto:[email protected]

You can also specify an HTTPS collector endpoint or list multiple destinations separated by commas:

v=TLSRPTv1; rua=mailto:[email protected],https://reports.example.com/v1/tlsrpt

Wait at least one to two weeks and monitor incoming reports for certificate mismatches, expired certs on backup MX hosts, or missing mx: entries. Once the reports are clean, update mta-sts.txt to mode: enforce and bump the id= tag in _mta-sts.

Next step: BIMI for inbox brand trust

Once your domain enforces DMARC (p=quarantine at pct=100 or p=reject) and protects transport encryption with MTA-STS, you can add BIMI (Brand Indicators for Message Identification) at default._bimi.example.com:

Host:  default._bimi
Type:  TXT
Value: v=BIMI1; l=https://example.com/brand/logo.svg; a=https://example.com/brand/vmc.pem
  • l= points to a square SVG Tiny PS logo served over HTTPS.
  • a= points to your Verified Mark Certificate (VMC) PEM file, which providers such as Gmail require before displaying your logo next to messages.

Verify your live setup

Publishing a typo in mta-sts.txt, forgetting to update id=, or accidentally serving mta-sts.<domain> behind a 301 redirect silently breaks enforcement. Test your _mta-sts TXT record, live mta-sts.txt policy file, _smtp._tls reporting record and default._bimi tag in one pass with our MTA-STS, TLS-RPT & BIMI Checker.