Guide · 8 min · For Owners

SPF, DKIM and DMARC: which job each one does.

Three DNS records work together to prove that email using your domain is really from you. They are easy to confuse because they are always mentioned in one breath, but each has a separate job:

  • SPF (Sender Policy Framework, RFC 7208) is a list of the servers allowed to send mail for your domain, published as a TXT record. A receiving server checks the server that handed it the message against that list.
  • DKIM (DomainKeys Identified Mail, RFC 6376) is a signature. Your sending system signs each message with a private key, and the receiver checks the signature against a public key you publish in DNS.
  • DMARC ties both of them to the From address a person actually reads, and tells receivers what to do when a message fails. It has its own guide: DMARC policy explained.

One detail explains most of the confusion. SPF checks the envelope sender, the technical return address a person never sees, not the visible From line. A spammer can pass SPF perfectly well for a domain they own while putting your name in the From line. DMARC’s alignment rule is what closes that gap, which is why SPF and DKIM on their own are a foundation rather than a finished job.

SPF record examples.

An SPF record is a single TXT record at the root of your domain. It starts with v=spf1, lists what is allowed, and ends with an all rule for everything else.

Microsoft 365 only:

v=spf1 include:spf.protection.outlook.com ~all

Google Workspace only:

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

Microsoft 365 plus an invoicing or newsletter tool:

v=spf1 include:spf.protection.outlook.com include:spf.sendingtool.example ~all

The third example uses a placeholder. Every sending tool publishes its own include value in its setup instructions, usually under a heading like domain authentication, and that exact value is what goes in your record.

Three rules apply to every example. A domain gets exactly one SPF record, so a new tool’s include is added to the existing record rather than published separately. The record lives at the root of the domain, not on a subdomain, unless that subdomain sends its own mail. And the all rule goes last, because anything after it is ignored.

The 10-lookup limit and how to stay under it.

SPF limits a receiver to 10 DNS lookups while it evaluates your record. The limit counts nested lookups too: an include that itself contains three more includes costs four. Go over 10 and the result is a permanent error, which receivers treat as an SPF failure for every message you send.

What counts toward the 10-lookup limit
Mechanism What it matches Costs a lookup
include: Every server another domain’s SPF record allows Yes, plus whatever it includes
a and mx The addresses behind your own web or mail hostnames Yes
ptr Reverse DNS names. The standard discourages it; do not use it. Yes
exists: and redirect= Uncommon; used by some large senders Yes
ip4: and ip6: A specific address or range No
all Everything not matched earlier No

Ways to stay under the limit, in the order worth trying:

  1. Remove what you no longer use. Old newsletter platforms and retired help-desk tools are the most common dead weight.
  2. Drop a and mx unless you send from those hosts. Microsoft 365 and Google Workspace do not need them; the include already covers their servers.
  3. Rely on DKIM for tools that support it. DMARC needs only one aligned pass, so a tool that signs with your domain may not need an SPF include at all. Check the tool’s documentation before removing anything.
  4. Give heavy senders a subdomain. A newsletter platform sending from news.yourdomain.com gets its own SPF record and its own 10 lookups.

Services that flatten SPF, replacing includes with lists of IP addresses, do bring the count down. They also break quietly when a vendor changes its addresses, so treat flattening as a last resort rather than a first step.

Softfail or fail: ~all versus -all.

The all rule at the end tells receivers how to treat a server that is not on your list. -all is fail, ~all is softfail, and ?all is neutral. Never publish +all, which authorizes every server on the internet to send as you.

Guidance differs on ~all versus -all, and once DMARC is at enforcement the choice matters less than it once did, because the DMARC policy decides what happens to a failing message. The argument for ~all is forwarding. A receiver that sees -all may reject a forwarded message on SPF alone before DMARC has a chance to notice a valid DKIM signature. The argument for -all is clarity. For a domain that sends no mail at all, v=spf1 -all is the right record either way. Whichever you choose for your main domain, choose it on purpose and write down why.

DKIM: selectors, keys, and turning it on.

DKIM keys live in DNS under a selector, a name that lets one domain publish several keys at once, usually one per sending service. Microsoft 365 uses selector1 and selector2; Google Workspace uses google by default. The public key is published at selector._domainkey.yourdomain.com. Use a 2048-bit key wherever your DNS host accepts one; most split the long value into the required pieces automatically.

Microsoft 365.

Until you turn it on, Microsoft 365 signs outbound mail with your onmicrosoft.com domain. That signature passes DKIM but does not align with your own From address, so DMARC cannot count it. To sign with your own domain, open the Email authentication settings page in the Microsoft Defender portal, choose the domain on the DKIM tab, publish the two CNAME records it shows at your DNS host, and enable signing once they resolve. The two selectors let the key be rotated later without interrupting mail; rotation is a button on the same page.

Google Workspace.

In the Admin console, go to Apps, Google Workspace, Gmail, then Authenticate email. Generate a new 2048-bit record, publish it as a TXT record at google._domainkey, wait for DNS to update, and click Start authentication. Until then, Gmail signs your messages with a Google-owned domain that does not align with yours.

The third-party sender gap.

Microsoft 365 or Google Workspace is rarely the only system sending mail as your domain. Most small businesses also have some of these:

  • Accounting and invoicing software that emails invoices and statements
  • Payroll and HR platforms that send pay notices and onboarding mail
  • A CRM, a newsletter platform, and an e-signature service
  • Website contact forms and online scheduling
  • The copier’s scan-to-email and the phone system’s voicemail-to-email

Each one needs one of three things: its include added to your SPF record, DKIM signing with your domain (usually two or three CNAME records from the tool’s domain authentication settings), or a From address on a subdomain set aside for it. DKIM is the better option where a tool offers it, because it survives forwarding and does not spend SPF lookups.

The hard part is not the records. It is knowing the list. A DMARC record at p=none produces reports that show every server sending as your domain, which is the most reliable way to find the tool nobody mentioned. Asking each department one question, “what system sends email that says it is from us?”, finds most of the rest.

Managed Domain is $29 per domain per month and includes onboarding third-party senders: finding each tool and setting up its records is part of the plan.

How to check your own records.

  • From a command line. On Windows or macOS, nslookup -type=txt yourdomain.com shows your SPF record among the domain’s TXT records. Replace the name with selector1._domainkey.yourdomain.com or google._domainkey.yourdomain.com to check a DKIM key.
  • From a message you sent. Send an email to a personal Gmail account, open it, and choose Show original. Gmail lists SPF, DKIM and DMARC as pass or fail at the top. In Outlook, the Authentication-Results line in the message headers carries the same information.
  • With a free online checker. Several reputable ones will parse your SPF record, count its lookups, and flag a missing DKIM key.

If the SPF record looks right but DMARC still fails, the likely cause is alignment rather than the record itself, and the next step is the DMARC guide.

Frequently asked questions.

What is DKIM?
DKIM (DomainKeys Identified Mail) is an email authentication method: the sending system signs each message with a private key, and receivers check the signature against a public key published in your DNS. A valid signature shows the message came from someone holding your key and was not changed on the way.
What is the difference between SPF and DKIM?
SPF is a list: a DNS record naming the servers allowed to send mail for your domain. DKIM is a signature: the sending system signs each message with a private key, and receivers check it against a public key you publish in DNS. SPF checks where a message came from; DKIM checks that it was sent by someone holding your key and was not altered on the way.
Can a domain have two SPF records?
No. Two TXT records that both start with v=spf1 produce a permanent error, and receivers treat SPF as failed for every message. When a new tool asks you to add an SPF record, add its include to your existing record instead of publishing a second one.
Does DKIM encrypt my email?
No. DKIM signs a message so a receiver can confirm who sent it and that it was not changed in transit. The message itself is still readable. Encryption in transit is handled separately by TLS between mail servers, and encrypting a message’s contents is a different tool again.
Do I need SPF if DKIM is set up?
Publish both. DMARC needs only one of them to pass in alignment, but each fails in situations where the other survives: forwarding often breaks SPF, and some mailing lists that rewrite messages break DKIM. Having both gives a legitimate message two ways to pass.
Why does my SPF check return permerror?
The two usual causes are more than 10 DNS lookups once every include is expanded, and two separate SPF records on the same domain. Both make SPF fail for all of your mail, so they are worth fixing before anything else.

Your next step

Reading is the easy part — the gap closes when someone owns it. Book a free 20-minute call and we’ll walk through how this applies to your environment, in plain English.