Guide / What is DKIM

What is DKIM? Signatures, Selectors, Key Length and How to Check It

DKIM is one of the pillars of email authentication, alongside SPF and DMARC. Here is how the signature works and how to check for yourself that it is set up correctly.

Published: November 13, 2026 · 日本語

DKIM is a digital signature on your email

With DKIM (DomainKeys Identified Mail), the sending server adds a digital signature to each outgoing message and the receiver verifies it. That confirms the message really was sent under the control of that domain and was not modified on the way. It is defined in RFC 6376.

SPF looks at which server sent the message; DKIM signs the message itself. So even when a message is forwarded and the sending IP address changes, the signature stays valid as long as the body and key headers are unchanged. That is the main reason DKIM makes up for SPF's weakness with forwarding.

How signing and verification work

  1. The sending mail server computes a hash of the body and some headers (From, Subject, Date and so on) and signs it with a private key.
  2. The signature is added at the top of the message as a DKIM-Signature header.
  3. The receiving server reads the domain and selector in that header and fetches the public key published in DNS.
  4. It verifies the signature with the public key: "pass" if the message is untouched, "fail" if the signature does not match.

Only the sender holds the private key; only the public key goes in DNS. The private key cannot be derived from the public key, so it does no harm that anyone can see the public key.

Reading the DKIM-Signature header

If you view the source of a received message, you will find a header like this (shortened):

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=example.com; s=selector1;
 h=from:to:subject:date:message-id;
 bh=(hash of the body); b=(signature)

Selectors and the public key in DNS

The public key goes in a TXT record at the DNS name selector._domainkey.domain. For selector selector1 and domain example.com, the name to look up is:

selector1._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkq..."

The public key is in p=. Selectors exist so that one domain can use several keys at the same time. If you use more than one mailing service, or are switching keys, separate selectors keep them from interfering with each other.

There is no way to list a domain's selectors from DNS. External tools that try a list of common selector names therefore have limits: not finding one does not prove DKIM is missing. The reliable way is to look at the s= value in the header of a message actually sent from your domain.

Key length and algorithm

2048-bit RSA keys are the current recommendation. 1024-bit keys still work in many places, but moving to 2048 bits is advised for strength. A 2048-bit public key makes the TXT record longer than 255 characters, so depending on your DNS control panel you may need to enter it as several strings (DNS joins them back into a single value).

When entering a long key, some panels handle quotes and line breaks for you and some do not. After saving, always check that the value you get back from DNS is not cut off part way.

Rotating DKIM keys

A private key carries a lasting risk of leaking, so changing it regularly is recommended. The basic steps are:

  1. Create a new key pair under a new selector name.
  2. Add the new public key to DNS (do not delete the old one yet).
  3. Switch the sender's signing setting to the new selector.
  4. Wait while messages signed with the old key may still be in transit (a few days), then delete the old public key.

Delete the old key first and messages still in transit fail verification. Always go in the order add, switch, wait, delete.

Why DKIM alone is not enough

DKIM vouches for the signing domain, but not that it is the same as the From domain the recipient sees. An attacker can sign a message with their own domain while displaying your domain as the sender. Catching that mismatch, and saying what to do with messages that do not match, is DMARC's job. Think of DKIM and DMARC as a pair.

How to check your setup

Common pitfalls

FAQ

Does setting up DKIM alone stop spoofing?

No. DKIM only shows which domain signed; it does not guarantee a match with the From domain the recipient sees. Use it together with DMARC, which checks that match and says what to do with messages that fail.

How often should I rotate DKIM keys?

There is no fixed rule, but many organizations rotate about once a year. Rotate right away if you suspect the key has leaked or when the person responsible leaves.

Can forwarding break a DKIM signature?

If the body and signed headers are not rewritten, the signature survives forwarding. But a mailing list that adds text to the subject or body can invalidate it.

Check your own domain

Enter your domain and the points in this article are checked for free. No sign-up.

Check DKIM and DMARC for free