Somebody sent you a ticket that says “Gmail says our mail isn’t authenticated, can you fix DKIM?” and you’re now staring at a DNS record that looks like someone sat on a keyboard. Fair enough. DKIM is the part of email authentication that most admins set up once, by copying values out of an admin console, and never think about again until it breaks.

So, what is DKIM? DomainKeys Identified Mail is a way for a domain to put a cryptographic signature on outgoing messages. The sending server signs certain headers and the body with a private key. The receiving server looks up the matching public key in DNS and checks the signature. If it verifies, the receiver knows two things: a domain that holds that key took responsibility for the message, and the signed parts weren’t changed in transit.

That’s it. DKIM doesn’t encrypt anything, and on its own it doesn’t tell a receiver what to do with a message that fails. That last part is DMARC’s job, which we’ll get to.

What a DKIM signature looks like

Open the full headers of any message from Microsoft 365 or Google Workspace and you’ll find something like this (trimmed, because the real thing is long):

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=example.com; s=google;
        h=from:to:subject:date:message-id;
        bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
        b=Kz3J0pX9...long base64 blob...

The tags that matter, per RFC 6376 section 3.5:

  • d= is the signing domain, the one taking responsibility for the message.
  • s= is the selector. It tells the receiver which key to fetch, so a domain can have many keys at once.
  • h= lists the header fields that were signed.
  • bh= is a hash of the message body.
  • b= is the signature itself.
  • a= is the algorithm. These days that should be rsa-sha256. RFC 8301 says flatly that rsa-sha1 “MUST NOT be used for signing or verifying.”

The d= and s= values together tell the receiver exactly where to look in DNS.

Where the public key lives

DKIM keys live under a _domainkey subdomain, at <selector>._domainkey.<domain>. For the signature above, the receiver queries google._domainkey.example.com. You can do the same thing:

dig +short TXT google._domainkey.example.com

What comes back is a key record:

"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."

v=DKIM1 identifies the record, k=rsa is the key type (RSA is the default), and p= is the public key in base64. If the TXT value is longer than 255 characters, DNS splits it into several quoted strings. That’s normal, and resolvers glue them back together.

One detail worth knowing: an empty p= is not a mistake. RFC 6376 says “an empty value means that this public key has been revoked.” That’s useful when you retire a key or lock down a domain that should never send mail.

Why selectors exist

Selectors let a domain run more than one key. Your Microsoft 365 tenant signs with one key, your marketing platform signs with another, and your helpdesk signs with a third, all for the same domain. Each uses a different selector, so they never collide.

Selectors also make key rotation painless. You publish a new key under a new selector, switch signing over, and retire the old one once mail signed with it has aged out.

To find which selector a sender is using, look at the s= value in the DKIM-Signature header of a message it sent. That beats guessing.

Key length: 1024 vs 2048

RFC 8301 sets the floor: “Signers MUST use RSA keys of at least 1024 bits for all keys,” and “Signers SHOULD use RSA keys of at least 2048 bits.” Google’s sender guidelines also require at least 1024 bits for mail to personal Gmail accounts and recommend 2048 if your DNS host supports it.

So use 2048 unless something stops you. The usual obstacle is a DNS provider that chokes on long TXT records. Microsoft 365 is worth checking here, because Microsoft’s documentation says New-DkimSigningConfig defaults to 1024-bit keys. You can move to 2048 with a rotation, which we’ll cover in a second.

There’s also a newer algorithm, Ed25519 (RFC 8463), with much shorter keys. Support isn’t universal yet, so if you use it, the RFC’s own advice is to sign with both RSA and Ed25519 under separate selectors.

DKIM in Microsoft 365

Microsoft 365 uses two selectors, selector1 and selector2, published as CNAME records that point back at keys Microsoft hosts for you. That’s how Microsoft rotates keys without you touching DNS each time.

dig +short CNAME selector1._domainkey.example.com
dig +short CNAME selector2._domainkey.example.com

The CNAME targets look different depending on when the domain was added. Older domains point at something like selector1-contoso-com._domainkey.contoso.onmicrosoft.com. Microsoft says custom domains added since May 2025 use a newer format ending in dkim.mail.microsoft. Don’t type either from memory. Copy the exact values from the Defender portal (Email & collaboration > Policies & rules > Threat policies > Email authentication settings > DKIM) or pull them with PowerShell:

Get-DkimSigningConfig | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME

Create both CNAMEs, then enable signing for the domain. If the domain is still on a 1024-bit key, rotate it:

Rotate-DkimSigningConfig -Identity example.com -KeySize 2048

Microsoft notes it takes 96 hours for a new key to start signing, and the new size only applies to the selector that becomes active, so a full upgrade takes two rotations.

One trap: if you never set up DKIM for your custom domain, Microsoft 365 still signs your mail, but with your onmicrosoft.com domain. The signature passes. It just doesn’t align with your From address, which matters for the next section.

DKIM in Google Workspace

Google’s default selector is google, published as a TXT record at google._domainkey. In the Admin console, go to Apps > Google Workspace > Gmail > Authenticate email, pick the domain, generate a 2048-bit record, publish it in DNS, then come back and click Start authentication. Google warns it can take up to 48 hours for DKIM to start working, so don’t panic if the first test fails.

If you’d like a step-by-step walkthrough of both platforms, including SPF and DMARC, we covered that in SPF, DKIM, DMARC for Microsoft 365 and Google Workspace.

Passing DKIM isn’t the same as passing DMARC

This is the bit that trips people up. A message can carry a perfectly valid DKIM signature and still fail DMARC.

DMARC wants the d= domain in a passing signature to match the domain in the visible From header. That’s called alignment. Under relaxed alignment (the default), the two just need to share an organizational domain, so d=example.com aligns with From: [email protected]. Under strict alignment (adkim=s), they must be identical.

Now picture your invoicing platform sending as [email protected] but signing with d=invoiceplatform.com. DKIM passes. Alignment fails. If that platform also isn’t covered by aligned SPF, the message fails DMARC, and once you’re at p=reject it gets bounced. The fix is to turn on custom-domain DKIM in that platform, which almost always means publishing a CNAME or TXT record it gives you under your own domain.

This is exactly why DMARC reports are worth reading. They show every source signing as your domain and whether its DKIM aligned. If XML isn’t your idea of a good time, How to Read DMARC Reports breaks it down, and What Is DMARC? covers the bigger picture.

Why it matters more now

Since February 2024, Google requires every sender to set up SPF or DKIM, and anyone sending more than 5,000 messages a day to Gmail needs SPF, DKIM, and DMARC, with the From domain aligned to either SPF or DKIM. Yahoo’s requirements are similar: SPF or DKIM for everyone, both for bulk senders. Google’s FAQ says it began ramping up enforcement in November 2025, including temporary and permanent rejections.

SPF on its own has well-known limits. It breaks on forwarding and runs into the 10-lookup ceiling (see Why Your SPF Record Is Breaking). DKIM survives forwarding as long as the signed content isn’t modified, which makes it the more reliable path to DMARC alignment for most of your mail.

Quick DKIM checklist

  1. Every service that sends as your domain signs with d= set to your domain, not the vendor’s.
  2. Keys are 2048-bit wherever the platform allows it.
  3. Nothing is still signing with rsa-sha1.
  4. Old selectors you no longer use are removed or revoked with an empty p=.
  5. Your DMARC reports show DKIM aligned for every legitimate source.

Want to see where your domain stands right now? Run it through the free MonitorDMARC DNS tools. They check your DMARC, SPF, DKIM, and BIMI records in one go, and you don’t need an account. If the DKIM line comes back red, you now know where to look.

References