DKIM (DomainKeys Identified Mail) adds a cryptographic signature to outgoing email. The sending mail server signs selected headers and the message body using a private key. The corresponding public key is published in DNS as a TXT record. Receiving servers fetch the public key and verify the signature — confirming the message is authentic and unmodified.
How It Works
- Sending server hashes selected headers + body
- Hashes with private key → DKIM-Signature header added to email
- Receiving server reads
d=domain ands=selector from DKIM-Signature - Looks up
selector._domainkey.domain.comin DNS for public key - Decrypts signature, recomputes hash, compares — PASS or FAIL
DNS Record Format
google._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqG..."
The selector (google) allows multiple keys — one per email service.
Importance
DKIM provides message integrity (wasn’t altered in transit) and signing domain proof (came from a server with the private key). Combined with DMARC alignment, it prevents From: address spoofing. Survives email forwarding better than SPF (which breaks when the envelope changes).