Before you start
Run the free Email security check on your domain. Its Suggested records section gives you the exact values for your domain; this guide explains what each record does and where to put it.
All records are added at your DNS provider, for example Cloudflare → your domain → DNS → Records → Add record. In most providers, the Name field takes the part before your domain (_dmarc, not _dmarc.example.com).
Recommended order
| Step | Record | Effort | Why this order |
|---|---|---|---|
| 1 | TLS-RPT | 2 minutes | Starts sending reports, no risk |
| 2 | DKIM | 10 minutes | Needed before DMARC can be enforced safely |
| 3 | SPF | 5 minutes | Lists every service that sends as you |
| 4 | DMARC p=none → quarantine → reject | 2–6 weeks | Use the reports to find legitimate senders first |
| 5 | MTA-STS (testing → enforce) | 30 minutes + a few weeks | Needs a small HTTPS file |
| 6 | BIMI | Optional | Only works once DMARC is enforced |
| 7 | DNSSEC and CAA | 10 minutes | Protects the DNS records themselves |
MX: where your mail is delivered
MX records tell other servers where to deliver mail for your domain. Your mail provider gives you the value; you rarely change it.
| Provider | Type | Name | Value | Priority |
|---|---|---|---|---|
| Microsoft 365 | MX | @ | yourdomain-com.mail.protection.outlook.com | 0 |
| Google Workspace | MX | @ | smtp.google.com | 1 |
| Email gateway (Proofpoint, Mimecast…) | MX | @ | the hosts the vendor gives you | as given |
- Keep only your provider's MX records and delete old ones.
- MX records cannot be proxied (Cloudflare shows them as DNS only).
- A domain that never receives mail should publish a null MX:
0 . - If a gateway sits in front of Microsoft 365, restrict Exchange Online to accept mail only from the gateway (an inbound connector), so attackers cannot bypass it.
SPF: who may send as you
One TXT record on the root of the domain.
| Type | Name | Value (Microsoft 365 example) |
|---|---|---|
| TXT | @ | v=spf1 include:spf.protection.outlook.com -all |
- Add an
include:for every service that sends as you: Googleinclude:_spf.google.com, SendGridinclude:sendgrid.net, Mailchimpinclude:servers.mcsv.net, Salesforceinclude:_spf.salesforce.com, and so on. - End with
-all(others fail). Use~allonly while testing. Never+allor?all. - Only one SPF record per domain, and no more than 10 DNS lookups in total. The email security check counts them for you.
DKIM: signing your mail
DKIM proves a message really came from you and was not changed. The key comes from your mail provider.
Microsoft 365
- Open the Microsoft Defender portal → Email & collaboration → Policies & rules → Threat policies → Email authentication settings → DKIM.
Select your domain. It shows two CNAME records:
Type Name Value CNAME selector1._domainkeyselector1-yourdomain-com._domainkey.<tenant>.onmicrosoft.comCNAME selector2._domainkeyselector2-yourdomain-com._domainkey.<tenant>.onmicrosoft.com- Add both at your DNS provider (DNS only, not proxied), wait a few minutes, then switch Sign messages for this domain with DKIM signatures on.
Google Workspace: Google Admin → Apps → Google Workspace → Gmail → Authenticate email → Generate new record → publish the TXT record at google._domainkey → Start authentication.
Other senders (marketing, CRM, helpdesk) each have their own DKIM setup page; enable it so their mail passes DMARC too.
DMARC: enforcing it
DMARC tells receivers what to do with mail that fails SPF and DKIM, and sends you reports.
| Stage | Type | Name | Value | When |
|---|---|---|---|---|
| 1. Monitor | TXT | _dmarc | v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com | Day 1 |
| 2. Quarantine | TXT | _dmarc | v=DMARC1; p=quarantine; pct=100; rua=mailto:dmarc@yourdomain.com | After 2–4 weeks of clean reports |
| 3. Reject | TXT | _dmarc | v=DMARC1; p=reject; rua=mailto:dmarc@yourdomain.com | After 2–4 more weeks |
- Reports are XML files. A free reader makes them usable; on Cloudflare, Email → DMARC Management sets up the
ruaaddress and reads the reports for you. - Before each step, check that every legitimate sender in the reports passes SPF or DKIM.
- Only one DMARC record.
p=nonedoes not stop spoofing; it only monitors.
MTA-STS: require encrypted delivery
Without MTA-STS, an attacker on the network path can downgrade mail delivery to unencrypted. MTA-STS tells sending servers to deliver to you only over verified TLS. It needs two things: a policy file served over HTTPS, and a TXT record.
1. The policy file
It must be served at exactly https://mta-sts.yourdomain.com/.well-known/mta-sts.txt with a valid certificate:
version: STSv1
mode: testing
mx: *.mail.protection.outlook.com
max_age: 86400
mx:lines must match your MX hosts. Microsoft 365:*.mail.protection.outlook.com. Google Workspace:smtp.google.com(older setups:aspmx.l.google.comand*.aspmx.l.google.com). Gateways: one line per MX host.- Start with
mode: testing. Reports arrive through TLS-RPT, but delivery is never blocked.
2. Hosting the file
Option A: Cloudflare Worker (free, no server). Cloudflare → Workers & Pages → Create → Worker, name it mta-sts, replace the code with the snippet below and Deploy. Then open the Worker → Settings → Domains & Routes → Add → Custom domain → mta-sts.yourdomain.com.
const POLICY = `version: STSv1
mode: testing
mx: *.mail.protection.outlook.com
max_age: 86400
`;
export default {
fetch(request) {
const url = new URL(request.url);
if (url.pathname === '/.well-known/mta-sts.txt') {
return new Response(POLICY, { headers: { 'content-type': 'text/plain; charset=utf-8' } });
}
return new Response('Not found', { status: 404 });
},
};
Option B: any static host (GitHub Pages, Azure Static Web Apps, Netlify, your web server). Create the file at /.well-known/mta-sts.txt, connect the host to mta-sts.yourdomain.com and make sure HTTPS works.
Check it: open https://mta-sts.yourdomain.com/.well-known/mta-sts.txt in a browser. You should see the four lines, with no redirect and no certificate warning.
3. The TXT record
| Type | Name | Value |
|---|---|---|
| TXT | _mta-sts | v=STSv1; id=20261031 |
The id can be any short value; using today's date is easiest. Change it every time you edit the policy file, or senders keep the old policy.
4. Enforce
After 2–4 weeks of TLS-RPT reports without failures, change the file to mode: enforce and max_age: 604800 (one week), then update the id in the TXT record.
TLS-RPT: delivery reports
TLS-RPT sends you a daily report when other servers have trouble delivering to you securely. Set it up together with MTA-STS.
| Type | Name | Value |
|---|---|---|
| TXT | _smtp._tls | v=TLSRPTv1; rua=mailto:tls-reports@yourdomain.com |
Use a mailbox you read. Reports are JSON files from Google, Microsoft and others; "successful sessions" with no failures means you are ready to enforce MTA-STS.
BIMI: your logo in the inbox
BIMI shows your logo next to your messages in mail apps that support it. It is optional and only works once DMARC is p=quarantine (with pct=100) or p=reject.
- Create a square SVG Tiny PS logo:
version="1.2" baseProfile="tiny-ps", a<title>, a solid background, no scripts, images or links, under 32 KB. - Host it over HTTPS, for example
https://yourdomain.com/bimi.svg. Add the record:
Type Name Value TXT default._bimiv=BIMI1; l=https://yourdomain.com/bimi.svg; a=
- Yahoo shows the logo with just this.
- Gmail and Apple Mail also need a certificate: a VMC (requires a registered trademark) or a CMC, from DigiCert or Entrust. Put the certificate's
.pemURL aftera=. - Outlook / Microsoft 365 does not show BIMI logos for most mailboxes.
DNSSEC and CAA: protect the DNS itself
DNSSEC signs your DNS records so they cannot be forged in transit. On Cloudflare: DNS → Settings → Enable DNSSEC. If your domain is registered elsewhere, copy the DS record Cloudflare shows into your registrar's DNSSEC settings. If the registrar is Cloudflare, this is automatic.
CAA limits which certificate authorities may issue certificates for your domain.
| Type | Name | Tag | Value |
|---|---|---|---|
| CAA | @ | iodef | mailto:security@yourdomain.com |
| CAA | @ | issue | the CA you use, e.g. letsencrypt.org |
On Cloudflare with Universal SSL, Cloudflare automatically adds CAA records for the authorities it uses once you add your own, so its certificates keep renewing.
Check your progress
Run the Email security check after each step. A domain with SPF -all, DKIM, DMARC p=reject, MTA-STS, TLS-RPT and BIMI scores 100/100. The Security stack fingerprint shows what else your public DNS reveals.
Need help with a larger estate, several domains or third-party senders? Talk to an analyst.