DKIM (DomainKeys Identified Mail)

DKIM signs each email with a private key, and receivers check it against a public key in your DNS. See a DKIM record example, selectors, and common fixes.

DKIM (DomainKeys Identified Mail) adds a digital signature to every email a domain sends. The sending server signs each message with a private key, and the receiving server checks the signature against a public key published in the domain’s DNS. A valid signature shows that the domain signed the message and that the signed parts haven’t changed since. DKIM works alongside SPF and DMARC.

How DKIM works

  1. The sending server picks the header fields to sign, always including From, and hashes the message body.

  2. It signs those with the domain’s private key and adds the result to the message as a DKIM-Signature header.

  3. The receiving server reads the domain (d=) and selector (s=) from that header and looks up the public key at selector._domainkey.domain.

  4. It hashes the message again and checks the signature with the public key. If everything matches, the result is dkim=pass in the message’s Authentication-Results header.

DKIM doesn’t list who may send for a domain, and on its own it doesn’t check the From address people see. Any domain can sign a message, including one a spammer owns. That’s why DMARC only counts a DKIM pass when the d= domain matches the From domain.

DKIM signature and record example

Here is the DKIM-Signature header on a message from acme.com, a company that sends from Google Workspace, and the DNS record the receiver looks up to check it.

Header DKIM-Signature on a message from acme.com
v=1 1 a=rsa-sha256 2 d=acme.com 3 s=google 4 h=from:to:subject:date 5 bh=2jUSOH9N… 6 b=AuUoFEfD… 7
Tag What it does
1 v=1 Version. Always 1.
2 a=rsa-sha256 Signing algorithm. Receivers no longer accept rsa-sha1.
3 d=acme.com Signing domain. DMARC compares it with the From domain.
4 s=google Selector. Names the key to look up.
5 h=from:to:subject:date Header fields the signature covers. From is always one of them.
6 bh=2jUSOH9N… Hash of the message body.
7 b=AuUoFEfD… The signature, made with the private key.
Public key the receiver looks up
google._domainkey.acme.com The s= and d= values, with _domainkey between TXT v=DKIM1; k=rsa; p=MIIBIjANBgkq…
An example signature for acme.com, which sends from Google Workspace. The bh=, b= and p= values are shortened. Real ones run to hundreds of characters.

The receiver builds the lookup name from two tags: the selector in s= and the signing domain in d=, with _domainkey in between. Here that’s google._domainkey.acme.com. The TXT record there holds the public key: v=DKIM1 marks it as a DKIM key, k=rsa names the key type, and p= is the key itself. A record with an empty p= means the key has been revoked (RFC 6376, section 3.6.1).

DKIM selectors and keys

A selector is the name of one key. Because each key lives at its own selector, a domain can publish several at once: one for each service that sends as it, or an old and a new key while you switch. Google Workspace uses google by default, Microsoft 365 uses selector1 and selector2, and many sending services generate random selectors.

Selectors also make key rotation safe. Publish the new key under a new selector, switch signing to it, and leave the old record in DNS for a few days so mail already on its way still verifies. Then remove the old record, or publish it with an empty p=.

Use a 2048-bit RSA key. RFC 8301 requires at least 1024 bits and recommends 2048, and it retired the rsa-sha1 algorithm. A 2048-bit key is longer than the 255 characters one TXT string can hold, so DNS providers store it as several quoted strings. Receivers join them back together, so a split key works as long as no characters go missing between the pieces.

How to set up DKIM

  1. List every service that sends email as your domain: your mailbox provider, your email platform, your help desk, your billing tool. Each one signs with its own key, so each needs its own DKIM record.

  2. Open the DKIM or domain authentication settings in each service and copy the record it gives you. Some give a TXT record with the key in it. Others give CNAME records that point to a key the service hosts.

  3. Add each record in your DNS provider at the exact host the service shows, such as google._domainkey. Most DNS editors add your domain to the end of the host, so leave it off.

  4. Turn on signing in the service if that’s a separate step. Google Workspace, for example, only starts signing after you click Start authentication in the Admin console.

  5. Wait for DNS to update, then look the domain up in the email DNS checker. Send yourself a test message and check for dkim=pass with your domain in its Authentication-Results header.

Common DKIM errors

  • The record is at the wrong host. The key has to sit at selector._domainkey under the signing domain. A record at the root, or one with the domain typed twice (google._domainkey.acme.com.acme.com), is never found.

  • The key is broken. Line breaks, spaces or quotes pasted into the middle of p=, or a key cut off because the DNS editor kept only the first 255 characters. Paste the value exactly as the service gives it.

  • CNAME records are proxied. In Cloudflare, set DKIM CNAME records to DNS only. A proxied record doesn’t return the key.

  • Signing isn’t turned on. The record exists, but the service still signs with its own domain, or doesn’t sign at all.

  • DKIM passes but DMARC fails. The d= domain is the service’s own domain, not yours, so it doesn’t line up with your From domain. Set up DKIM for your domain in that service.

  • The message changed after signing. A mailing list that adds a footer, or a security gateway that rewrites links, changes the body. The body hash no longer matches and the result is dkim=fail.

  • An old key or algorithm. A 1024-bit key still verifies, but 2048 is the recommendation. A signature made with rsa-sha1 counts as a failure.

How DKIM works with SPF and DMARC

SPF checks the server that sent a message: its IP address has to be listed in the SPF record of the Return-Path domain. DKIM checks the message itself. DMARC connects both to the From address. A message passes DMARC when SPF or DKIM passes for a domain that aligns with the From domain.

DKIM is the check that usually survives forwarding. A forwarder relays the message unchanged but sends it from its own IP address, so SPF fails while the DKIM signature still verifies. That makes an aligned DKIM signature the more dependable way to pass DMARC. Count your SPF lookups with the SPF record checker, write your DMARC policy with the DMARC record generator, and see the email deliverability guide for the rest of the checklist.

What Loops sets up for your domain

When you add a sending domain in Loops, ideally a subdomain such as mail.acme.com, the Settings → Domain page lists the records to add: SPF, DKIM, MX and DMARC. For DKIM, that’s three CNAME records. Each one points to a public key Loops manages, so you never generate, paste or store a key.

A message sent through Loops from mail.acme.com
From domain mail.acme.com What people see.
DKIM d= mail.acme.com Signed with your sending domain, so it matches the From domain.
DKIM records you add from Loops
q3fz7wka._domainkey.mail.acme.com CNAME q3fz7wka.dkim.amazonses.com
m8c2xr4d._domainkey.mail.acme.com CNAME m8c2xr4d.dkim.amazonses.com
t5hn6pjv._domainkey.mail.acme.com CNAME t5hn6pjv.dkim.amazonses.com
The selectors are shortened here. Yours are long random strings, so copy the exact values from Settings → Domain in Loops.

Loops signs every message with DKIM from your first send, using your sending domain as the signing domain. Because the From address is on that same domain, the signature lines up with the From domain, which is what DMARC looks for. Campaigns, workflows and transactional emails are all signed the same way.

If Verify Records doesn’t pass right away, it’s usually DNS propagation. Wait up to an hour and verify again. If the records still aren’t found, copy them again to rule out a typo, and on Cloudflare check that the three CNAME records are set to DNS only.

The steps for each DNS provider are in Setting up your domain, and DMARC and DKIM setup covers what Loops provides and how to check the result.

FAQ

What is DKIM?
DKIM (DomainKeys Identified Mail) is an email authentication method. The sending server signs each message with a private key, and the receiving server checks the signature with a public key the domain publishes in DNS. A valid signature shows the domain signed the message and the signed parts weren’t changed.

What is a DKIM record?
A DKIM record is the DNS record that holds a domain’s public key. It sits at a selector under _domainkey, such as google._domainkey.acme.com, and usually reads v=DKIM1; k=rsa; p= followed by the key. Some services have you add a CNAME there instead, pointing to a key they host.

What is a DKIM selector?
A selector is the name of one key. The signature’s s= tag carries it, and the receiver looks the key up at the selector, then _domainkey, then the signing domain. Selectors let one domain publish a key for each service, or an old and a new key during a rotation.

How do I check if DKIM is working?
Send a message to a mailbox you control and open its headers. The Authentication-Results header should show dkim=pass for your domain. The email DNS checker also looks for DKIM keys at common selectors, though it can’t guess randomized ones.

What DKIM key length should I use?
Use a 2048-bit RSA key. RFC 8301 requires at least 1024 bits and recommends 2048. Signatures made with rsa-sha1 count as failures, so sign with rsa-sha256.

Does DKIM survive email forwarding?
Usually. A forwarder that passes the message on unchanged leaves the signature valid, while SPF fails because the forwarder’s server isn’t in your SPF record. A mailing list that adds a footer or edits the subject breaks the signature.

Do I need to set up DKIM to send with Loops?
Yes, as part of domain setup. Loops gives you three CNAME records to add to your DNS, then signs every message with your sending domain from the first send. You don’t generate or manage keys yourself.

Related: SPF, DMARC, Email authentication, Email deliverability best practices, Email deliverability, Inbox placement.