Log in
Blog

SPF, DKIM and DMARC explained: why your emails land in spam and how to fix it

Mailboxes don't know who you are. These three DNS records are how you prove it. Here's what each one does, in plain English, with tools to build and test your own.

3 Dec 20269 min readNaheem Olaide

Why good email lands in spam

You wrote a real email to a real customer, and it went to spam. Nothing in it was spammy.

Email was built in the 1980s on trust. Any server can send a message and put any address in the From line, including yours. Mailbox providers like Gmail, Outlook and Yahoo know this, so before they put your message in front of anyone, they check three things:

  1. Is this server allowed to send for this domain? That's SPF.
  2. Was the message changed on the way? That's DKIM.
  3. If something fails, what does the domain owner want done? That's DMARC.

When these are missing or set up wrong, your real email looks exactly like a forgery. Send one below and watch the checks run.

Follow an email to the inbox

Pick a sender, then send

SPF: the guest list

SPF (Sender Policy Framework) is a list of servers allowed to send email for your domain. You publish it as one TXT record in your DNS. When a message arrives, the receiving server looks up that record and checks whether the sending server is on it.

A typical record looks like this:

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

Read it left to right: this is an SPF record, Google Workspace and SendGrid may send for us, and anything else should be treated as suspicious (~all, a soft fail) or rejected (-all, a hard fail).

Two common mistakes

The first is publishing two SPF records. You can only have one. Add a second for a new tool and both stop working. Merge them into one line instead.

The second is going over the lookup limit. SPF allows at most 10 DNS lookups. Every include costs at least one, and some providers nest more includes inside theirs. Go over 10 and receivers treat the whole record as broken. Build yours below and watch the count.

Build your SPF record

Lookup counts checked 3 Dec 2026
If a server isn't on the list
Tools that send email for you
DNS lookups0 of 10
Over the limit. Receivers will return a permanent error and your SPF check fails for every email. Remove tools you no longer use, or ask a tool for a dedicated sending subdomain.

Add this as a TXT record on yourcompany.com. Some tools, such as Amazon SES and Postmark, send from their own return address by default and don't need an include. Check each tool's setup guide.

SPF checks the hidden return address (the Return-Path), not the From address your reader sees. A newsletter tool can pass SPF for its own domain while sending as you. That gap is why DMARC exists, and we'll get to it shortly.

DKIM: the wax seal

DKIM (DomainKeys Identified Mail) works like a wax seal on an envelope. Your email provider signs each outgoing message with a private key only it holds. You publish the matching public key in your DNS. The receiving server uses that public key to check the seal.

If anything in the signed parts of the message changes in transit, even one character, the check fails. If it passes, the receiver knows two things: the message came from a server that holds your key, and nobody altered it along the way. And unlike SPF, a DKIM signature usually survives forwarding.

The seal below is real. Your browser just created a 2048-bit RSA key pair, the same kind DKIM uses. Sign the email, then change anything in it.

Sign an email, then try to tamper with it

Keys are generated in your browser
From
Subject
Public key you'd publish in DNS
selector1._domainkey.yourcompany.com TXT
"v=DKIM1; k=rsa; p=generating…"
Signature added to the email
DKIM-Signature: not signed yet
Not signed yetSign the email to put a seal on it.

Setting DKIM up

You don't create the keys yourself. In each tool that sends for you (Google Workspace, Microsoft 365, your newsletter or helpdesk tool), find the domain authentication or DKIM setting. It gives you one or more records to add to your DNS, usually under a name like selector1._domainkey. Add them, then click verify in the tool. Pick a 2048-bit key when you're given the choice.

Do this in every tool that sends as you, your main mailbox included. A tool that signs with its own domain instead of yours passes DKIM but won't help you with DMARC, which is next.

DMARC: the house rules

DMARC (Domain-based Message Authentication, Reporting and Conformance) ties SPF and DKIM to the address your reader actually sees. A message passes DMARC when at least one of these is true:

  • SPF passes and the return address domain matches the From domain.
  • DKIM passes and the signing domain (d=) matches the From domain.

That matching is called alignment, and it's the easy part to miss. A spammer can pass SPF all day for their own domain. Alignment stops them from borrowing yours.

DMARC also lets you choose what happens to messages that fail: p=none (deliver and send me reports), p=quarantine (send to spam) or p=reject (block it). Try the combinations.

DMARC simulator

From address: [email protected]
Who sent it
Your DMARC policy
CheckResultDomain checkedMatches From?

Read the reports

Add a rua address to your record and mailbox providers send you daily reports listing every server that sent mail using your domain and whether it passed. You'll find tools you forgot about, and sometimes people pretending to be you. The raw reports are XML, so most teams point them at a free or paid DMARC report reader.

Build your DMARC record

Policy

Add this as a TXT record named _dmarc.yourcompany.com. Start with Monitor.

Check an email you already sent

Every email you receive carries the results of these checks. Send yourself an email at a Gmail address, open it, click the three dots and choose Show original. In Outlook, open the message and choose View message source. Copy the headers, or just the line starting with Authentication-Results, and paste it here.

Read your email headers

Nothing you paste leaves this page

Roll it out without breaking anything

Jumping straight to p=reject is how companies block their own invoices. Go in this order and let the reports tell you when it's safe to move on.

The rules mailboxes now enforce

This stopped being optional in 2024. If your email started landing in spam in the last couple of years, these rules are a likely reason.

RequirementGmail and Yahoo (since Feb 2024)Outlook.com, Hotmail, Live (since May 2025)
Every senderSPF or DKIM, valid DNS for sending servers, TLSGood practice expected; enforcement aimed at bulk senders
Bulk sendersAround 5,000+ messages a day to Gmail. SPF, DKIM and DMARC (at least p=none), aligned with your From domainOver 5,000 messages a day. SPF, DKIM and DMARC (at least p=none), aligned
UnsubscribeOne-click unsubscribe on marketing email, honoured within 2 daysClear unsubscribe link expected
Spam complaintsKeep under 0.3%, ideally under 0.1%Low complaint rates expected

Check your Gmail standing for free in Google Postmaster Tools, and for Outlook in Microsoft SNDS. Rules change, so check each provider's sender guidelines before a big send.

Your checklist

Tick these off as you go. Your progress stays in this browser.

Common questions

Do I need all three?

Yes. SPF and DKIM prove where a message came from, and DMARC connects them to your visible From address and tells mailboxes what to do. Bulk senders are now required to have all three, and smaller senders get better placement with them.

Should my SPF end in ~all or -all?

Either works once DMARC is in place, because DMARC decides what happens to failures. ~all is the safer start while you're still finding every tool that sends for you.

Will p=reject block my own email?

Only if a tool sending as you isn't authenticated. That's why you start at p=none and read the reports first. When the reports show all your real senders passing, reject is safe.

Why does an email pass SPF and DKIM but fail DMARC?

Alignment. The tool passed the checks for its own domain, not yours. Set up custom DKIM in that tool so it signs with your domain, or a custom return path so SPF aligns.

How long do DNS changes take?

Usually minutes, sometimes up to a few hours depending on your DNS provider and TTL settings. Use the header reader above on a fresh test email to confirm.

0:00
0:00