DKIM explained: selectors, keys and why signatures fail
What DKIM signs, how to find your selector, how Google Workspace and Microsoft 365 set it up, 1024 versus 2048-bit keys, safe key rotation and the usual reasons signatures fail.
Published
On this page
The short answer: DKIM adds a digital signature to every email you send. The receiving server finds your public key in DNS, using a name called the selector, and checks the signature. If it passes, the receiver knows the message really came from a server you've authorised and that the signed parts haven't been changed. Most DKIM failures come from a missing or mistyped key record, a provider that hasn't been switched on, or a message changed on the way by a mailing list or security service.
This guide explains what DKIM checks, how to find your selector, how Google Workspace and Microsoft 365 set it up, and why signatures fail.
What DKIM signs and checks
DKIM (DomainKeys Identified Mail) is defined in RFC 6376. It works like this:
- Your email provider holds a private key. As each message leaves, it uses the key to sign a set of headers, such as From, To, Subject and Date, and a summary (a hash) of the body.
- It adds a
DKIM-Signatureheader to the message. This holds the signature, your domain in thed=tag and the selector in thes=tag. - The receiving server puts the selector and domain together to find the public key in DNS, at
selector._domainkey.domain. - It uses the public key to check the signature. If any signed header or the body has changed, the check fails.
The From header must always be signed. That matters because DMARC compares the d= domain in the signature with the domain in the From address people see.

What a DKIM record looks like
The public key is published as a TXT record:
selector1._domainkey.example.com. 3600 TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
v=DKIM1marks it as a DKIM key.k=rsais the key type. RSA is by far the most common.ed25519keys also exist but aren't yet checked by every receiver.p=is the public key itself. An emptyp=means the key has been revoked.t=y, if present, means the domain is testing DKIM. Receivers treat the mail as if it weren't signed.
Some providers ask you to publish a CNAME at the selector name instead. The CNAME points to a record that they publish and keep up to date. The receiver follows the CNAME and finds the key in the same way.
Finding your selector
You can't list all the DKIM keys for a domain: each selector is a separate name, and DNS has no way to ask "what selectors exist?". There are two reliable ways to find yours:
- From a message you've sent. Send an email to an outside mailbox, open it and view the original message or headers. Find the
DKIM-Signatureheader and read thes=andd=tags. For example,d=example.com; s=selector1means the key is atselector1._domainkey.example.com. - From your provider's settings. The DKIM page in your email service shows the selector and the record to publish.
The DKIM Checker also tries a few common selectors if you only enter a domain, but a message header is the only way to be sure which one a particular email used.
Try it now
DKIM Checker
Check a domain's DKIM key for a selector: whether it exists, its type and size, testing mode, revoked keys and provider CNAMEs such as Microsoft 365.
Setting up DKIM with Google and Microsoft
Google Workspace
In the Google Admin console, go to Apps, Google Workspace, Gmail, then Authenticate email. Google's DKIM set-up guide explains the steps:
- Choose the domain and generate a new record. Pick a 2048-bit key if your DNS host supports it. The default selector is
google. - Add a TXT record at
google._domainkeywith the value Google shows, startingv=DKIM1; k=rsa; p=. - Back in the Admin console, choose Start authentication.
A 2048-bit key is longer than the 255-character limit on a single TXT string. Most DNS hosts split it for you. If yours doesn't, split it into several quoted strings in the same record, as Google's troubleshooting page describes.
Microsoft 365
Microsoft manages the keys for you. You publish two CNAME records, and Microsoft rotates the keys behind them. Microsoft's DKIM guide gives the format:
selector1._domainkey CNAME selector1-example-com._domainkey.contoso.n-v1.dkim.mail.microsoft
selector2._domainkey CNAME selector2-example-com._domainkey.contoso.n-v1.dkim.mail.microsoft
Domains added from May 2025 use targets ending in dkim.mail.microsoft, with a letter that Microsoft chooses. Older domains use targets ending in your onmicrosoft.com name. Copy both values from the Microsoft Defender portal rather than typing them from an example, publish both even though only one is used at a time, and then switch DKIM signing on for the domain. A TXT record at these names isn't supported.
Key length: 1024 or 2048 bits
RSA keys come in different lengths. Longer keys are harder to break. RFC 8301 sets the rules: signers must use keys of at least 1024 bits and should use at least 2048 bits, and receivers must not accept keys shorter than 1024 bits. The same RFC bans the old rsa-sha1 method.
A 1024-bit key still works today, but it's now the minimum. If your provider offers 2048 bits, use it. When you upgrade, create the new key under a new selector rather than replacing the old one in place, as described below.
Rotating and revoking keys
Changing your DKIM key from time to time limits the damage if a private key ever leaks. The safe way is to use two selectors:
- Publish the new public key under a new selector, for example
s2beside the existings1. - Wait for the new record to be visible everywhere, then switch your sending service to sign with
s2. - Leave the old
s1record in place for a few days. Messages signed just before the switch may still be waiting in queues or be checked again later. - Then revoke the old key by setting its record to an empty
p=, or delete the record.
Microsoft 365 does this for you with its two selectors, which is why it asks for both. If a private key has been exposed, revoke it straight away: mail signed with it will then fail DKIM, which is what you want.
Why DKIM signatures fail
| What you see | Likely cause | What to do |
|---|---|---|
| No key found at the selector | Record missing, mistyped name, or the domain added twice (google._domainkey.example.com.example.com) | Enter only selector._domainkey as the name in most DNS panels |
| CNAME found but no key | The provider hasn't switched signing on, or the CNAME target is wrong | Turn DKIM on in the provider's settings and copy the target again |
| Signature fails after forwarding | A mailing list added a footer or tag to the Subject, or a security service rewrote links | Usually outside your control; see below |
| DKIM passes but DMARC fails | The d= domain isn't your From domain | Set the service up to sign with your own domain |
| Key looks broken | Spaces, quotes or line breaks pasted into the middle of the key | Paste the value again exactly as given |
Forwarding and mailing lists
Simple forwarding usually keeps DKIM intact, because the signature travels inside the message. That's one reason DKIM matters more than SPF for forwarded mail, which always fails SPF. Mailing lists are different: adding [list-name] to the subject or a footer to the body changes signed content, so the original signature fails. Many lists now rewrite the From address to their own domain, and some add an ARC chain (RFC 8617) that records the original result for the receiver.
Try it now
DMARC Checker
Check a domain's DMARC record: the policy that applies, whether it is inherited, alignment, reporting addresses and mistakes, following RFC 9989.
DKIM and DMARC alignment
A valid signature isn't the whole story. DMARC passes on DKIM only when the signature is valid and its d= domain matches the domain in the From address. Many services sign with their own domain by default, so the signature passes but doesn't help your DMARC result until you set up DKIM for your domain in that service.
This now affects delivery directly. Google's email sender guidelines require every sender to use SPF or DKIM from 1 February 2024. Anyone sending 5,000 or more messages a day to Gmail accounts must use SPF, DKIM and DMARC, and the From domain must align with SPF or DKIM.
Common questions
Can a domain have more than one DKIM key?
Yes, one per selector, and that's normal. A message can even carry several signatures, for example one from your domain and one from the sending service.
Do I need DKIM if I already have SPF?
Yes. SPF fails when mail is forwarded, and it checks the hidden envelope address rather than the From address people see. DKIM survives simple forwarding and can align with your From domain. DMARC works best with both.
Why does the DKIM Checker say a selector isn't in use?
The record exists but its key is empty, which means it has been revoked, or it's a spare selector waiting for the next key change. That's fine as long as the selector your mail is actually signed with has a working key.
How long does a new DKIM record take to work?
Usually minutes, once your DNS host has published it. Wait until a lookup shows the key before you switch signing on, or mail sent in the meantime will fail DKIM.
Checklist
- Every service that sends as your domain signs with your domain, using its own selector.
- Each selector in use has a key record that a lookup can find.
- Keys are 2048 bits where the provider allows it.
- Microsoft 365: both CNAME records are published and signing is switched on.
- Old keys are revoked after a key change, once queued mail has been delivered.
- DMARC reports show DKIM passing and aligned for your main senders.
Related tools
-
DKIM Checker
Check a domain's DKIM key for a selector: whether it exists, its type and size, testing mode, revoked keys and provider CNAMEs such as Microsoft 365.
-
DMARC Checker
Check a domain's DMARC record: the policy that applies, whether it is inherited, alignment, reporting addresses and mistakes, following RFC 9989.
-
SPF Checker
Check a domain's SPF record: syntax, the 10 DNS-lookup limit across every include, void lookups, and what the "all" setting means.
More email guides
-
Email
Moving DMARC from p=none to reject, safely
How to read DMARC reports, fix every real sender and move from monitoring to quarantine and reject in stages, without blocking your own email.
-
Email
How to write an SPF record, with examples for common providers
What each part of an SPF record means, the includes for Google Workspace, Microsoft 365 and other providers, where to publish it and how to stay within 10 lookups.
-
Email
Email health checklist: what to check before you send
The DNS records and other checks that decide whether your email is trusted, from MX, SPF, DKIM and DMARC to reverse DNS, BIMI, MTA-STS and DNSSEC.