Blog / How the internet works /

How email actually gets delivered: SPF, DKIM and DMARC in plain words

You send an invoice, a booking confirmation or a reply to a customer. They say they never got it. You check your sent folder: it’s there. You ask them to check spam: it’s in spam. Or it isn’t anywhere at all.

If you run a website, this will happen to you. A contact form that stops delivering. A newsletter that lands in the promotions tab, or worse. An email that “must have been lost”. Almost always, the cause isn’t luck. It is three small lines of text in your domain’s DNS called SPF, DKIM and DMARC, or the absence of them.

This guide explains how email actually travels, what those three things do in plain words, how to set them up, and how to check that they’re working. It’s longer than most of my posts because email is one of those subjects where a half-understanding gets you into trouble.

Key takeaways

  • Email was built without proof of identity. Anyone can claim to be sending from your address. SPF, DKIM and DMARC are the add-ons that fix that.
  • SPF lists who is allowed to send email for your domain.
  • DKIM adds a signature that proves a message wasn’t altered and really came from you.
  • DMARC tells receiving servers what to do when a message fails those checks, and sends you reports.
  • Every service that sends email as your domain (your website, your newsletter tool, your help desk) must be covered.
  • Set up all three, start DMARC in monitoring mode, and test by sending yourself a message.
  • From February 2024, Google and Yahoo require authentication from bulk senders to their users, and are tightening the rules for everyone.

How an email actually travels

Most people picture email as a message that flies from your computer to theirs. It’s closer to a parcel handed through several depots.

  1. You write and press send. Your email program hands the message to your outgoing mail server, the one run by your email provider or your hosting company.
  2. Your server looks up where to send it. It checks the recipient’s domain in DNS for an MX record, which says, “mail for this domain should go to this server.”
  3. Your server hands the message to theirs, using a protocol called SMTP, in a conversation between two computers.
  4. Their server decides what to do: accept it into the inbox, put it in spam, or reject it.
  5. The recipient’s email app fetches it from their mailbox.

The crucial thing is step 4. The receiving server has to make a judgement call about a message from a stranger. And here’s the uncomfortable fact about email: it was designed in an era when everyone on the network knew each other. The “From” address on an email is like the return address on a paper envelope. You can write anything you like on it.

So the receiving server needs a way to ask: is this message really from the domain it says it’s from? That’s what SPF, DKIM and DMARC are for.

If DNS itself is still a bit fuzzy, start with DNS explained for people who just want their site to work. All three of these tools live in your DNS settings as TXT records.

An analogy: the nightclub door

Imagine a club with a strict door policy.

  • SPF is the guest list. The doorman checks whether the person arriving is on the list of people allowed in for this event. In email terms: is this server on the list of servers allowed to send for this domain?
  • DKIM is the wristband with a tamper seal. The person arrives wearing a numbered, sealed band that can only be made by the organiser. In email terms: was this message signed by the domain’s own key, and is the signature intact, meaning the contents weren’t changed on the way?
  • DMARC is the house rule. It tells the doorman what to do when a guest fails the check (“turn them away”, “put them in the holding area”, or “let them in but note it down”) and asks for a report at the end of the night.

None of the three is much use alone. Together they give a receiving server confidence.

SPF: the list of allowed senders

SPF stands for Sender Policy Framework. It is a TXT record at the root of your domain listing which servers may send mail using your domain.

A simple example for a domain whose email is handled by Google Workspace:

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

Read it from left to right:

  • v=spf1 says “this is an SPF record”.
  • include:_spf.google.com says “servers that Google lists are allowed”.
  • ~all says “anything else is suspicious” (a “soft fail”). A stricter version is -all, “anything else is not allowed”.

When a message arrives, the receiving server looks at the sending server’s address, fetches your SPF record and checks whether that address is on the list. Match: pass. No match: fail.

SPF rules that catch people out

  • One SPF record per domain. Having two is an error, and receivers may ignore both. If you add a new service, merge it into the existing record.
  • Include every sender. Your email host, your newsletter tool, your website’s transactional email service, your help desk. Forgetting one is how a perfectly legitimate message starts failing.
  • There is a limit of 10 DNS lookups. Each include: can trigger more lookups behind the scenes. Pile on too many services and the record breaks. That’s a good reason to keep your list of senders short.
  • SPF checks the hidden “envelope” sender, not the “From” address you see. This is one reason SPF alone isn’t enough, and why DMARC exists.
  • It breaks when mail is forwarded, because the forwarding server isn’t on your list. DKIM survives forwarding better.

DKIM: the signature

DKIM stands for DomainKeys Identified Mail. It uses a pair of keys, one private and one public.

  • Your sending service holds the private key and uses it to sign every outgoing message. The signature travels in the message’s hidden headers.
  • You publish the public key in your DNS as a TXT record.
  • The receiving server reads the signature, fetches your public key and checks that they match.

If they match, two things are proven: the message was signed by someone who holds your domain’s key, and it wasn’t altered after signing. If a single character of the body changed in transit, the check fails.

The DNS record sits at a name made from a “selector” chosen by the sending service, such as selector1._domainkey.yourdomain.com. You don’t invent the value. Your email provider generates it and gives you the exact record to add. A long string beginning v=DKIM1; k=rsa; p=... is normal.

DKIM rules that catch people out

  • Each sending service has its own DKIM keys. Your mailbox provider, your newsletter tool and your website’s email service each need setup.
  • You have to switch it on. In many providers, DKIM is a setting you must enable after adding the record.
  • Copy the record exactly. Long keys get broken by stray spaces or line breaks. Some DNS dashboards need the value split or quoted in a particular way.
  • Keep it after you change provider. Old records can be left behind. They’re mostly harmless, but tidy them up.

DMARC: the policy and the reports

DMARC stands for Domain-based Message Authentication, Reporting and Conformance. It sits on top of SPF and DKIM and adds two things.

1. A policy: what receivers should do when a message fails.

  • p=none: do nothing special, just report to me. (Monitoring mode.)
  • p=quarantine: treat failures as suspicious, usually the spam folder.
  • p=reject: refuse them outright.

2. Alignment: DMARC requires that the domain in the visible “From” address matches the domain that passed SPF or DKIM. That closes the loophole where a scammer passes SPF with their own domain but shows your address in the From line.

A starting DMARC record, a TXT record at _dmarc.yourdomain.com:

v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.com

The rua part says where to send daily summary reports. Those reports are machine-readable XML files. Raw, they’re unpleasant to read, which is why many people use a free or paid DMARC report service to turn them into a dashboard.

The safe way to roll DMARC out

  1. Start at p=none for a few weeks. This changes nothing about delivery. You just collect reports.
  2. Read the reports. Which servers send mail as your domain? Are they all legitimate? Are any failing SPF or DKIM?
  3. Fix the legitimate senders that fail: add them to SPF, set up DKIM.
  4. Move to p=quarantine, perhaps applying it to a small percentage of messages at first.
  5. Move to p=reject when you are confident every real sender passes.

Jumping straight to reject is the classic mistake. It works perfectly until you remember the booking system that sends emails as your address, and then those emails silently vanish.

Why this matters more in 2024

Email providers have always checked for these signals, but the rules are getting stricter. Google and Yahoo announced new requirements for senders that take effect in February 2024. In short, for people who send large volumes to Gmail and Yahoo addresses, they expect:

  • SPF and DKIM authentication
  • A DMARC policy in place (at least p=none)
  • Alignment between the From domain and the authenticated domain
  • Easy one-click unsubscribe for marketing mail
  • Low spam complaint rates

Google’s guidance describes the strictest requirements for bulk senders (those sending thousands of messages a day to Gmail), but it also says everyone who sends to Gmail should set up SPF or DKIM. The practical lesson for a small site: you may not be a bulk sender, but the checks apply in spirit to you too, and setting everything up now costs very little.

What this means for a website owner

Your website probably sends email: contact form notifications, order confirmations, password resets. By default, many WordPress sites send those from the web server using plain PHP mail, as your domain, from an address no one authorised in your SPF record. That is exactly the pattern spam filters distrust.

Typical fixes:

  1. Send site email through a proper email service (an SMTP service or a transactional email provider) instead of the web server.
  2. Add that service to your SPF record and enable its DKIM signing.
  3. Use a “From” address on your own domain that matches what’s authenticated.
  4. Publish a DMARC record and read the reports for a while.
  5. Send a test and check the headers (see below).

I explained why different kinds of email deserve different tools in transactional email vs marketing email, and the hosting side in email and website on the same host: pros and cons. If you’re building a mailing list, email lists for small sites: why I’d start one early explains why authentication should be set up before the first send, not after the first problem.

One more DNS warning. If your domain uses Cloudflare, any email-related record that can be proxied (for example a CNAME that a provider uses for DKIM) must be set to “DNS only”. MX and TXT records aren’t proxied, because Cloudflare’s proxy applies to web traffic. I covered the basics in DNS, SSL and Cloudflare: what site owners should know, and DNS changes take time to spread, as explained in TTL: why DNS changes take time.

How to check it’s working

You don’t need special software for a first check.

  1. Send an email from your domain to a Gmail address.
  2. Open the message in Gmail, click the three dots and choose Show original.
  3. Look at the top of the page. It shows SPF, DKIM and DMARC with PASS or FAIL.

What you want to see:

SPF: PASS
DKIM: PASS
DMARC: PASS

If any says FAIL or NEUTRAL, the details below the summary tell you which domain was checked and why it failed. Repeat the test for every kind of email you send: a message from your mailbox, a test from the contact form, a test from the newsletter tool. Each path can have a different result.

You can also look up your records with any free DNS lookup tool: search for the TXT records on your root domain (for SPF), on _dmarc.yourdomain.com (for DMARC) and on your DKIM selector name.

Common problems and what they usually mean

Symptom Likely cause
Contact form emails go to spam Sent by the web server, not authenticated; use an email service and add SPF/DKIM
SPF “permerror” Two SPF records, or more than 10 lookups, or a typo
DKIM FAIL Record copied wrongly, DKIM not switched on, or the message was altered on the way
DMARC FAIL while SPF passes Alignment: the domain that passed isn’t your From domain
New newsletter tool, delivery drops Its servers aren’t in your SPF, and its DKIM isn’t set up
Mail vanished after moving to reject A legitimate sender was missing from your setup
Good setup, still lands in spam Content, sender reputation, blacklists or sudden volume. Authentication helps but doesn’t guarantee inbox placement

That last row is worth remembering.

Myths

“SPF, DKIM and DMARC guarantee my email reaches the inbox.” They don’t. They prove you are who you say you are. Whether your message goes to the inbox also depends on your sender reputation, how recipients react and what you write.

“I only send a few emails, so I don’t need this.” Small senders get filtered too, and spoofing your domain doesn’t depend on your volume.

“DMARC is only for big companies.” The basic record takes five minutes, and the reports show you if someone is faking your address.

“Set it up once and forget it.” Every time you add a tool that sends as your domain, update SPF and DKIM. Put it on your checklist for new services.

“A green tick in my email program means it’s fine.” Not necessarily. Check the headers.

A short setup checklist

FAQ

Do I need all three?

Yes. They do different jobs. SPF and DKIM authenticate; DMARC enforces and reports. With current provider requirements, you want all three.

Where do I add these records?

In the DNS settings of whoever hosts your DNS: your registrar, your host or Cloudflare. They’re all TXT records, except that your email provider tells you exactly what to paste.

Will changing these break my email?

Adding a correct record shouldn’t. The dangerous moves are adding a second SPF record, deleting one that’s in use, and tightening DMARC too soon. Make one change at a time and test after each.

How long until changes work?

Usually minutes to a few hours, depending on the record’s TTL setting.

Why does my email still go to spam?

Check authentication first, then the sending reputation of the service, the content and any blacklists. Authentication is the entry ticket, not the whole show.

Your next step

Send an email from your domain to a Gmail account today, open “Show original”, and look at those three lines. If all say PASS, you’re in good shape. If any don’t, you now know where to start. Which one failed for you?