DKIM
SPF verifies that a message came from an authorized server, but it says nothing about whether the message itself was tampered with after it left that server. DKIM fills this gap by attaching a cryptographic signature to every outgoing email that receivers can independently verify.
What is DKIM
DKIM uses public-key cryptography. The sending mail server signs each outgoing message using a private key, and the corresponding public key is published as a DNS TXT record. When the message arrives, the receiving server looks up the public key and uses it to verify the signature.
The signature covers specific headers and the message body, so any modification in transit — even a single changed character — causes verification to fail.
A DKIM DNS record is published at a selector-specific subdomain:
selector._domainkey.yourdomain.comThe selector is an arbitrary label (like s1 or clerk) that lets a domain use multiple DKIM keys simultaneously, which is useful when sending through multiple services.
How DKIM works
When a mail server sends an email, it:
- Selects which headers and the body content to sign.
- Generates a hash of that content.
- Encrypts the hash with its private key.
- Attaches the result as a
DKIM-Signatureheader on the message.
The receiving server:
- Reads the
DKIM-Signatureheader to find the signing domain and selector. - Looks up the public key via DNS at
selector._domainkey.yourdomain.com. - Decrypts the signature using the public key.
- Hashes the same headers and body content independently.
- Compares its hash to the decrypted signature. If they match, the email passes DKIM.
The DKIM result is then factored into DMARC evaluation if a DMARC record exists for the domain.
DKIM and Clerk
Clerk configures DKIM records automatically as part of production instance setup. This ensures that every verification email sent from your domain carries a valid cryptographic signature.
For more details on email authentication setup, see Email deliverability.