Skip to content

BlogDKIM

What is DKIM? How DKIM signing works and how to set it up

DKIM still passes after a message is forwarded, which is why DMARC leans on it most. Setting it up means one TXT record in DNS, or two CNAMEs in Microsoft 365, and a 2048-bit key instead of 1024 when your provider offers it. The steps for Google Workspace and Microsoft 365 are below.

Julien Coulaud on X

Founder of Shipmail, the email platform for businesses and their AI agents. Every guide here draws on mail servers running in production.

  • DKIM
  • DKIM record
  • DKIM selector
  • Email authentication
  • DNS

Short answer

DKIM (DomainKeys Identified Mail) adds a digital signature to every email you send. Your mail server signs the message with a private key, and you publish the matching public key in DNS at selector._domainkey.yourdomain.com. The receiving server fetches that key and checks the signature. A pass proves that the signing domain sent the message and that the signed headers and body were not changed on the way.

What DKIM is

DKIM stands for DomainKeys Identified Mail. When your provider sends a message, it computes a hash of the body and of selected headers, signs them with a private key, and adds the result to the message as a DKIM-Signature header. The public half of the key sits in a TXT record in your DNS, where anyone can read it.[1]

The receiving server reads the signature, looks up the public key, and checks the math. If the body or a signed header changed after signing, the check fails. If it passes, the receiver knows that whoever controls the signing domain sent this exact message.[1]

What a DKIM pass proves, and what it does not

A DKIM pass proves that the signing domain sent the message and that the signed parts arrived unchanged. It does not prove that the signing domain matches the From address the reader sees.[1]

  • It proves that the domain in the signature's d= tag signed the message.
  • It proves that the signed headers and the body arrived unchanged.
  • It does not prove that the d= domain matches the From address your reader sees. DKIM itself does not require that match. A spammer can sign mail with their own domain and put your domain in the From line.
[1]

Closing that gap is DMARC's job. DMARC only counts a DKIM pass when the d= domain matches the visible From domain, and it tells receivers what to do with mail that fails.[3]

The DKIM-Signature header fields that matter

Five tags in the DKIM-Signature header tell you most of what you need: d=, s=, h=, bh= and b=. You'll find the DKIM-Signature header, a line of tags, in the full header of any email you receive.[1]

  • d= is the signing domain, for example d=example.com. This is the domain DMARC compares with the From address.
  • s= is the selector, for example s=google. It tells the receiver which key to fetch.
  • h= lists the headers that were signed, separated by colons, such as from:to:subject:date. The From header must always be in this list.
  • bh= is the hash of the message body.
  • b= is the signature itself, a long base64 string.
[1]

The receiving server writes its verdict in the Authentication-Results header, as dkim=pass or dkim=fail, followed by the domain it checked.[4]

DKIM selectors and the DKIM record

A selector is a name you choose for one key. The public key lives at the selector, then _domainkey, then your domain. With the selector mail2026 on example.com, the receiver looks up the TXT record at mail2026._domainkey.example.com. Selectors let one domain publish several keys at once, for example one for your mailbox provider and one for your newsletter tool.[1]

A DKIM TXT record has three tags: v=DKIM1, k=rsa for the key type, and p= for the public key in base64. Here is a complete, valid record. It uses a 1024-bit key to keep it short; a 2048-bit key is about twice as long.[1]

  • Name: mail2026._domainkey.example.com
  • Type: TXT
  • Value: v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8mU2sbxe0ASysssHpoCGjBzMHGEFYmQqHH5hSlIWf5L7si/Yg1AJbkuCqoGUfNIKkUHE4WJfyIeomVx8S7n4zHvUS3L3uNSkIh+3Xqwgr7KxXPppef6gD8zwRTSbKUpCGn9hMqkoQ5K8J6IJkZnyrtaY+mvn7HNFPEpKfehavEQIDAQAB
[1]

Some providers ask for a CNAME instead of a TXT record. The CNAME points your selector name at a key the provider hosts, so the provider can replace the key without asking you to edit DNS again. Microsoft 365 works this way. A delegated record looks like this.[6]

  • Name: s1._domainkey.example.com
  • Type: CNAME
  • Value: s1.dkim.example.net
[6]

To find the selector a sender uses, read the s= tag in the DKIM-Signature header of one of their messages. You cannot list every selector a domain has from DNS, because you need the name to look the record up.[1]

DKIM key length: 1024 or 2048 bits

RFC 8301 sets the rules. Signers must use RSA keys of at least 1024 bits and should use at least 2048 bits. Receivers must not accept signatures made with keys shorter than 1024 bits. The same RFC bans the old rsa-sha1 algorithm, so signatures should use a=rsa-sha256.[2]

Google recommends 2048-bit keys for Google Workspace and says to fall back to 1024 bits only if your DNS host does not support the longer record. Microsoft's PowerShell command for a new DKIM setup creates 1024-bit keys by default and accepts 2048. If your provider offers 2048 bits, use it.Sources[5]Google Workspace Admin Help: set up DKIM[6]Microsoft Learn: use DKIM for email in your custom domain

DKIM key rotation

Rotating a key means replacing it with a new one, the way you would change a password. Selectors make this safe. You publish the new key under a new selector, switch signing to it, and keep the old record in DNS until mail signed with the old key has been delivered and checked.[1]

  1. Step 1

    Publish the new key

    Add a TXT record under a new selector, for example mail2027._domainkey.example.com.

  2. Step 2

    Switch signing

    Tell your mail server or provider to sign with the new selector.

  3. Step 3

    Retire the old key

    After a few days, revoke the old key by publishing its record with an empty p= value, or delete the record.

[1]

With CNAME delegation the provider does the work. In Microsoft 365, Rotate DKIM keys switches between selector1 and selector2, and the new key starts signing after four days.[6]

Why DKIM survives forwarding better than SPF

DKIM survives forwarding because the signature is attached to the message itself, while SPF checks the IP address of the server that hands over the message. When a mailbox forwards your email, the forwarding server's address is not in your SPF record, so SPF usually fails. A forwarder that does not change the body or the signed headers leaves the signature valid.Sources[3]RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)[1]RFC 6376: DomainKeys Identified Mail (DKIM) signatures

This is why Google calls DKIM especially important for forwarded mail, and why the DMARC standard says a domain with a reject policy must sign with DKIM instead of relying on SPF alone. Mailing lists that add a footer or rewrite the subject can still break the signature.Sources[7]Gmail: best practices for forwarding email to Gmail[3]RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)

How to set up DKIM in Google Workspace

To set up DKIM in Google Workspace, generate a 2048-bit key under Authenticate email in the Google Admin console, add it as a TXT record at your DNS host, then click Start authentication.[5]

  1. Step 1

    Open Authenticate email

    Sign in to the Google Admin console as a super administrator. Go to Menu, Apps, Google Workspace, Gmail, then click Authenticate email.

  2. Step 2

    Generate the key

    Pick your domain under Selected domain and click Generate New Record. Choose 2048 bits and keep the default selector prefix, google, unless the domain already uses it. Click Generate.

  3. Step 3

    Add the TXT record

    Copy the DNS Host name (usually google._domainkey) and the TXT record value, which starts with v=DKIM1. Add them as a TXT record at your DNS host.

  4. Step 4

    Start authentication

    Back on the Authenticate email page, click Start authentication. Only do this after the DNS record is published.

[5]

How to set up DKIM in Microsoft 365

Microsoft 365 already signs mail sent from your yourcompany.onmicrosoft.com address. For your own domain, you publish two CNAME records and turn signing on.[6]

  1. Step 1

    Open the DKIM tab

    In the Microsoft Defender portal at security.microsoft.com, go to Email & collaboration, Policies & rules, Threat policies, Email authentication settings, and open the DKIM tab.

  2. Step 2

    Get the CNAME values

    In the row for your custom domain, slide the toggle to Enabled. If the CNAMEs are not published yet, Microsoft shows an error. Open the domain's details: the Publish CNAMEs section lists selector1._domainkey and selector2._domainkey, each pointing to a Microsoft-hosted key.

  3. Step 3

    Add both CNAMEs

    Create the two CNAME records at your DNS host exactly as shown. Microsoft may take a few minutes or longer to detect them.

  4. Step 4

    Turn on signing

    Back on the DKIM tab, slide the toggle for the domain from Disabled to Enabled again. The status changes once Microsoft finds the records.

[6]

How to check that DKIM works

Send a message from your domain to a Gmail address, open it, and view the original message. The Authentication-Results header should show dkim=pass followed by your own domain. If it shows a different domain, your provider is signing with its own domain, and DMARC will not count it for you.Sources[5]Google Workspace Admin Help: set up DKIM[4]RFC 8601: Authentication-Results header field

To check the record itself, enter your domain and selector in a DKIM checker. Shipmail's free DKIM checker shows whether the key is published and how long it is.

DKIM on Shipmail

When you add a domain to Shipmail, the DKIM record is one of the four DNS records it gives you, a TXT record at shipmail._domainkey. Shipmail can publish the records for you or you can add them by hand, and it rechecks them until they verify. Shipmail then signs every message from your mailboxes with d= set to your own domain.[10]

Transactional email and newsletters get their own subdomain and their own key, for example shipmail._domainkey.notify.example.com. Removing a sending subdomain never touches the key that signs your team's mail.Sources[11]Shipmail transactional email documentation[12]Shipmail newsletter editor documentation

Sources12 sourcesVerified 2026-11-09
  1. [1]
    RFC 6376: DomainKeys Identified Mail (DKIM) signatures

    Section 3.5: the signature is stored in the DKIM-Signature header field; d= is the signing domain, s= the selector, bh= the body hash and b= the signature data. Section 3.6.2.1: the public key is a DNS TXT record at selector._domainkey.domain. Section 3.5: h= lists the header fields that were signed; Section 5.4: the From header field MUST be signed. Section 3.6.1: key record tags v=DKIM1, k (default rsa) and p, where an empty p= means the key was revoked. Section 3.1: selectors allow several keys per domain and routine key replacement. Section 3.11: DKIM itself does not require d= to match any other header. Relays that do not change the content preserve the signature.

    rfc-editor.org · 2026-10-11

  2. [2]
    RFC 8301: cryptographic algorithm and key usage update to DKIM

    Updates RFC 6376. Signers MUST use RSA keys of at least 1024 bits and SHOULD use keys of at least 2048 bits. Verifiers MUST be able to validate keys from 1024 to 4096 bits and MUST NOT accept signatures made with keys shorter than 1024 bits. Signers MUST sign with rsa-sha256; rsa-sha1 MUST NOT be used.

    rfc-editor.org · 2026-10-11

  3. [3]
    RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)

    Published May 2026 on the Standards Track; obsoletes RFC 7489 and RFC 9091. Section 4.7 tags: v=DMARC1 (required, first), p (none, quarantine, reject; treated as none if absent), sp (existing subdomains, defaults to p), np (non-existent subdomains), psd, t (test mode y or n, default n), rua and ruf (mailto: report addresses), adkim and aspf (r relaxed or s strict, default r), fo (default 0, ignored without ruf: 0 asks for a failure report when all mechanisms fail to give an aligned pass, 1 when any fails, d when a DKIM signature failed, s when SPF failed). Section 4.1: the policy record is a TXT record at _dmarc.<domain>. With t=y the domain owner is testing and expects failing mail to get the policy one step lower, so quarantine becomes none and reject becomes quarantine; t has no effect on reports. Relaxed alignment means the same organizational domain, strict means identical domains. If several DMARC records are returned for one name, all are discarded. Appendix A.6 removes pct, replaced by t, whose y and n values match pct=0 and pct=100; Appendix C.5.2 lists rf and ri as removed. Section 7.4: in forwarding, SPF will most likely fail while DKIM signatures generally remain valid; a domain publishing p=reject MUST NOT rely only on SPF and MUST apply valid DKIM signatures; domains whose users post to mailing lists should not publish p=reject, or should first publish p=none for at least a month and then p=quarantine for as long.

    rfc-editor.org · 2026-10-11

  4. [4]
    RFC 8601: Authentication-Results header field

    Authentication-Results records the results of message authentication checks such as SPF and DKIM so mail clients and filters can use them. The receiving server that performed the checks adds it at the top of the message; the first element is the authserv-id naming that service. Before adding its own, a server should remove instances claiming to come from its own trust boundary. Results include pass, fail, softfail (SPF), neutral, none, temperror and permerror.

    rfc-editor.org · 2026-10-11

  5. [5]
    Google Workspace Admin Help: set up DKIM

    A super administrator opens Menu, Apps, Google Workspace, Gmail, Authenticate email, selects the domain, clicks Generate New Record, chooses a key length and selector prefix (default google), adds the TXT record (for example google._domainkey, value starting v=DKIM1) at the domain host, then clicks Start authentication. 2048-bit keys are recommended; use 1024 bits if the DNS host does not support 2048. Wait 24 to 72 hours after turning on Gmail before generating the key; authentication can take up to 48 hours to start after the DNS record is added. Check for dkim=pass in the Authentication-Results header.

    knowledge.workspace.google.com · 2026-10-11

  6. [6]
    Microsoft Learn: use DKIM for email in your custom domain

    In the Defender portal, go to Email & collaboration, Policies & rules, Threat policies, Email authentication settings, DKIM tab, open the custom domain, publish the two CNAME records it shows (selector1._domainkey and selector2._domainkey pointing to Microsoft-hosted keys), then turn on Sign messages for this domain with DKIM signatures. The *.onmicrosoft.com domain is signed automatically. New-DkimSigningConfig creates 1024-bit keys by default and accepts 2048. Rotate DKIM keys switches to the other selector; the new key starts signing after four days (96 hours).

    learn.microsoft.com · 2026-10-11

  7. [7]
    Gmail: best practices for forwarding email to Gmail

    Forwarded messages often fail SPF; DKIM is especially important for forwarded mail; Gmail does not automatically trust forwarded messages that passed authentication earlier; forwarded spam marked by recipients makes future mail from the forwarding domain more likely to be filtered.

    support.google.com · 2026-10-15

  8. [8]
    Gmail email sender guidelines

    Since February 1, 2024, all senders to Gmail need SPF or DKIM, valid forward and reverse DNS, TLS, RFC 5322 formatting, and a Postmaster Tools spam rate below 0.3% (best practice below 0.1%). Senders of more than 5,000 messages a day also need SPF, DKIM and DMARC (policy may be none), a From domain aligned with SPF or DKIM, and one-click unsubscribe for marketing and subscribed mail. Messages of the same category should have the same From address, display names should be a consistent and accurate statement of the sender's identity, and subject lines should not start with Re: or Fwd: unless the message is a real reply or forward. The page does not mention no-reply addresses.

    support.google.com · 2026-10-11

  9. [9]
    Yahoo Sender Hub best practices

    Yahoo asks bulk senders to implement SPF and DKIM, publish a DMARC policy of at least p=none that passes, support one-click unsubscribe for marketing and subscribed mail, honor unsubscribes within 2 days, and keep the spam rate below 0.3%.

    senders.yahooinc.com · 2026-10-11

  10. [10]
    Shipmail domain setup documentation

    Adding a domain to Shipmail: four DNS records (MX, SPF, DKIM and DMARC), published automatically or by hand, suggested merging of an existing SPF record, and verification that rechecks the records every 30 seconds.

    shipmail.to · 2026-10-11

  11. [11]
    Shipmail transactional email documentation

    Shipmail transactional email: an app sends from its own sending subdomain of a domain already verified in Shipmail, and replies go to a Shipmail mailbox. Sends count toward the plan's monthly quota, a sender costs nothing extra, Activity shows delivery status, and a retry with the same Idempotency-Key returns the first message. Every email from a sender carries its mailbox's address as Reply-To, so replies arrive in that mailbox's Transactional folder; the sending address itself cannot receive email. On a paid plan, an organization's transactional email starts at a safety limit of 1,000 recipients a day, raised daily to twice the highest clean day of the last 7 days, up to 25,000 automatically; the plan keeps 80% of its daily limit as a floor; a migration review with the last 30 days gets an answer within one business day.

    shipmail.to · 2026-11-09

  12. [12]
    Shipmail newsletter editor documentation

    Newsletters written in Shipmail with a rich text editor, design blocks, custom HTML or plain text, preview, test sends and pre-send review checks.

    shipmail.to · 2026-10-15

Questions worth answering

Common questions about what is dkim.

What does DKIM stand for?
DomainKeys Identified Mail. It is an email authentication standard, defined in RFC 6376, that lets a domain sign the messages it sends.[1]
How do I find my DKIM selector?
Open the full header of an email you sent and find the DKIM-Signature line. The value after s= is the selector. Your provider's admin page also shows it, for example google in Google Workspace and selector1 or selector2 in Microsoft 365.Sources[1]RFC 6376: DomainKeys Identified Mail (DKIM) signatures[5]Google Workspace Admin Help: set up DKIM[6]Microsoft Learn: use DKIM for email in your custom domain
Can a domain have more than one DKIM record?
Yes. Each key has its own selector, so a domain can publish one record per sending service, such as google._domainkey for Google Workspace and another selector for a newsletter tool.[1]
Is a 1024-bit DKIM key still OK?
It is the minimum receivers accept. RFC 8301 says signers should use at least 2048 bits, and Google recommends 2048 bits when your DNS host supports it.Sources[2]RFC 8301: cryptographic algorithm and key usage update to DKIM[5]Google Workspace Admin Help: set up DKIM
Do I need DKIM if I already have SPF?
Yes. SPF usually fails when mail is forwarded, while DKIM usually survives. Gmail and Yahoo require both SPF and DKIM from bulk senders, and a DMARC reject policy should not rely on SPF alone.Sources[3]RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)[8]Gmail email sender guidelines[9]Yahoo Sender Hub best practices
Why does DKIM fail?
The usual causes are a record that is missing or published under the wrong selector, a record broken while pasting it into DNS, or a message that something changed in transit, such as a mailing list footer.[1]

Related guides

More on Shipmail pricing, comparisons, and team workflows.

Email, newsletters and booking pages on your own domain, in one plan.

Get started for free