What is DKIM?
DKIM (DomainKeys Identified Mail) is an email authentication method that adds a cryptographic signature to each message. The receiving server fetches the sender's public key from DNS and checks that the signed parts of the message haven't changed since it was sent.
With DKIM (RFC 6376), your sending server signs selected headers and the body with a private key and adds a DKIM-Signature header. The signature names the signing domain (d=) and a selector (s=). The receiver looks up the public key at selector._domainkey.domain and checks the signature against it.
A valid signature proves two things: the domain in d= took responsibility for the message, and the signed content wasn't altered in transit. Unlike SPF, DKIM usually survives forwarding, because the signature travels inside the message.
Where the key lives
The selector lets one domain publish several keys, one per sending service, and rotate them without downtime.
# Public key in DNS, selector "s1" for northwind.example
s1._domainkey.northwind.example. 3600 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
# Signature added to each outgoing message
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=northwind.example; s=s1;
h=from:to:subject:date:message-id;
bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSb...
# Check a selector from the terminal
$ dig TXT s1._domainkey.northwind.example +shortDKIM tags worth knowing
| Tag | Where | Meaning |
|---|---|---|
d= | Signature | The signing domain. DMARC compares it with the From domain |
s= | Signature | The selector, used to find the public key in DNS |
h= | Signature | Which headers were signed. From must always be included |
bh=, b= | Signature | The body hash, and the signature itself |
c= | Signature | Canonicalization. relaxed/relaxed tolerates harmless whitespace and header-case changes |
p= | DNS record | The public key. An empty p= means the key has been revoked |
k= | DNS record | Key type, usually rsa |
Key length and rotation
Use 2048-bit RSA keys wherever your DNS host and sending platform support them. RFC 8301 requires at least 1024 bits and recommends 2048, so treat 1024 as the floor, not the goal.
Rotate keys from time to time: publish a new selector, switch signing to it, and remove the old record once mail signed with it has had time to be delivered. Selectors make this painless, which is also why each service you send through should have its own.
DKIM questions
How do I find my DKIM selector?
Open a message you sent, view the original headers and find DKIM-Signature. The s= value is the selector and d= is the signing domain. Your sending platform's DNS setup page also lists the selector it uses.
Does DKIM stop spoofing?
Not on its own. DKIM proves the domain in d= signed the message, but that domain doesn't have to match the visible From address. DMARC adds that requirement, which is what stops spoofing of your From domain.
Why does DKIM fail?
The usual causes are a public key that isn't published or has a copy-paste error, a selector in the message that doesn't match DNS, a key removed too early during rotation, or something along the way changing the signed content, such as a mailing list adding a footer.
Can I have more than one DKIM key?
Yes. Each selector is a separate key, so your workspace mail, your marketing platform and your help desk can each sign with their own key on the same domain.
Signed, aligned, and sent to real inboxes
Authentication proves the mail is yours. MailVet makes sure the addresses you send it to actually exist.