What is DKIM? How DKIM records work, and how to set one up
DKIM lets a receiving mail server check that a message really came from your domain and was not changed on the way. Here is how it works, what the DNS record means, and how to fix it when it fails.
DKIM in one paragraph
DKIM (DomainKeys Identified Mail, RFC 6376) is an email authentication standard. The sending server signs each outgoing message with a private key, and publishes the matching public key in DNS. The receiving server reads the signature, looks up the public key under your domain and checks that the two match. If they do, the message was sent by someone holding your key and its signed parts were not altered.
Gmail, Yahoo and Microsoft now require DKIM, or SPF, for all senders, and both plus DMARC for anyone sending in bulk. You can check what your domain sends against those rules with the bulk sender requirements checker.
How DKIM signing works
- Your mail service generates a key pair. The private key stays on the sending servers; the public key goes into a DNS TXT record.
- When a message is sent, the server hashes chosen headers (From, Subject, Date and others) and the body, signs the hash with the private key and adds a
DKIM-Signatureheader. - The receiving server reads the
d=(domain) ands=(selector) tags in that header and fetches the public key fromselector._domainkey.domain. - It recomputes the hash and verifies the signature with the public key. The result, pass or fail, is recorded in the
Authentication-Resultsheader and fed into DMARC.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=google;
h=from:to:subject:date:message-id; bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB...What a DKIM record looks like
A DKIM record is a TXT record at selector._domainkey.yourdomain.com. Its value is a list of tags separated by semicolons:
google._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."| Tag | Meaning | Example |
|---|---|---|
v | Version. Always DKIM1 if present. | v=DKIM1 |
k | Key type. rsa is the default; ed25519 is also allowed. | k=rsa |
p | The public key, base64-encoded. Empty means the key was revoked. | p=MIIBIjAN... |
t | Flags. y means test mode, and receivers treat failures as if unsigned. | t=y |
h | Hash algorithms allowed. Rarely set. | h=sha256 |
A 2048-bit RSA key is longer than the 255 characters one DNS string can hold, so the record is split into several quoted strings. Most DNS providers do this for you. A key that fails to decode is usually a copy-paste error at that split.
What a DKIM selector is, and how to find yours
The selector is the label in front of ._domainkey. It lets one domain publish many keys at once, one for each service that sends as you, such as your mailbox provider, a newsletter tool and a help desk. DNS has no way to list them, so you need the name to look a key up.
- Send a message from the service to an address you can read.
- Open the raw message: "Show original" in Gmail, "View message source" in Outlook.
- Find the
DKIM-Signatureheader whosed=is your domain. Thes=value is the selector.
| Service | Usual selectors | Record type |
|---|---|---|
| Google Workspace | google | TXT |
| Microsoft 365 | selector1, selector2 | CNAME to Microsoft |
| Mailchimp | k1, k2, k3 | CNAME |
| SendGrid | s1, s2 | CNAME |
| Fastmail | fm1, fm2, fm3 | CNAME |
Then enter the domain and selector in the DKIM checker. It also tries the common selectors above if you leave the field empty.
How to set up DKIM
Google Workspace
- In the Admin console, go to Apps → Google Workspace → Gmail → Authenticate email.
- Pick the domain and choose Generate new record. Keep the 2048-bit key length and the
googleprefix unless you need another. - Add the TXT record it shows at your DNS provider, at
google._domainkey. - Wait for DNS to update (check with the TXT lookup), then press Start authentication.
Microsoft 365
- In the Microsoft Defender portal, open Email & collaboration → Policies & rules → Threat policies → Email authentication settings → DKIM.
- Select your custom domain. The portal shows two CNAME records, for
selector1._domainkeyandselector2._domainkey. - Create both CNAMEs at your DNS provider, then turn on signing for the domain. Microsoft rotates between the two keys itself.
Other services (newsletter tools, CRMs, help desks) each have a "domain authentication" or "sender authentication" page that gives you their records. Every service that sends as your domain needs its own.
DKIM vs SPF vs DMARC
| SPF | DKIM | DMARC | |
|---|---|---|---|
| Checks | Which servers may send for the domain | That the message was signed by the domain and not changed | That SPF or DKIM passed for the domain in the From address |
| Lives at | TXT on the domain | TXT or CNAME at selector._domainkey | TXT at _dmarc |
| Records per domain | Exactly one | One per sending service | Exactly one |
| Survives forwarding | Usually not | Usually yes | Passes if DKIM survives |
DKIM alone does not stop spoofing, because a message can be validly signed by any domain. DMARC is what ties the signing domain to the From address and tells receivers what to do when neither matches. Check the other two with the SPF checker and the DMARC checker.
Why DKIM fails, and how to fix it
| Symptom | Likely cause | Fix |
|---|---|---|
dkim=none or no signature | The service is not signing as your domain | Turn on DKIM in that service and publish its records |
dkim=fail (no key for signature) | No record at the selector, or a typo in the name | Look up selector._domainkey.domain; publish or correct it |
dkim=fail (bad signature) | Message changed in transit, often by a mailing list or security gateway that rewrites links or adds a footer | Sign after the gateway, or rely on ARC/SPF for that path |
| Key will not decode | Record split or truncated badly | Re-paste the key as one value and let the DNS panel split it |
| Pass, but DMARC fails | d= is the service's domain, not yours | Set up custom-domain signing so d= matches your From domain |
To see the result for a real message, open its raw source and read Authentication-Results. It names the domain and selector checked and why it failed.
Frequently asked questions
What does DKIM stand for?
DomainKeys Identified Mail. It is an email authentication method, defined in RFC 6376, that adds a cryptographic signature to each message so receivers can verify it came from the signing domain and was not modified.
Is DKIM required?
In practice, yes. Since 2024 Gmail and Yahoo require all senders to use SPF or DKIM, and bulk senders (over 5,000 messages a day to Gmail) to use both plus DMARC. Microsoft introduced similar rules for Outlook.com in 2025.
Where is the DKIM record stored?
In DNS, as a TXT record (or a CNAME pointing at one) at selector._domainkey.yourdomain.com. With the selector google and the domain example.com, the record is at google._domainkey.example.com.
Can I have more than one DKIM record?
Yes. Each sending service uses its own selector, so a domain usually has several DKIM records. They do not conflict. This is different from SPF and DMARC, where a domain must have only one record.
What key length should DKIM use?
2048-bit RSA. 1024-bit keys still verify but are considered weak, and keys under 1024 bits are rejected under RFC 8301. Ed25519 keys are allowed but not yet verified by every receiver.
How long does a DKIM record take to work?
As long as your DNS takes to update, usually minutes and at most the record's TTL. Turn on signing in the mail service only after the record resolves, or messages will fail DKIM in the meantime.
Do I need SPF if I have DKIM?
Yes. They check different things: SPF checks which servers may send for the domain, DKIM checks that the message was signed and not changed. DMARC passes if either one passes in alignment, so having both means a message survives cases where one breaks, such as forwarding. Gmail and Yahoo require both for bulk senders.