What Is DKIM and How Does Email Signing Work?
DKIM (DomainKeys Identified Mail) adds a cryptographic signature to outgoing emails so receiving servers can verify the message was not altered in transit and came from the stated domain.
ProfitTool Team
Security & Dev
The Problem DKIM Solves
Email passes through multiple servers between sender and recipient — mail transfer agents, spam filters, mailing list processors. Any of these could modify the message in transit. DKIM provides a way to cryptographically verify that the message body and key headers have not been altered and that the signing domain vouches for the message.
How DKIM Signing Works
- The sending mail server generates a public/private key pair.
- The public key is published in DNS as a TXT record at
selector._domainkey.domain.com. - For each outgoing message, the server computes a hash of specified headers (From, Subject, Date) and the message body.
- It encrypts that hash with the private key to produce the DKIM signature.
- The signature is added to the message as a
DKIM-Signatureheader.
How Receiving Servers Verify DKIM
- The receiving server reads the
DKIM-Signatureheader. - It extracts the selector (
s=) and domain (d=) values. - It queries DNS for the public key at
selector._domainkey.domain.com. - It decrypts the signature with the public key.
- It recomputes the hash of the specified headers and body.
- If the hashes match, the signature is valid.
The DKIM-Signature Header
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=example.com; s=mail2024;
h=from:to:subject:date:message-id;
bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
b=dGhpcyBpcyBhIGZha2Ugc2lnbmF0dXJl...Key fields:
d=— signing domains=— selector (identifies which key pair)h=— headers included in the signaturebh=— hash of the message bodyb=— the signature itself
DKIM Selectors
A domain can have multiple DKIM key pairs active simultaneously, identified by different selectors. This allows rotating keys without downtime — add the new key, update your mail server, then remove the old key.
DKIM and Forwarding
Unlike SPF, DKIM signatures survive email forwarding because the signature travels with the message. This is why DMARC relies on DKIM for forwarded email scenarios.
Key Length Recommendations
- RSA 1024-bit: deprecated, should be rotated
- RSA 2048-bit: current minimum recommendation
- RSA 4096-bit or Ed25519: recommended for new deployments
Check any domain's DKIM record with our DKIM Record Checker.
ProfitTool Team
Security & DevWritten and maintained by the ProfitTool team. Where an article references a ProfitTool utility, the behaviour described is the behaviour of the tool on this site — you can open it and check the output yourself.
More from the Knowledge Hub
SPF vs DKIM vs DMARC: How Email Authentication Works
SPF, DKIM and DMARC work together to protect your domain from email spoofing and phishing. This guide explains what each one does and why you need all three.
Privacy & SecurityWhat Is an SPF Record and How Does It Work?
SPF (Sender Policy Framework) records tell receiving mail servers which IP addresses are authorised to send email for your domain. Here is how to read and set one correctly.
Privacy & SecurityWhat Is DMARC and How Do You Set It Up?
DMARC builds on SPF and DKIM to give domain owners control over what happens to unauthenticated email. This guide covers how DMARC works and how to configure it safely.