SPF, DKIM and DMARC: How to Set Up Email Authentication
SPF, DKIM and DMARC are three DNS (Domain Name System) records that let a receiving mail server check that an email really comes from your domain. SPF lists the servers allowed to send as you, DKIM adds a signature to each message, and DMARC tells the receiver what to do when those checks fail.
To set them up you need a login to your DNS provider and a list of every service that sends email from your domain. Add them in this order: SPF, then DKIM, then DMARC.
Why SPF, DKIM and DMARC matter
Without these records, anyone can put your domain in the From line of an email, a trick called spoofing. With them, a receiving server can tell your real emails from forgeries and decide what to do with the forgeries.
The large mailbox providers now require them. Google's email sender guidelines ask every sender for SPF or DKIM. Anyone sending more than 5,000 messages a day to Gmail needs SPF, DKIM and a DMARC record. Yahoo asks the same of bulk senders without naming a volume.
Outlook.com applies the same rule to domains sending more than 5,000 messages a day. Since 5 May 2025 it has rejected their failing email with the error "550; 5.7.515 Access denied" (Microsoft, 2025). Each provider's rules sit side by side in what Google, Yahoo and Microsoft require from senders.
What is SPF?
SPF (Sender Policy Framework) is a TXT (text) record in your DNS that lists the servers allowed to send email for your domain. A receiving server reads it like a guest list at the door.
The check runs in four steps:
- You publish the SPF record, listing the IP (internet protocol) addresses or services that send for you.
- An email arrives, and the receiving server reads the domain in its Return-Path, the hidden address that bounces go back to.
- It looks up that domain's SPF record and checks whether the sending server's IP address is on it.
- If it is, SPF passes. If not, SPF fails, and what happens next depends on the receiver and on your DMARC policy.
SPF checks the Return-Path domain, not the From address your reader sees. That gap is the reason DMARC exists, and the Return-Path has its own explainer.
A typical SPF record looks like this:
v=spf1 ip4:192.0.2.10 include:_spf.example.com ~all
| Part | Meaning |
|---|---|
| v=spf1 | SPF version 1 |
| ip4:192.0.2.10 | This IP address may send |
| include:_spf.example.com | Servers listed in that domain's SPF record, such as an email platform's, may send |
| ~all | Mail from any other server gets a "soft fail" |
| -all | Used instead of ~all: mail from any other server fails outright |
Start with ~all. A soft fail marks unlisted mail as suspicious rather than failing it outright, so a forgotten service keeps its email while you check. Move to -all once every source is listed.
How to set up SPF
- List every service that sends email from your domain: your office email (Google Workspace or Microsoft 365), your email marketing platform, your online shop, your CRM (customer relationship management system) and any booking or invoicing tool.
- Ask each service whether it needs an
includein your root SPF record. Some do; others send from a bounce subdomain of their own and need none. - At your DNS provider, create or edit one TXT record on
@(your root domain) that names all of them. - Check it with a lookup tool such as MXToolbox, which shows whether the record is valid and how many DNS lookups it uses.
For a business on Google Workspace that also uses one other service, the record reads:
v=spf1 include:_spf.google.com include:_spf.example.com ~all
Common SPF mistakes
Two SPF records on one domain is the most common. RFC 7208, the Request for Comments (RFC) that defines SPF, treats two records as an error, so neither works.
Add a new service to the existing record instead of creating a second one.
The standard also caps an SPF check at 10 DNS lookups, and each include uses at least one. Remove services you no longer use before adding new ones.
A missing colon or a stray space breaks the record without any warning. Run the lookup again after every edit.
What is DKIM?
DKIM (DomainKeys Identified Mail) is a digital signature added to each email, which proves the message came from your domain and was not changed on the way. It has nothing to do with the email signature you type at the bottom of a message.
The sending server signs each email with a private key. The receiving server fetches the matching public key from your DNS and checks the signature; if they match, DKIM passes.
| SPF | DKIM | |
|---|---|---|
| What it checks | The sending server's IP address | A signature over the message |
| Where it lives | One TXT record on the Return-Path domain | A public key under a selector, such as s1._domainkey |
| Forwarded email | Usually fails, because the forwarding server is not on your list | Usually survives, as long as the message is not changed |
| Changed content | Not checked | The signature fails |
Forwarding is why you want both. A message your customer forwards to a colleague loses SPF but keeps its DKIM signature.
How to set up DKIM
Your email platform or office email service creates the key pair and shows you a DNS record to publish. The private key stays with the service.
- Find the DKIM setting in each service that sends for you. Google Workspace and Microsoft 365 each have their own; an email platform shows its records when you add a sending domain.
- Publish each record exactly as shown. It is either a TXT record holding the public key or a CNAME record pointing to the service's key.
- Turn signing on in the service, if it has a switch for it.
- Send yourself a test and open the email headers.
dkim=passfollowed by your own domain means it works.
Authentication-Results: mx.example.net; dkim=pass header.d=yourcompany.co.uk
dkim=fail usually means the key in DNS does not match the signing key. A character lost while pasting the record is a common cause.
If you run your own mail server, you generate the keys yourself. RFC 8301 asks for RSA keys of at least 1024 bits and recommends 2048.
What is DMARC?
DMARC (Domain-based Message Authentication, Reporting and Conformance) is a TXT record that tells receiving servers what to do with email that fails authentication for your domain, and where to send reports. It adds the check SPF and DKIM lack: the domain they pass for must match the From address.
To pass DMARC, SPF or DKIM must pass for a domain that aligns with the From domain. Relaxed alignment, the default, accepts a subdomain, so bounce.yourcompany.co.uk aligns with yourcompany.co.uk; strict alignment needs an exact match (Google, Set up DMARC).
The reports are the useful part at first. They list every server sending as your domain and whether it passes, including services you had forgotten.
| Policy | What the receiver is asked to do with failing mail | When to use it |
|---|---|---|
p=none | Deliver as normal and report | The first weeks, while you read reports |
p=quarantine | Treat it as suspicious, usually the spam folder | Once every legitimate source passes |
p=reject | Refuse the message | Once quarantine has run without surprises |
What each tag does and when to switch is covered in DMARC policy: none, quarantine and reject.
How to set up DMARC
- Make sure SPF or DKIM passes for every service that sends as you. Google suggests waiting 48 hours after setting up SPF and DKIM before adding DMARC.
- Create a mailbox for reports, such as
[email protected]. Reports arrive as XML (Extensible Markup Language) files, and a DMARC report reader turns them into a readable table. - Add a TXT record named
_dmarcthat starts in monitoring mode. - Read the reports for a few weeks and fix every legitimate source that fails.
v=DMARC1; p=none; rua=mailto:[email protected]
| Tag | Meaning |
|---|---|
| v=DMARC1 | DMARC version; always first |
| p | Policy for your domain: none, quarantine or reject |
| rua | Where aggregate reports go |
| sp | Policy for subdomains; without it, they follow p |
| t=y | Test mode: receivers apply one level below your policy |
A subdomain that sends its own email, such as newsletter.yourcompany.co.uk, needs its own SPF record, and its own DKIM key if its mail is signed with the subdomain's name. For DMARC it follows your sp tag, or p when there is no sp, unless it publishes a record of its own.
How to tighten the DMARC policy
Move one level at a time, none to quarantine to reject, and read the reports between each step. A policy of quarantine or reject is also required for a BIMI logo in Gmail and Yahoo.
Older advice phases a policy in with pct=10, then 25 and 50. RFC 9989, the DMARC standard published in May 2026, lists pct as historic (RFC 9989). Its replacement is t=y, which asks receivers to apply one level below the policy you publish while you test.
v=DMARC1; p=quarantine; t=y; rua=mailto:[email protected]
Receivers built on the older standard may ignore t, so treat it as a signal rather than a safety net. You can also tighten one subdomain first, as RFC 9989's own example does before moving it to reject.
How SPF, DKIM and DMARC work together
Take an email campaign sent from [email protected] through an email platform.
- The platform adds your DKIM signature and sets the Return-Path to
bounce.yourcompany.co.uk. - The receiving server checks SPF for
bounce.yourcompany.co.uk: the platform's server is listed, so SPF passes. - The DKIM signature verifies, so DKIM passes too.
- It reads your DMARC record. Both checks passed for domains that align with
yourcompany.co.uk, so DMARC passes.
Now a forger sends as [email protected] from their own server. That server is not in your SPF record and cannot sign with your key, so both checks fail. With p=reject, the receiver refuses the email and your customers never see it.
So do you need DMARC if SPF and DKIM already pass? Yes. Neither check looks at the From address your customers see, and neither tells the receiving server what to do when it fails; DMARC does both.
SPF, DKIM and DMARC on a MailGraf sending domain
In MailGraf, what you add to DNS depends on the kind of sending domain you choose under Settings > Senders (Add a sending domain).
| Sending domain | What you add at your DNS provider | DMARC |
|---|---|---|
MailGraf domain, such as yourbrand.postgraf.net | Nothing | MailGraf creates it |
Your subdomain, such as news.yourbrand.com | 4 nameserver (NS) records; MailGraf then manages DKIM, SPF and DMARC | MailGraf creates it |
Your root domain, such as yourbrand.com | The records listed in MailGraf, usually 3 CNAME (alias) records, 1 MX (mail exchange) record and 1 TXT record | You add it |
Your existing website and email records stay as they are. For a root domain with no DMARC record yet, add a TXT record named _dmarc with v=DMARC1; p=none. Until you do, the checks on a campaign's Review step show No DMARC record on this domain.
Before choosing a platform, you can compare MailGraf's monthly plans.
Keeping the records working
Authentication breaks quietly when the services around it change. Check the records whenever you add or drop a tool:
- SPF: remove services you no longer use, and add new ones to the same record.
- DKIM: rotate keys when your provider offers it, and delete keys for services you have left.
- DMARC: read the reports; a server you do not recognise is either a forgotten tool or a forger.
- Reputation: once authentication passes, bounces and spam complaints decide your sender reputation.
If every record passes and email still lands in spam, the cause is usually the list or the content rather than DNS. Why emails go to spam walks through those causes.
Originally published: Apr 9, 2026


