What is DKIM? How email signatures prove who sent a message
DKIM adds a cryptographic signature to every email, and the public key that checks it lives in your DNS. Here's how it works and how to set it up.
DKIM (DomainKeys Identified Mail) is a way for a domain to sign the emails it sends, so the receiving server can check that the message really came from that domain and wasn't changed on the way. The sender signs with a private key, and the receiver fetches the matching public key from the sender's DNS.
It's defined in RFC 6376, which says DKIM "permits a person, role, or organization to claim some responsibility for a message by associating a domain name with the message," and that the claim "is validated through a cryptographic signature and by querying the Signer's domain directly to retrieve the appropriate public key."
How does DKIM work?
When your mail server sends a message, it hashes the body and a chosen set of headers, signs the result with your private key, and adds a DKIM-Signature header. Here's the example from RFC 6376, shortened:
DKIM-Signature: v=1; a=rsa-sha256; d=example.net; s=brisbane;
h=from:to:subject:date;
bh=MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=;
b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZVoG4ZHRNiYzR...The parts that matter:
d=is the signing domain.s=is the selector, which says which key was used.h=lists the headers that were signed.bh=is the hash of the body.b=is the signature itself.
The receiving server reads d= and s=, looks up the public key in DNS, and checks the signature. If someone edited the body or a signed header in transit, the check fails.
Where does the DKIM key live?
In a DNS TXT record under a subdomain called _domainkey. RFC 6376 gives the rule: with a d= of example.com and an s= of foo.bar, "the DNS query will be for foo.bar._domainkey.example.com."
The record holds the public key, along these lines:
v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC...v=DKIM1 is the version and p= is the base64 public key. The RFC notes that "an empty value means that this public key has been revoked."
What is a DKIM selector?
A selector is a name that lets one domain publish several keys at once. That's how you rotate keys, or let a second service send for you, without breaking mail that's already signed. RFC 6376 recommends a new selector for each new key: "A better strategy is to assign new keys to new selectors."
What happens if DKIM fails?
On its own, not much. The standard says "signature verification failure does not force rejection of the message," and that a verifier "SHOULD NOT treat a message that has one or more bad signatures and no good signatures differently from a message with no signature at all."
What turns a failure into a rejection is DMARC.
How do DKIM, SPF and DMARC fit together?
They answer three different questions:
- SPF (RFC 7208) lets a domain "explicitly authorize the hosts that are allowed to use their domain names." It checks the sending server.
- DKIM checks the message: who signed it, and whether it changed.
- DMARC (RFC 7489) ties them to the From address you see and tells receivers what to do when the checks fail.
DMARC matters because a signature alone proves less than it seems. RFC 7489: "a message can bear a valid signature from any domain, including domains used by a mailing list or even a bad actor. Therefore, merely bearing a valid signature is not enough to infer authenticity of the Author Domain." DMARC passes when a DKIM signature both verifies and is aligned with the From domain.
A DMARC record's p= tag sets the policy: none (no specific action), quarantine (treat failing mail "as suspicious", which can mean the spam folder) or reject (refuse it, ideally during the SMTP transaction).
How do I set up DKIM?
- Generate a key pair, or have your email provider generate one.
- Publish the public key as a TXT record at
<selector>._domainkey.<your domain>. - Turn on signing at your provider, using the same selector.
- Send a test message and check the
Authentication-Resultsheader (RFC 8601) on the received copy fordkim=pass. - Add a DMARC record so receivers know what to do with mail that fails.
On ACK you don't generate keys yourself. When you add your own domain, ACK generates the DKIM, return-path and DMARC records for you to paste in at your DNS provider. The domain doesn't verify until the DKIM and MX records are valid, and the domains API tells you which record is missing or wrong.
FAQ
Is DKIM the same as SPF? No. SPF checks which servers may send for a domain. DKIM signs the message itself. RFC 6376 notes that relays "typically make no substantive change to the message content and thus preserve the DKIM signature."
Does DKIM encrypt my email? No. RFC 6376 says "no attempt is made to include encryption as part of the mechanism." It proves who signed the message, and the message itself isn't hidden.
Can one domain have more than one DKIM key? Yes. Each key gets its own selector, so several services can sign for the same domain.
Will mail be rejected if DKIM fails? Not because of DKIM alone. Rejection depends on the sender's DMARC policy and the receiver's own filtering.
ACK gives each AI agent its own email inbox on your domain, with DKIM signing set up when you add the domain, signed webhooks for every delivery and bounce, and drafts a person approves. It's $19 per organisation a month with 10 inboxes. Start a trial.