SPF, DKIM, DMARC and MX records, explained

MX records tell the world where to deliver your domain's mail. SPF lists the servers allowed to send as you, DKIM signs each message, and DMARC tells Gmail, Yahoo and Outlook.com what to do with mail that fails them.

Last updated

The four records at a glance

Say you run a bakery called Corner Loaf, and your mail is at Google Workspace. These are the records cornerloafbakery.com needs, laid out the way your DNS company's screen lists them. DNS is the public address book where your domain's settings live.

TypeNameValue
MX@1 smtp.google.com (Where your mail goes (MX))
TXT@v=spf1 include:_spf.google.com ~all (Who may send as you (SPF))
TXTgoogle._domainkeyv=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA… (The key that checks your signature (DKIM))
TXT_dmarcv=DMARC1; p=none; rua=mailto:dmarc@cornerloafbakery.com (What to do with mail that fails (DMARC))
Google Workspace's records, with the values from Google's own setup pages (checked 30 November 2026). The DKIM value is cut short here: the real one is about 400 characters, and Google's admin console makes it for you.

MX is about mail coming to you. The other three are about mail you send: they let the customer's mail server check that a message saying it's from cornerloafbakery.com really is.

What happens when you send a message

  1. Emily sends a message from hello@cornerloafbakery.com

    to a customer, James, at his gmail.com address.

    Google Workspace signs the message with Corner Loaf's DKIM key, then looks up gmail.com's MX record to find Gmail's server.

  2. Gmail's server receives it

    and reads cornerloafbakery.com's records to check it.

    • SPF Pass Did it come from a server on Corner Loaf's list?
    • DKIM Pass Is Corner Loaf's signature on it, unchanged?
    • DMARC Pass Did SPF or DKIM pass for cornerloafbakery.com, the domain in the From line? If not, what does Corner Loaf ask?

    It passes, so Gmail knows it's really from Corner Loaf. Inbox or spam still depends on what's in it, and on how people have treated Corner Loaf's mail before.

  3. In James's inbox

    A forgery would fail these checks. Corner Loaf's record only watches for now (p=none), so Gmail's own filters decide; with p=quarantine, a forgery would go to spam.

A message's path from Corner Loaf to a customer on Gmail, and where each record is read.

Since February 2024, Google has asked everyone who sends to Gmail addresses to set up SPF or DKIM, and anyone sending 5,000 or more a day to have all three (Google's sender rules). Since November 2025 Gmail has been turning away more of the mail that doesn't (Google's FAQ). Yahoo asks the same, and Outlook.com turns away mail from anyone sending it 5,000 or more messages a day that doesn't pass SPF, DKIM and DMARC. All checked 30 November 2026.

MX: where your mail goes

An MX record (mail exchanger) names the server that takes mail for your domain. When anyone writes to hello@cornerloafbakery.com, their mail server looks up this record and delivers the message there.

Most providers give you one to five MX records, each with a priority number. Senders try the lowest number first, and the others only if it doesn't answer (RFC 5321, section 5.1). Any numbers work; only their order counts. Our own domain, flatinbox.com, takes its mail through Cloudflare, which gave us these three:

TypeNameValue
MX@12 route2.mx.cloudflare.net
MX@58 route3.mx.cloudflare.net
MX@69 route1.mx.cloudflare.net
flatinbox.com's MX records, as a DNS lookup returned them on 30 November 2026. Senders try route2 first, because 12 is the lowest number.

Two things go wrong with MX records:

  • Records from two providers at once. Mail goes to whichever has the lowest number, or is split between them when the numbers match, so some of it lands where you don't look. When you move your mail, delete the old provider's MX records.
  • No MX record at all. Senders then try the server your domain's website is on, which usually doesn't take mail, so messages to you bounce.

Change your MX records only when you move your mail to a different provider. They make no difference to the mail you send. Google's setup page, for example, asks for one record, smtp.google.com with priority 1 (Google's MX page).

SPF: who may send as your domain

SPF (Sender Policy Framework) is a TXT record (a record that holds a line of text) on your domain, listing the servers allowed to send mail as it. The receiving server compares the server a message came from with your list (RFC 7208). Corner Loaf's record, part by part:

TXT cornerloafbakery.com

v=spf1 include:_spf.google.com ~all

  1. v=spf1 marks this TXT record as SPF. It always comes first.
  2. include:_spf.google.com adds Google's list of sending servers to yours. Some services that send as you, such as an invoicing app, give you an include to add here; others, including many newsletter tools, ask only for DKIM records.
  3. ~all covers every server not listed: a “soft fail”, meaning the mail is probably not from you. -all asks for a plain fail. Use the one your provider gives you.

Two rules trip people up:

  • One SPF record per domain. With two records starting v=spf1, SPF fails for every message you send (RFC 7208, sections 3.2 and 4.5). To add a service, put its include into the record you already have, before the ~all.
  • No more than 10 includes. Each one makes the receiving server look up another list, and any includes inside that list count too, as do the rarer a, mx, exists and redirect. Past 10, SPF fails (section 4.6.4). Google's include counts as one.

SPF checks the hidden return address where bounces go, not the From address people see (section 2.4). On its own it doesn't stop someone putting your address in From. DMARC is the check that covers the From address.

DKIM: a signature on every message

DKIM (DomainKeys Identified Mail) adds a signature to each message you send. Your mail provider signs with a secret key that only it holds. The record you add holds the matching public key, which can check the signature but can't make one. If the signed part of the message changes on the way, the check fails (RFC 6376).

You don't write a DKIM record yourself. Your provider makes the key and shows you the record to add. Its name is a label the provider picks, called the selector, then ._domainkey: Google's is google._domainkey. Some providers give you CNAME records (records that point to another name) instead, which point to a key they keep and can change without asking you. When we set up notify.flatinbox.com, the domain FlatInbox's own emails come from, Amazon's mail service gave us three:

TypeNameValue
CNAMEw4cafset6e5na3lfsvsxyb7cvjitdgad._domainkey.notifyw4cafset6e5na3lfsvsxyb7cvjitdgad.dkim.amazonses.com
CNAMEnfdqjb52vypa374xlhluot5sls5v6hoa._domainkey.notifynfdqjb52vypa374xlhluot5sls5v6hoa.dkim.amazonses.com
CNAMEznx75fes6nksh3yxmg7u4ka36udkevjs._domainkey.notifyznx75fes6nksh3yxmg7u4ka36udkevjs.dkim.amazonses.com
The DKIM records for notify.flatinbox.com, added in Cloudflare on 30 November 2026. The long names are the selectors Amazon picked.

If your provider asks how long a key to make, pick 2048 bits. The standard asks for at least 1024 and recommends 2048 (RFC 8301), and Google suggests 2048 too, where your DNS company accepts a value that long.

A forwarded message arrives from the forwarder's server, which isn't on your SPF list, so SPF fails. DKIM usually still passes, because plain forwarding leaves the message as it was. That makes DKIM the check that keeps forwarded mail trusted.

DMARC: what to do with mail that fails

DMARC ties SPF and DKIM to the From address people see, and tells receiving servers what to do with a message that fails. It's a TXT record named _dmarc on your domain (RFC 9989, which replaced the first DMARC standard in May 2026).

A message passes DMARC when SPF or DKIM passes for the same domain as its From address. Unless you ask for an exact match, a subdomain counts as the same domain, so mail signed by notify.flatinbox.com passes for an address on flatinbox.com.

TXT _dmarc.cornerloafbakery.com

v=DMARC1; p=none; rua=mailto:dmarc@cornerloafbakery.com

  1. v=DMARC1 marks the record as DMARC. It comes first.
  2. p=none the policy for mail that fails: none only watches, quarantine asks for it to go to spam, reject asks for it to be turned away.
  3. rua=mailto:dmarc@cornerloafbakery.com where receiving servers send a daily report of the mail they saw from your domain, and whether it passed. It's optional, and the reports are files meant for software.

Start with p=none. It changes nothing for your mail, and it's enough for Google's, Yahoo's and Microsoft's rules for big senders. Switch to p=quarantine once every service that sends as you passes DMARC (the Gmail check below shows it). The standard suggests p=none for at least a month first, and p=quarantine for as long again before anything stricter. It also says a domain whose people post to mailing lists shouldn't use p=reject, because lists change messages and break their signatures (RFC 9989, section 7.4). For most small businesses we'd stop at quarantine.

Google's own two domains sit at opposite ends. Their records, and ours, on 30 November 2026:

TypeNameValue
TXT_dmarc.google.comv=DMARC1; p=reject; rua=mailto:mailauth-reports@google.com
TXT_dmarc.gmail.comv=DMARC1; p=none; sp=quarantine; rua=mailto:mailauth-reports@google.com
TXT_dmarc.flatinbox.comv=DMARC1; p=none
google.com asks for forgeries to be turned away, while gmail.com only watches (and asks for spam for its subdomains). Our own flatinbox.com watches too.

See whether a message passed

Gmail shows the results for any message. Open it on a computer, click the three dots next to Reply, then Show original (Google's steps).

Gmail's More menu on an open message, with Show original near the bottom.
Gmail's More menu, on an open message.

The box at the top gives SPF, DKIM and DMARC, each PASS or FAIL. Here's a message we sent from notify.flatinbox.com to one of our test Gmail accounts:

Gmail's Show original page: SPF PASS with IP 54.240.8.82, DKIM PASS with domain notify.flatinbox.com, DMARC PASS.
Gmail's Show original, for our message on 30 November 2026, cropped to the checks.

Try it with a message from your own business address to a Gmail account. A FAIL on DMARC means something sending as you isn't set up yet: its SPF include or its DKIM record is missing.

Where to add these records

Records live with whoever runs your domain's DNS. That's usually the company you bought the domain from, unless you've moved your DNS to another, such as Cloudflare. Every company's screen asks for the same three things, a type, a name and a value, though it may call the name Host and the value Content, Data or Answer. Their own help pages show where: Cloudflare, GoDaddy, Namecheap, Squarespace and Porkbun (checked 30 November 2026).

For a record on the domain itself, most screens take @ as the name, and a few want the box left empty. For _dmarc or a DKIM name, type only that part: most screens add your domain after it.

The records, worked out for you.

FlatInbox gives you three records to copy, two for DKIM and one for bounces that makes SPF pass, and checks each one. Request access, and we'll write to you when your account is ready.

We only use your address to tell you when your account is ready.