How to set up SPF, DKIM and DMARC for a cold email domain

By the outr team9 min read

You set up SPF, DKIM and DMARC for cold email with three DNS records: one SPF TXT record at the root of your domain, the DKIM key your email provider generates for you, and a DMARC TXT record at _dmarc. Add them in that order, give each one time to work, then send a test email and read the header.

Expect a little clicking and a couple of days of waiting, nothing more. The mistakes that turn up on almost every new cold email domain are the part worth slowing down for.

Key points

  • Publish exactly one SPF record per domain; a second one makes SPF return a permanent error.
  • On Microsoft 365, mail from a custom domain is not DKIM signed until you add two CNAME records and switch signing on.
  • Google asks you to wait 48 hours after SPF and DKIM before you add DMARC.
  • Start DMARC at p=none with a rua address, and only tighten it once the reports look clean.
  • The test that counts is a header that says spf=pass, dkim=pass and dmarc=pass on a message you sent to someone else.

What SPF, DKIM and DMARC each do

Three records, three different questions a receiving mail server asks about your email.

RecordThe question it answersWhere it lives in DNS
SPFIs this server allowed to send for this domain?TXT record on the domain itself (host @)
DKIMWas this message signed by the domain, and is it unchanged?TXT or CNAME at selector._domainkey
DMARCDoes the visible From domain match what SPF or DKIM checked, and what should happen if not?TXT record at _dmarc

SPF is a list of senders. Per RFC 7208, it must be published as a TXT record and has to start with exactly v=spf1.

DKIM is a signature. Your provider signs every message with a private key, and the public key sits in DNS under a name made of a selector plus _domainkey. The selector exists so a domain can have several keys at once, which is why RFC 6376 says the key namespace "is subdivided using selectors".

DMARC ties the two to the address people actually see. A message passes DMARC when SPF or DKIM passes for a domain that aligns with the From address. By default alignment is relaxed, which under RFC 9989, the current DMARC standard, means the two domains only need the same organizational domain. So mail.example.com and example.com align; example.com and example.onmicrosoft.com do not.

Do you need all three for cold email?

Yes. Set up all three, even if you plan to send a few dozen emails a day.

Strictly, Google's email sender guidelines only ask all senders to "set up SPF or DKIM", and add DMARC for people sending 5,000 or more messages a day. Yahoo's sender best practices split the same way: SPF or DKIM for everyone, and for bulk senders both of them plus "a valid DMARC policy with at least p=none". The full list, including spam rate and unsubscribe rules, is in our guide to the Google and Yahoo sender requirements.

But a brand new domain has no history to vouch for it, and missing records are one of the few problems you can fix in an afternoon. Do it before the first email goes out.

The order to set them up in

  1. Set up your mailboxes first (Google Workspace or Microsoft 365) and verify the domain with them. DKIM keys are generated inside the provider, so it has to exist before anything else.
  2. Add SPF.
  3. Turn on DKIM.
  4. Wait. Google's own DMARC setup page says to "allow 48 hours after setting up SPF and/or DKIM before setting up DMARC".
  5. Add DMARC at p=none.
  6. Send a test and read the header.

One timing trap on Google Workspace: on a fresh account, Google's DKIM page says you may need to wait 24 to 72 hours before the DKIM key is available in the Admin console. If the button is not there yet, that is why. Add SPF, go do something else, come back tomorrow.

Step 1: add your SPF record

Go to your DNS panel (wherever you bought the domain, or Cloudflare if you moved it there) and add a TXT record. For the host, use @, which means the root domain itself.

If you send only through Google Workspace, this is the value from Google's SPF page:

Type:  TXT
Host:  @
Value: v=spf1 include:_spf.google.com ~all

If you send only through Microsoft 365, this is the value from Microsoft's SPF page:

Type:  TXT
Host:  @
Value: v=spf1 include:spf.protection.outlook.com -all

Notice the ending. Google writes "Google recommends you use ~all", which is a soft fail: servers not on the list are probably not allowed. Microsoft recommends -all, a hard fail, because it expects you to run DKIM and DMARC as well. Both are valid SPF. Use the one your provider recommends and move on; this is not where cold email lives or dies.

If anything else sends email as your domain, it goes in the same record, never a new one. Google's own example for Workspace plus Microsoft looks like this:

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

Each extra service gives you its own include: value in its setup docs. Every include: costs at least one DNS lookup, and SPF stops at 10. If your record is getting long, read how to fix the SPF 10 lookup limit before you add the next tool.

Google says SPF can take up to 48 hours to start working.

Step 2: turn on DKIM

DKIM is the one you cannot type from memory. Your provider generates the key, and you copy it into DNS.

DKIM in Google Workspace

From Google's DKIM instructions:

  1. In the Google Admin console, go to Menu, then Apps, Google Workspace, Gmail, and click Authenticate email.
  2. Pick your domain and generate a new record. Choose 2048-bit if your DNS host supports it. Google: "Longer keys are more secure than shorter keys."
  3. Leave the selector as google, the default and recommended prefix.
  4. Copy the TXT value into your DNS panel.
  5. Back in the Admin console, click Start authentication.

The record ends up looking like this (your key will be much longer):

Type:  TXT
Host:  google._domainkey
Value: v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOC...

Paste the whole value. Once it works, the Admin console status changes to "Authenticating email with DKIM". Google says DKIM can take up to 48 hours to start after you add the key.

DKIM in Microsoft 365

This is the one people miss. Microsoft's DKIM page is blunt about it: for custom domains, "no DKIM signing occurs for outbound mail" until you set it up. Without a DKIM signature from your own domain, DMARC can only pass on SPF.

The fix:

  1. Open the Defender portal at security.microsoft.com, go to Email and collaboration, Policies and rules, Threat policies, Email authentication settings, and open the DKIM tab.
  2. Click your domain. The details panel shows two CNAME records under Publish CNAMEs.
  3. Create both at your DNS host. They look like this (copy yours from the portal, the exact values differ per tenant):
Type:  CNAME
Host:  selector1._domainkey
Value: selector1-example-com._domainkey.example.n-v1.dkim.mail.microsoft

Type:  CNAME
Host:  selector2._domainkey
Value: selector2-example-com._domainkey.example.n-v1.dkim.mail.microsoft
  1. Go back to the panel and switch on "Sign messages for this domain with DKIM signatures". The status should change to "Signing DKIM signatures for this domain".

Microsoft says it takes "a few minutes (or possibly longer)" to detect the new records. If the toggle complains, wait an hour and try again.

If you ever need to look up which selector a domain uses, or check a key by hand, see how to find your DKIM selector.

Step 3: add DMARC, starting at p=none

Once SPF and DKIM have had their 48 hours, add one more TXT record:

Type:  TXT
Host:  _dmarc
Value: v=DMARC1; p=none; rua=mailto:dmarc@example.com

What each part does:

  • v=DMARC1 marks it as a DMARC record. RFC 9989 says it "MUST be the first tag".
  • p=none asks receivers to take no special action on mail that fails. You are watching, not blocking.
  • rua= is where receivers send daily aggregate reports. Google says the tag is optional but "Google recommends you always include it". Use a real mailbox you will actually open, or a DMARC report service.

Start at p=none. Really. Both Google and Microsoft tell you to begin there, read the reports, and only then move to quarantine and later reject. When to move, and whether a cold email domain should ever go to reject, we cover in DMARC p=none, quarantine or reject.

How to check it worked

Do two checks: one on DNS, one on a real message.

The DNS check. On a Mac or Linux terminal:

dig TXT example.com +short
dig TXT google._domainkey.example.com +short
dig TXT _dmarc.example.com +short

On Windows, nslookup -type=TXT _dmarc.example.com does the same job (Microsoft uses exactly that command in its DMARC troubleshooting table). For Microsoft 365 DKIM, query selector1._domainkey.example.com instead of google._domainkey. You should see one SPF line, one DKIM key, and one DMARC line. Two SPF lines is a problem, see below.

If you would rather not use a terminal, check your domain's records with our free checker. It reads SPF, DKIM, DMARC and MX live and gives you a corrected record to paste if something is off.

The message check. DNS can look perfect while signing is still switched off, so send a real email. Send it to a Gmail address that is not your own sending inbox; Google notes that sending to yourself won't verify DKIM. In Gmail, open the message, click More next to Reply, then Show original. Look for the Authentication-Results lines. Trimmed down, you want to see this, with your own domain:

Authentication-Results: mx.google.com;
  dkim=pass header.i=@example.com header.s=google;
  spf=pass smtp.mailfrom=you@example.com;
  dmarc=pass header.from=example.com

The detail that matters is the domain next to dkim=pass. If it says onmicrosoft.com or a sending tool's domain instead of yours, DKIM passed for someone else and does nothing for your DMARC.

Common mistakes on a new cold email domain

Two SPF records

The single most common one. Someone adds v=spf1 include:_spf.google.com ~all, then a year later a new tool says "add this SPF record" and they add a second TXT line instead of editing the first. RFC 7208 is clear that if the lookup finds more than one record, the result is permerror. Microsoft puts it plainly: "only one SPF record is allowed per domain or subdomain." Merge them into one record with both include: values.

Forgetting a sending service

Every service that sends with your domain in the From address needs to be in SPF or sign with your DKIM key, ideally both. That includes the cold email tool, the CRM that sends sequences, the invoicing app, the form on your site. Google warns that otherwise "messages sent by the new senders could be marked as spam." Make a list of everything that sends as you before you write the record, not after a bounce.

Jumping straight to p=reject

It feels secure. On a domain where you have not yet seen a single DMARC report, it is a guess. If one tool is not aligned, reject tells receivers to refuse that mail, and you find out from a confused prospect, not from a report. Microsoft's own rollout plan goes none, then quarantine, then reject, with monitoring at each step.

Microsoft 365 DKIM never switched on

Covered above, but it is so quiet it earns its own line. SPF passes, nothing errors, and your domain is simply not signing. Check the header.

Small typos that break the record

Microsoft lists the usual ones: a trailing full stop after the domain (include:spf.protection.outlook.com.), an equals sign instead of a colon (include=), or a space after the colon. A DMARC record on the root domain instead of _dmarc is another. So is a rua address on a different domain: Microsoft notes that the receiving domain must publish an authorization record, or reports are not delivered.

Treating setup as one and done

Give it six months and someone may have added a tool, a DNS migration may have dropped a TXT line, or a key may have been rotated. outr checks SPF, DKIM, DMARC and MX on every connected domain every day for exactly this reason. Without it, rerun the checks above once a month.

Questions people ask

How long does SPF, DKIM and DMARC take to start working?

Google says SPF and DKIM can each take up to 48 hours to start working after you add the records, and asks you to wait 48 hours after them before adding DMARC. On a new Google Workspace account, the DKIM key itself may not be available for 24 to 72 hours. Microsoft says 365 takes a few minutes, or possibly longer, to detect DKIM CNAME records.

Should I use ~all or -all in my SPF record?

Google recommends ~all for Google Workspace and Microsoft recommends -all for Microsoft 365. Both are valid under the SPF standard: ~all is a soft fail, -all a hard fail. Use your provider's recommendation, and make sure DKIM and DMARC are in place, since they matter more for alignment.

Can I have two SPF records if I use two email services?

No. A domain must have one SPF record, and two make SPF fail with a permanent error. Put both services in one record, for example v=spf1 include:_spf.google.com include:spf.protection.outlook.com ~all.

Do I need DMARC if I send fewer than 5,000 emails a day?

Google's guidelines only require DMARC from senders of 5,000 or more messages a day to Gmail, and Yahoo only requires it from bulk senders. Add it anyway at p=none: it costs one DNS record, and the reports show you every service sending as your domain.

What DMARC policy should a new cold email domain use?

Start with p=none and a rua address so you receive reports. Google and Microsoft both recommend starting there and moving to quarantine or reject only after the reports show your real mail passing.

Sources

  1. Email sender guidelines, Google Workspace Admin Help
  2. Sender best practices, Yahoo
  3. Set up SPF, Google Workspace Admin Help
  4. Set up DKIM, Google Workspace Admin Help
  5. Set up DMARC, Google Workspace Admin Help
  6. View full email headers, Gmail Help
  7. Set up SPF for your Microsoft 365 domain, Microsoft Learn
  8. How to use DKIM for email in your custom domain, Microsoft Learn
  9. Set up DMARC to validate email in Microsoft 365, Microsoft Learn
  10. RFC 7208: Sender Policy Framework (SPF)
  11. RFC 6376: DomainKeys Identified Mail (DKIM) Signatures
  12. RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)

Written by the outr team

We build outr, an AI sales team that sends from your own inboxes and drafts every reply for you to approve. Every figure in this article links to the page it comes from, listed above.

Read next

An AI sales team in your own inbox

Our AI-driven SDR researches every lead, writes every email and follows up until they answer.