Why does header re-ordering sometimes break DKIM?

Still have a question, spotted an error, or have a better explanation or a source we should cite?

When your server signs a DKIM message, it hashes a specific list of headers in a specific order. That order is recorded in the signature. When the receiving server verifies the signature, it reconstructs the same header list in the same sequence and checks that the hash matches.

If a mail relay has reordered those headers by the time the message arrives, the hash is different, and DKIM fails. The content is technically unchanged, but the order isn't, and DKIM can't tell the difference between reordering and tampering.

Why relays reorder headers

Some mail servers sort or normalize headers during processing. Mailing list software, forwarding services, and enterprise mail gateways often rewrite the header block to their preferred sequence. It's not malicious. It's just mail plumbing being imperfect. The headers arrive intact but in a different order than when they were signed.

Does canonicalization help?

Partly. Relaxed canonicalization normalizes whitespace and lowercases header names before hashing, which makes minor formatting changes survivable. But it doesn't handle full header reordering. Both simple and relaxed canonicalization will fail if the sequence of signed headers is shuffled.

When this actually happens

The most common place you'll see this is enterprise mail gateways. Products like Proofpoint, Mimecast, and some Microsoft Exchange configurations process and requeue messages, rewriting the header block in the process. If DKIM passes at Gmail but fails at corporate Outlook addresses, a rewriting gateway is worth investigating.

There's no setting you can flip to make DKIM survive full header reordering. The real fix is identifying which gateway is rewriting and whether its vendor supports DKIM-aware processing. Check your current canonicalization mode with our DKIM checker. If you're chasing a provider-specific failure you can't pin down, the SOS hotline is free.

Contributors

Who worked on this answer

Every name links to their profile. Every company links to their site. Real people, real accountability.

Ask an AI · tailored to your setup

Diagnose My Header Reordering Failure

I just read the Email Almanac entry on header re-ordering and DKIM failures. Help me figure out whether a mail gateway is reordering headers and causing my DKIM to fail selectively. Walk me through: 1. How to confirm the failure is provider-specific vs happening everywhere 2. How to identify which gateway is rewriting headers from the email trace 3. Whether my canonicalization mode (simple vs relaxed) is making it worse 4. What options I have if the gateway can't be changed --- My details (fill in what applies): - Sending domain: your domain - Where DKIM is failing: [specific providers, e.g. "corporate Outlook, not Gmail"] - Mail gateway in use (if known): Proofpoint / Mimecast / Exchange / unsure - Current canonicalization mode: simple / relaxed / unsure - Authentication-Results from a failing message (paste if you have it): dkim= result

Edit the yellow boxes, then send to the AI of your choice.