Cluster 10 · RFC 8461 · Cloudflare · Workers + Pages

MTA-STS Setup on Cloudflare: Workers, Pages & DNS TXT Guide

Deploy RFC 8461 MTA-STS on Cloudflare in under 5 minutes without a separate origin server: host https://mta-sts.<domain>/.well-known/mta-sts.txt via Cloudflare Pages or a 12-line Worker plus _mta-sts TXT.

Zero Telemetry · Strict CSP (connect-src 'none')

Domain Trust & Email-TLS Configuration

RFC 8461 · 8460 · 8659 · 9116
Domain Trust Readiness Score
100 / 100 (A)
HARDENED — TRUST & TLS READY
MTA-STS & TLS-RPT 30/30
BIMI & DMARC Gate 25/25
DNS CAA (RFC 8659) 20/20
RFC 9116 security.txt 25/25

MTA-STS & TLS-RPT Artifacts

RFC 8461 + 8460
https://mta-sts.example.com/.well-known/mta-sts.txt
version: STSv1
mode: enforce
mx: *.mx.cloudflare.net
max_age: 604800
TXT @ _mta-sts.example.com
v=STSv1; id=20261127000000Z
TXT @ _smtp._tls.example.com
v=TLSRPTv1; rua=mailto:[email protected]
STS-MX-OK: 1 valid MX pattern(s) encoded PASS
Policy binds TLS validation to *.mx.cloudflare.net.
STS-ID-OK: Valid _mta-sts policy id=20261127000000Z PASS
Update id= whenever you edit /.well-known/mta-sts.txt so senders re-fetch the policy.
STS-MODE-OK: mode: enforce active (downgrade protection enabled) PASS
Sending MTAs will refuse plaintext fallback or mismatched MX certificates.
STS-AGE-OK: max_age: 604800s (7 days) PASS
Within RFC 8461 bounds (<= 31557600 seconds).
TLSRPT-OK: Valid _smtp._tls TLS-RPT record (RFC 8460) PASS
Daily JSON TLS reports route to mailto:[email protected].

Complete 4-in-1 Domain Trust Bundle

Markdown / TXT
domain-trust-bundle.md
# Domain Trust Sidecar & Email-TLS Bundle — example.com

- **Domain Trust Readiness Score:** 100 / 100 (Grade A — HARDENED — TRUST & TLS READY)
- **MTA-STS & TLS-RPT:** 30/30 · **BIMI:** 25/25 · **DNS CAA:** 20/20 · **security.txt:** 25/25

## 1. MTA-STS Policy File (`https://mta-sts.example.com/.well-known/mta-sts.txt`)
Serve over HTTPS (`200 OK`, `Content-Type: text/plain; charset=utf-8`, no redirects):
```text
version: STSv1
mode: enforce
mx: *.mx.cloudflare.net
max_age: 604800
```

### MTA-STS & TLS-RPT DNS TXT Records
- `_mta-sts.example.com` TXT: `v=STSv1; id=20261127000000Z`
- `_smtp._tls.example.com` TXT: `v=TLSRPTv1; rua=mailto:[email protected]`

## 2. BIMI DNS TXT Record
- `default._bimi.example.com` TXT: `v=BIMI1; l=https://example.com/.well-known/bimi-logo.svg; a=https://example.com/.well-known/bimi-vmc.pem`
- DMARC Prerequisite: `p=reject; pct=100` (READY)

## 3. DNS CAA Records (RFC 8659 BIND Zone)
```bind
example.com. 3600 IN CAA 0 issue "letsencrypt.org"
example.com. 3600 IN CAA 0 issue "pki.goog"
example.com. 3600 IN CAA 0 issue "digicert.com"
example.com. 3600 IN CAA 0 issue "sectigo.com"
example.com. 3600 IN CAA 0 issuewild "letsencrypt.org"
example.com. 3600 IN CAA 0 issuewild "pki.goog"
example.com. 3600 IN CAA 0 issuewild "digicert.com"
example.com. 3600 IN CAA 0 issuewild "sectigo.com"
example.com. 3600 IN CAA 0 iodef "mailto:[email protected]"
```

## 4. RFC 9116 `https://example.com/.well-known/security.txt`
```text
Contact: mailto:[email protected]
Expires: 2027-11-26T00:00:00.000Z
Canonical: https://example.com/.well-known/security.txt
Policy: https://example.com/security-policy
Preferred-Languages: en
```

## Live Verification & Automated Remediation
- Live DoH + Security Scan: https://audit.runglab.dev/?domain=example.com
- Tailored 9-File ReadyCheck Fix Pack ($49): https://www.creem.io/product/prod_6rX3ZZhMCJ5MGugvk75Ogo
- Remote MCP Server (dev.runglab/devtools): https://mcp-server.runglab.dev/
Live DoH + TLS Verification $49 9-File Fix Pack

Verify Live DNS Records or Deploy All 9 ReadyCheck Fixes Together

In our N=140 B2B SaaS Readiness Benchmark, 95.2% (60/63) missed _mta-sts and 79.4% lacked valid RFC 9116 security.txt. Scan your live domain on ReadyCheck (https://audit.runglab.dev), order the tailored $49 9-File Domain Fix Pack, or automate via remote MCP Server dev.runglab/devtools.

RFC Specifications & Provider Requirements

Field / Record Compliant Value Engineering & Rollout Rationale
HTTPS Policy Endpoint https://mta-sts.<domain>/.well-known/mta-sts.txt Must return HTTP 200 text/plain; charset=utf-8 with ZERO 301/302 redirects (RFC 8461 §3.3)
Cloudflare Proxy (Orange Cloud) Proxied CNAME / Worker Route on mta-sts Cloudflare Edge terminates TLS 1.3 automatically; never enable Always-Use-HTTPS redirect loops
_mta-sts.<domain> TXT v=STSv1; id=20261127000000Z id= must be 1–32 alphanumeric characters; rotate id= after every policy edit
_smtp._tls.<domain> TXT v=TLSRPTv1; rua=mailto:tls-reports@<domain> Collects daily JSON delivery/TLS failure reports before flipping mode: testing to enforce

Cloudflare Worker — Zero-Origin /.well-known/mta-sts.txt Responder

mta-sts-worker.ts
const POLICY_BODY = [
  "version: STSv1",
  "mode: enforce",
  "mx: *.mx.cloudflare.net",
  "max_age: 604800",
  ""
].join("\r\n");

export default {
  async fetch(request: Request): Promise<Response> {
    const url = new URL(request.url);
    if (url.pathname === "/.well-known/mta-sts.txt") {
      return new Response(POLICY_BODY, {
        status: 200,
        headers: {
          "content-type": "text/plain; charset=utf-8",
          "cache-control": "public, max-age=300"
        }
      });
    }
    return new Response("Not Found", { status: 404 });
  }
};

Cloudflare DNS Records & Live DoH / cURL Verification

verify-cloudflare-mta-sts.sh
# Publish in Cloudflare DNS:
# 1) AAAA mta-sts -> 100:: (Proxied / Orange Cloud, handled by Worker route mta-sts.example.com/*)
# 2) TXT  _mta-sts -> "v=STSv1; id=20261127000000Z"
# 3) TXT  _smtp._tls -> "v=TLSRPTv1; rua=mailto:[email protected]"

curl -i --max-redirs 0 https://mta-sts.example.com/.well-known/mta-sts.txt
dig +short TXT _mta-sts.example.com
dig +short TXT _smtp._tls.example.com

Step-by-Step Deployment & Key Insights

  1. Create a Cloudflare DNS Proxied (Orange Cloud) route for mta-sts.<domain>/* pointing to a Worker or Cloudflare Pages project.
  2. Serve version: STSv1, mode: testing (initially), exact mx: patterns, and max_age: 604800 at /.well-known/mta-sts.txt with HTTP 200 and zero redirects.
  3. Publish _mta-sts.<domain> TXT (v=STSv1; id=YYYYMMDDHHMMSSZ) and _smtp._tls.<domain> TXT (v=TLSRPTv1; rua=mailto:...).
  4. Verify zero TLS failures via TLS-RPT for 7 days, switch mode to enforce, and bump id= in _mta-sts TXT.
  • In RungLab's N=140 B2B SaaS benchmark, 95.2% (60/63) of full-telemetry domains omit _mta-sts entirely — leaving inbound SMTP vulnerable to STARTTLS stripping.
  • RFC 8461 §3.3 strictly forbids following HTTP redirects when fetching mta-sts.txt. Cloudflare Bulk Redirects or Page Rules redirecting subdomains to www or apex will break MTA-STS silently.
  • Using Cloudflare Workers with a dummy Proxied AAAA record (100::) avoids spinning up any origin VM or bucket just to serve a 5-line text file.

Common Configuration Pitfalls to Avoid

  • Redirecting mta-sts.example.com to example.com or www.example.com — sending MTAs abort MTA-STS discovery on 301/302 responses.
  • Forgetting to update id= inside _mta-sts.<domain> TXT after changing mta-sts.txt, causing Gmail and Outlook to keep old cached MX rules until max_age expires.
  • Putting Cloudflare DNS proxy mode on mail MX hosts themselves (leave MX target A records DNS-Only gray cloud; only mta-sts.<domain> uses Orange Cloud HTTPS).

More Domain Trust & Email-TLS Guides

← Back to Domain Trust Sidecar Hub · Cluster 1A: SPF & DMARC Builder → · Cluster 4: Security Headers & CSP → · 2026 N=140 B2B Benchmark → · ReadyCheck Live Audit → · $49 9-File Fix Pack →

Frequently Asked Questions

Does Cloudflare Email Routing automatically enable MTA-STS?

No. Cloudflare Email Routing configures MX and SPF, but you must still publish https://mta-sts.<domain>/.well-known/mta-sts.txt (listing mx: *.mx.cloudflare.net) and the _mta-sts + _smtp._tls TXT records.

Why does RFC 8461 fail if mta-sts.<domain> returns a 301 redirect?

RFC 8461 §3.3 requires policy servers to avoid redirects because HTTP redirection to an untrusted host weakens certificate hostname validation. Always respond directly with 200 OK.

Can Cloudflare Pages serve /.well-known/mta-sts.txt without a Worker?

Yes — attach mta-sts.<domain> as a custom domain on a Cloudflare Pages project containing .well-known/mta-sts.txt and add a _headers rule setting Content-Type: text/plain; charset=utf-8.