All guides
Term

DKIM

An email authentication method that uses a digital signature to verify the sender's domain and ensure the message content has not been altered.

DKIM (DomainKeys Identified Mail) is an email authentication protocol that uses cryptographic signatures to verify a sender's domain identity and confirm that message content was not altered in transit. Defined in RFC 6376, it binds an email to a specific domain so receiving mail servers can trust its origin. Implementing DKIM alongside SPF and DMARC prevents domain spoofing and stops legitimate messages from landing in spam folders.

How it works

DKIM relies on asymmetric public-key cryptography to sign and validate outgoing emails through a four-step workflow:

  • DNS publication: The domain owner generates a key pair and publishes the public key in the domain's DNS zone as a TXT record under a specific selector subdomain.
  • Message signing: When an email is sent, the sending Mail Transfer Agent (MTA) or email service hashes selected headers (such as From, To, and Subject) along with the message body, then encrypts that hash using its private key.
  • Header attachment: The server inserts the resulting digital signature, along with metadata about the signing algorithm and selector, into a new DKIM-Signature email header.
  • Recipient verification: The receiving server reads the domain and selector from the header, queries DNS for the corresponding public key, decrypts the signature, and compares the hashes. If they match, the message passes authentication.

Example

To enable DKIM, a domain administrator adds a DNS TXT record combining a chosen selector name (such as default) with the fixed _domainkey subdomain:

default._domainkey.example.com.  IN  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."

When a server signs an outgoing email using that selector, it adds a header block similar to this:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com;
 s=default; h=from:to:subject:date;
 bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
 b=dGVzdHNpZ25hdHVyZWRhdGE...

You can verify that a published record resolves properly from the command line using dig:

dig TXT default._domainkey.example.com +short

What matters when choosing a server or hosting

Your hosting environment dictates how easily you can configure and maintain DKIM keys:

  • Managed email vs. self-hosted MTAs: Managed email hosts and transactional APIs typically generate keys automatically and provide copy-paste DNS values. On a self-hosted VPS running Postfix or Exim, you must install and configure a signer daemon such as OpenDKIM yourself.
  • DNS record length limits: Modern 2048-bit RSA keys exceed the 255-character limit of a single DNS TXT string. Ensure your DNS provider automatically splits long strings or supports multi-string concatenation without syntax errors.
  • Key rotation support: Good email platforms allow you to publish multiple selectors simultaneously, making it simple to rotate cryptographic keys periodically without disrupting outbound mail delivery.

Common mistakes

  • Using weak 1024-bit keys: Short RSA keys are vulnerable to cryptographic factorization and are rejected or penalized by major inbox providers. Always generate 2048-bit keys where supported.
  • Leaving unsigned third-party senders: Every platform that sends mail on behalf of your domain—including CRM tools, ticketing systems, and marketing platforms—needs its own unique DKIM selector configured in your DNS.
  • Post-signing content modification: Mailing lists, security gateways, or automatic email footers that alter the message body or signed headers after the DKIM signature is applied will break the hash check and cause authentication failure.

FAQ

Does DKIM encrypt the contents of an email?

No. DKIM only signs the message to prove authenticity and integrity. The email body and headers remain readable in transit unless encrypted separately with TLS or end-to-end encryption like PGP.

What is the difference between DKIM and SPF?

SPF verifies that the sending server's IP address is authorized to send mail for the domain, while DKIM attaches a cryptographic signature to the message itself. Because DKIM travels inside the email headers, it survives email forwarding even when SPF breaks due to an intermediate server IP change.

Can a domain have multiple DKIM records?

Yes. Each sending service uses a distinct selector name (for example, google._domainkey and mailchimp._domainkey), allowing multiple independent platforms to sign emails for the same root domain without conflict.

All glossary terms

Glossary

Related terms

Full glossary

New guides every week.

A digest of the best pieces on servers, VPN and self-hosted software. No ads, no spam.

1 email a weekOne-click unsubscribeRU · EN
Only slipjar.app articles, nothing else.