Does DKIM sign the email body or just the headers?
Michael Ko
Co-founder & CEO, Suped
Published 25 Jan 2025
Updated 14 Sep 2025
7 min read
I often get asked whether DKIM, or DomainKeys Identified Mail, signs just the email headers or if it also covers the email body. This is a crucial question because the extent of DKIM's protection directly impacts your email security and deliverability. The short answer is that DKIM's digital signature protects both.
When an email is sent with DKIM, a cryptographic signature is generated and attached to the message. This signature acts as a tamper-evident seal, allowing receiving mail servers to verify that the email originated from an authorized sender and that its content hasn't been altered in transit.
Understanding DKIM's dual protection
DKIM's effectiveness comes from its comprehensive approach to email authentication. It doesn't just look at one part of your email; it considers multiple elements. When a sending server applies a DKIM signature, it calculates a hash value based on selected email headers and a portion of the email body. This hash is then encrypted using the sender's private key, and the resulting signature is added to a DKIM-Signature header.
What DKIM protects
Sender authenticity: Verifies that the email originated from a domain authorized by the sender.
Message integrity: Ensures that the content of the email, both headers and body, has not been tampered with since the signature was applied.
The headers included in the DKIM signature are specified by the 'h=' tag within the DKIM-Signature header. While the From header is almost always included, a sender can choose to include other relevant headers like Subject, Date, and others. You can learn more about which DKIM tag specifies the signed header fields. This selection ensures that any unauthorized modification to these critical parts of the email will invalidate the signature.
For the email body, DKIM takes a hash of its content. This means that even subtle changes to the message body, such as altering a single character or adding a hidden pixel, will result in a different hash value. When the receiving server recalculates the body hash and compares it to the one in the DKIM signature, any mismatch indicates tampering, causing the DKIM check to fail.
The mechanics of body signing
The process of hashing the body involves a specific canonicalization algorithm, which normalizes the email body to account for minor formatting differences introduced by email clients or intermediate servers without invalidating the signature. The resulting hash is then encoded and included in the DKIM-Signature header using the 'bh=' tag. You can learn more about what DKIM tag specifies the body hash.
This body hash is critical for detecting any manipulation of the actual message content. Without it, an attacker could potentially modify the body of an email after it has been signed, for example, by changing links or altering text to facilitate a phishing attack, while the header signature would remain valid.
It's worth noting that DKIM can be configured to hash the entire body or only a portion of it, depending on the 'l=' tag (length of the body hashed) in the signature. This flexibility allows senders to protect against significant changes while potentially tolerating minor, non-malicious modifications that might occur in transit, such as a forwarder adding a disclaimer. However, most implementations hash the entire body or a substantial part of it.
Why this comprehensive signing matters
The comprehensive signing of both headers and body is what makes DKIM such a powerful tool in email security. It ensures that an email cannot be modified in transit without invalidating its signature. This capability is vital for combating email spoofing, phishing, and other forms of email-based fraud. Without DKIM, it would be much easier for malicious actors to impersonate legitimate senders and trick recipients.
Header modifications
Scenario: An attacker changes the Subject line or the Reply-To address.
DKIM impact: If these headers are part of the 'h=' tag, the signature verification will fail.
Body modifications
Scenario: A malicious actor inserts a phishing link into the email text.
DKIM impact: The recalculated body hash ('bh=') will not match the original, causing the signature to fail.
This robust protection not only builds trust with your recipients but also significantly improves your email deliverability. Mailbox providers heavily weigh email authentication protocols like DKIM when deciding whether to place an email in the inbox, spam folder, or reject it entirely. Proper DKIM implementation signals to these providers that your emails are legitimate and trustworthy.
While DKIM signs the body, it's important to understand that attachments are part of the email body's MIME structure. Therefore, any modification to an attachment would change the overall body content and thus invalidate the DKIM body hash. So, indirectly, DKIM does protect attachments by protecting the integrity of the entire message body, including any encoded attachments.
Troubleshooting and maintaining DKIM integrity
Despite its robust nature, DKIM can still fail if not properly configured or if messages are altered in ways that aren't accounted for. A common issue I see is a DKIM body hash mismatch. This often occurs when an intermediate server, mailing list, or email gateway modifies the email body, even slightly, after the DKIM signature has been applied. Such modifications could include adding footers, disclaimers, or changing character encoding.
Common causes of DKIM body hash mismatch failures
Automated modifications: Mailing list software, email archiving services, or spam filters adding or removing content.
Character set conversions: Changing how certain characters are encoded can alter the body hash.
Oversigning issues: When the canonicalization algorithm isn't chosen carefully, or when emails have long headers, it can lead to validation problems.
To mitigate these issues, it's essential to configure your sending infrastructure correctly. This often involves ensuring that any intermediate systems that process your outbound emails are configured not to alter the message body or headers in a way that breaks DKIM. Using a relaxed canonicalization algorithm for both headers and body can help, as it's more forgiving of minor whitespace changes.
Monitoring your DKIM validation status through DMARC reports is also vital. Services like Suped's DMARC monitoring provide detailed insights into your email authentication results, highlighting any DKIM failures and helping you diagnose the root cause. With Suped's AI-powered recommendations, you get clear, actionable steps to fix issues and strengthen your policy, making DMARC implementation and maintenance accessible for everyone.
Fortifying your email defenses
In conclusion, DKIM provides a powerful mechanism for email authentication by signing both chosen email headers and a cryptographic hash of the email body. This dual protection ensures that not only is the sender's identity verifiable, but also that the message content has not been tampered with since it left the authorized sender's server. This makes DKIM a cornerstone of modern email security strategies.
Implementing and correctly maintaining DKIM, alongside SPF and DMARC, is essential for maximizing your email deliverability and protecting your brand's reputation. Utilize tools like Suped for comprehensive DMARC monitoring and reporting to gain real-time insights and ensure your emails always reach their intended recipients securely.