schedule 15-min read

How to Set Up DKIM: Microsoft 365, Google Workspace and ESPs

DMARC AI editorial team · Last updated

Step-by-step DKIM setup for Microsoft 365, Google Workspace and email service providers, with record examples, verification checks and an MSP rollout list.

01

How do you set up DKIM?

To set up DKIM, list every service that sends mail as your domain, generate or enable a signing key in each one, publish the public key (a TXT record or the CNAMEs the service gives you) under selector._domainkey.yourdomain, switch signing on, then confirm dkim=pass with a header.d= that matches your From domain.

The detail is in the platforms: Microsoft 365 uses two CNAMEs and a portal toggle, Google Workspace one TXT record, and most email service providers (ESPs) CNAMEs that delegate the key to them. This guide covers each, then verification, common errors and a rollout checklist for MSPs (managed service providers). If you want the concept first, read what DKIM is and why DMARC depends on it, or start at the DKIM pillar guide.

02

Key takeaways

  • DKIM is set up per sending service, not per domain. A domain using Microsoft 365, a newsletter tool and a CRM needs three separate DKIM configurations, each with its own selector.
  • Microsoft 365 does not sign mail with your custom domain until you enable it. Since May 2025, new custom domains get a different CNAME target format, so always copy the values Microsoft shows you rather than a template.
  • Google Workspace defaults to the google selector and lets you choose a 2048-bit key. Allow up to 48 hours before authentication starts working.
  • For DMARC, DKIM only counts when the signing domain (d=) aligns with the From domain. A pass on the ESP's own domain does not help.
  • Verify with DNS, then with real message headers, then with DMARC aggregate reports. All three should agree before you tighten the DMARC policy.
03

What are the universal steps for setting up DKIM on any platform?

Every DKIM setup follows the same five steps: inventory senders, create a key, publish it in DNS, enable signing, and verify alignment. Platforms differ only in where the buttons are and whether you publish a TXT record yourself or CNAMEs that point at a key the provider manages.

  1. Inventory every sender. The reliable source is your DMARC aggregate reports (rua). Publish p=none with a reporting address if you do not have reports yet, and let them run for a couple of weeks. Every source IP that sends as your domain shows up, including the ones nobody remembered. Our guide to DMARC aggregate reports explains how to read them.
  2. Generate or enable a key in each sending platform. Choose 2048-bit RSA where the platform allows it. RFC 8301 says signers "MUST use RSA keys of at least 1024 bits" and "SHOULD use RSA keys of at least 2048 bits", and the UK NCSC DKIM guidance also recommends 2048-bit keys.
  3. Publish the record. Either a TXT record containing the public key, or one or more CNAMEs that point to the provider's key. The name is always <selector>._domainkey.<domain>, as defined in RFC 6376.
  4. Enable signing in the platform. Publishing DNS alone does nothing; the platform must start adding a DKIM-Signature header.
  5. Verify alignment. Check the header of a test message and then your aggregate reports. Under RFC 9989, the DMARC standard that obsoletes RFC 7489, a DKIM pass only produces a DMARC pass when the signing domain shares the From domain's Organizational Domain (relaxed alignment, the default for adkim).

A self-hosted TXT key looks like this:

s2026._domainkey.example.co.uk.  3600  IN  TXT  ( "v=DKIM1; k=rsa; "
    "p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu3x..."
    "...remainder-of-the-2048-bit-public-key...IDAQAB" )

A provider-managed key is a delegation instead:

s1._domainkey.example.co.uk.  3600  IN  CNAME  s1.domainkey.u1234567.wl123.sendgrid.net.

04

How do you set up DKIM in Microsoft 365?

In Microsoft 365 you create two CNAME records (selector1._domainkey and selector2._domainkey) and then enable signing for the domain in the Microsoft Defender portal or with Exchange Online PowerShell. Microsoft states that outbound mail from custom domains is not DKIM signed with that domain until you do this.

Microsoft's article Set up DKIM to sign mail from your Microsoft 365 domain (formerly titled "Use DKIM to validate outbound email sent from your custom domain") is the reference. Only the initial *.onmicrosoft.com domain is signed automatically.

Portal route

  1. Go to the Defender portal at security.microsoft.com, then Email & collaboration > Policies & rules > Threat policies > Email authentication settings, and open the DKIM tab.
  2. A domain that has never been configured shows the status NoDKIMKeys ("No DKIM keys saved for this domain" in the flyout). Try to slide the Toggle to Enabled. A Client error dialog appears containing the CNAME values; select OK.
  3. The status is now CnameMissing. Open the domain's flyout and copy the two values in Publish CNAMEs.
  4. Create both CNAMEs at the client's DNS host.
  5. After Microsoft detects them (a few minutes or longer), return to the flyout and turn on Sign messages for this domain with DKIM signatures. The status should change to Signing DKIM signatures for this domain.

Which CNAME format does Microsoft use now?

New custom domains added since May 2025 use a new target format; existing custom domains keep the old one. Microsoft documents the two side by side, and notes that "the old and new formats can't coexist for the same selector".

; Old format (existing custom domains)
selector1._domainkey  CNAME  selector1-example-co-uk._domainkey.contoso.onmicrosoft.com
selector2._domainkey  CNAME  selector2-example-co-uk._domainkey.contoso.onmicrosoft.com

; New format (custom domains added from May 2025)
selector1._domainkey  CNAME  selector1-example-co-uk._domainkey.contoso.n-v1.dkim.mail.microsoft
selector2._domainkey  CNAME  selector2-example-co-uk._domainkey.contoso.n-v1.dkim.mail.microsoft

In the new format, the character before -v1 is a partition character that Microsoft generates (for example r or n) and you cannot choose it. So never copy a CNAME from another tenant or an old runbook; take the values from the portal or PowerShell every time.

PowerShell route

For MSPs working across many tenants, PowerShell is faster and easier to document in change control:

# Create keys (signing stays off until the CNAMEs exist)
New-DkimSigningConfig -DomainName example.co.uk -KeySize 2048 -Enabled $false

# Read the exact CNAME targets to publish
Get-DkimSigningConfig -Identity example.co.uk | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME

# After the CNAMEs resolve, switch signing on
Set-DkimSigningConfig -Identity example.co.uk -Enabled $true

Pass -KeySize 2048 explicitly: Microsoft documents 1024 as the default for New-DkimSigningConfig. If a domain already signs with 1024-bit keys, Rotate-DkimSigningConfig -Identity example.co.uk -KeySize 2048 moves to 2048-bit, but Microsoft notes the change applies to the next active selector first, and a rotation takes four days (96 hours) to complete. Our guide on rotating DKIM keys safely covers the timing.

Two Microsoft specifics worth knowing: only one of the two selectors is active at a time, and if the client uses Cloudflare, Microsoft says to set the CNAMEs to DNS only, because a proxied record will not resolve as a CNAME. For DMARC-specific Microsoft 365 work, see the Microsoft 365 MSP implementation guide.

05

How do you set up DKIM in Google Workspace?

In Google Workspace you generate a key in the Admin console under Apps > Google Workspace > Gmail > Authenticate email, publish it as a TXT record at google._domainkey, then click Start authentication. Google says it can take up to 48 hours for DKIM to start working.

The steps from Google's Set up DKIM page:

  1. Sign in with an account that has the Gmail Settings administrator privilege and open Authenticate email. If Gmail was only just turned on, Google says you may need to wait 24 to 72 hours before a key can be generated.
  2. Select the domain and click Generate new record. Choose 2048 if the DNS host supports 2048-bit keys, or 1024 if it does not. Keep the default prefix selector google unless the domain already uses that selector for something else.
  3. Copy the TXT record name and value and publish them at the DNS host:

google._domainkey.example.com.  3600  IN  TXT  ( "v=DKIM1; k=rsa; "
    "p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn5q..."
    "...remainder-of-the-key...IDAQAB" )

  1. Return to Authenticate email and click Start authentication. The status should read "Authenticating email with DKIM".

Google's DKIM troubleshooting page notes that most DNS hosts limit a single TXT string to 255 characters, so a 2048-bit key is entered as several quoted strings, as above. It also warns that the Admin console may show "You must update the DNS records for this domain" for up to 48 hours, which you can ignore if the record is correct. Each additional domain or alias domain in the tenant needs its own key. For the SPF side of a Workspace domain, see the Google Workspace SPF record explained.

06

How do you set up DKIM for an ESP such as SendGrid, Mailchimp or Amazon SES?

Most ESPs use CNAME delegation: you add the CNAME records shown in the ESP's domain authentication screen, the ESP hosts the actual public key, and it signs your mail with d= set to your domain. This lets the ESP rotate keys without asking you to change DNS again.

The pattern is the same everywhere, but the record count and selector names differ, and the values are account-specific:

  • Twilio SendGrid domain authentication with automated security creates three CNAMEs: a return-path subdomain plus s1._domainkey and s2._domainkey. SendGrid uses the two selectors interchangeably and activates one at a time. Details in our SendGrid setup guide.
  • Mailchimp shows two CNAMEs (labelled CNAME 1 and CNAME 2) in its domain authentication instructions, plus a DMARC TXT record if one is missing. See authenticating Mailchimp marketing email.
  • Amazon SES Easy DKIM requires three CNAMEs of the form token._domainkey.example.com, pointing to a hosted zone that AWS says varies by Region. Use the values returned for the identity. See the Amazon SES implementation guide.

The critical check for any ESP is the signing domain. Many ESPs sign with their own domain by default until you complete domain authentication. That passes DKIM but fails DMARC alignment, which is exactly why a sender can look "authenticated" in its dashboard and still fail in your reports.

07

Where is DKIM enabled on each platform?

The table below summarises the main platforms. Selector names and record counts are the platform defaults at the time of writing; always publish the exact values the platform generates for that domain.

Platform Where to enable Record type Selector(s) Key size
Microsoft 365 Defender portal > Email authentication settings > DKIM, or New-DkimSigningConfig / Set-DkimSigningConfig 2 x CNAME selector1, selector2 1024 or 2048 (PowerShell default 1024)
Google Workspace Admin console > Apps > Google Workspace > Gmail > Authenticate email 1 x TXT google (changeable) 2048 or 1024
Twilio SendGrid Sender authentication > Domain authentication 3 x CNAME (automated security) s1, s2 Managed by SendGrid
Mailchimp Domain authentication in account settings 2 x CNAME Shown in account Managed by Mailchimp
Amazon SES Verified identity > DKIM (Easy DKIM) 3 x CNAME Generated tokens Managed by SES (or bring your own with BYODKIM)
Exchange Server on-premises No native signing: a signing agent or outbound gateway TXT Chosen by you 2048 recommended
Zoho Mail Zoho Mail Admin Console, per domain TXT Chosen by you Per Zoho console

For the last two rows, see our guides to DKIM for Exchange Server on-premises and Zoho Mail SPF, DKIM and DMARC setup.

08

How do you verify that DKIM is working?

Verify in three layers: confirm the record resolves in DNS, confirm a real message carries a DKIM-Signature whose d= is your domain, and confirm the receiver's Authentication-Results header shows dkim=pass with a matching header.d=. Then watch aggregate reports for a week. Our guide on how to check if DKIM is working goes deeper on each check, including Gmail and Outlook steps and what every result value means.

1. DNS. Query the selector directly:

dig +short CNAME selector1._domainkey.example.co.uk
dig +short TXT google._domainkey.example.com
dig +short TXT s1._domainkey.example.co.uk

A CNAME setup should return the provider's target, and following it should return a TXT record starting v=DKIM1. Our DKIM validator and DNS lookup tool do the same in a browser.

2. The signature. Send a test message to a mailbox you control and open the original source. Look for:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.co.uk;
 s=selector1; h=From:Date:Subject:Message-ID; bh=...; b=...

Check d= (must be your domain or a subdomain of it), s= (the selector you just published) and a=rsa-sha256 (RFC 8301 says rsa-sha1 "MUST NOT be used").

3. The verdict. The receiver adds something like:

Authentication-Results: mx.example.net;
 dkim=pass header.d=example.co.uk header.s=selector1;
 spf=pass smtp.mailfrom=example.co.uk;
 dmarc=pass header.from=example.co.uk

If dkim=pass shows header.d=sendgrid.net or header.d=contoso.onmicrosoft.com while the From is example.co.uk, DKIM is working but not aligned. Paste full headers into the email header analyzer or follow how to read email headers.

09

What are the most common DKIM setup errors?

Most DKIM failures after setup come from DNS entry mistakes, signing never being switched on, or something modifying the message after it was signed. The table lists the errors we see most and how to fix each.

Symptom Likely cause Fix
Microsoft 365 status stuck on CnameMissing CNAME not yet visible, wrong target, or old/new format mixed Re-copy values from Get-DkimSigningConfig; check with dig; wait and recheck
Record found at selector._domainkey.example.com.example.com DNS host appends the zone name automatically Enter only selector._domainkey as the host name
dkim=fail (body hash did not verify) Footer, disclaimer or gateway rewrote the message after signing Add footers before signing, or sign at the last hop; see how gateways affect DKIM
dkim=none (message not signed) Signing toggle never enabled Turn on signing in the platform, then resend
dkim=temperror Key lookup timed out or the DNS host returned an error Check the DNS host's health and the record's syntax
TXT record rejected or truncated 2048-bit key in one string over 255 characters Split into multiple quoted strings, or ask the host about long TXT support
CNAME fails to resolve on Cloudflare Record proxied (orange cloud) Set to DNS only
DKIM passes, DMARC fails d= is the ESP's domain, not yours Complete the ESP's domain authentication; see why DMARC fails when SPF passes

Google also notes that Gmail checks only the first five DKIM signatures on a message, so a long chain of signing hops can push the aligned signature out of range.

10

How should an MSP roll out DKIM across a client portfolio?

Treat DKIM as a tracked change per domain and per sender, not a one-off ticket. Start from DMARC report data, script the Microsoft 365 work, record every selector you publish, and only tighten DMARC policy once reports show aligned DKIM for each legitimate source.

A rollout checklist that works across many tenants:

  1. Monitor first. Make sure each client domain has a DMARC record at p=none with an aggregate report address, and collect at least two weeks of data. The DMARC onboarding checklist for MSP clients covers this stage.
  2. Build a sender inventory per domain. For each source in the reports: platform, owner at the client, current DKIM result and current d=.
  3. Fix the mailbox platform first. Microsoft 365 or Google Workspace usually carries most of the volume. For Microsoft 365, script Get-DkimSigningConfig across tenants to find domains still at NoDKIMKeys or CnameMissing.
  4. Then each ESP, CRM and line-of-business sender. Get the client's admin to complete domain authentication; you publish the records.
  5. Log every selector in your documentation: domain, selector, platform, key size, date published, date of last rotation. Orphaned selectors are hard to clean up later; our DKIM selector guide explains why.
  6. Verify with headers and reports, not just with the platform's green tick.
  7. Move policy. Once every legitimate source shows aligned DKIM or SPF, progress from p=none to p=quarantine to p=reject. RFC 9989 removed pct, so there is no percentage rollout; the t=y testing flag is available if you need it.
  8. Schedule rotation. NCSC suggests rotating keys every 12 months. Provider-managed CNAME setups rotate on the provider's side.
  9. Do not publish DKIM on parked domains. Microsoft advises against it, because the absence of a public key means forged signatures cannot validate. Protect parked domains with a reject DMARC policy and a null SPF record instead.

DKIM management for MSPs covers the ongoing operational problems once the rollout is done.

11

FAQ

How long does DKIM take to start working?

It depends on the platform and your DNS TTL. Microsoft says detection of new CNAMEs takes a few minutes or longer and DNS propagation can take up to 48 hours. Google says DKIM can take up to 48 hours to start working after you add the key. ESPs usually verify within minutes to hours once records resolve.

Should I use a 1024-bit or 2048-bit DKIM key?

Use 2048-bit wherever the platform and DNS host support it. RFC 8301 sets 1024 bits as the minimum and recommends at least 2048, and the NCSC also recommends 2048-bit keys. Use 1024 only if your DNS host cannot store a longer TXT record, and plan to upgrade. The full comparison, including Ed25519 and how to check an existing key, is in DKIM key length: 1024 vs 2048.

Can a domain have more than one DKIM record?

Yes. Each sending service uses its own selector, so a domain can have selector1, google, s1 and others at the same time without conflict. RFC 9989 says a message passes DMARC if any one of its DKIM signatures is valid and aligned with the From domain.

Do I need DKIM if SPF already passes?

Yes. SPF breaks when mail is forwarded, while a DKIM signature usually survives forwarding intact. Google, Yahoo and Microsoft all expect bulk senders to have both. DKIM gives DMARC a second aligned path, which is what keeps legitimate mail flowing once you move to p=reject.

Related articles

Related tools

Ready to Implement?

Get authenticated mail moving in minutes: start free, book a guided demo, or talk to the team about your stack.