Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

DomainKeys Identified Mail (DKIM)


Internet standard. An domain-based email authentication protocol that helps ISPs better identify legitimate email senders. RFC 6376(link takes you to an external page) defined this standards and RFC 8301(link takes you to an external page), RFC 8463(link takes you to an external page), RFC 8553(link takes you to an external page), and RFC 8616(link takes you to an external page) updated it.

To verify the authenticity of an email message, DomainKeys Identified Mail (DKIM) signs email headers with public-key cryptography(link takes you to an external page). The DKIM signature prevents bad actors from impersonating a legitimate domain.


DKIM implementation

dkim-implementation page anchor

To implement DKIM, you follow these steps.

  1. Using your email provider, generate a DKIM key pair. If asked, provide the following parameters
    • selector: A unique identifier for the key.
    • key size: The cryptographic strength or size of the key in bits (1024 and 2048 are common).
  2. Copy the public key.
  3. Create a TXT(link takes you to an external page) DNS record.
    • Set the record label to <selector>._domainkey.<domain>.
    • Set the record value to the signature, outlined in the DKIM record format.

To verify the authenticity of a message, the TXT record contains the public key that receiving mail servers use.


An DKIM record resides as the value of a DNS TXT that resemble the following:

DKIM DNS TXT record

dkim-dns-txt-record page anchor
k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDmzRmJRQxLEuyYiyMg4suA2SyMwR5MGHpP9dNT1hRiwUd/mZp1ro7kIDTKS8ttkI6z6eTRW9e9dDOxzSxNuXmume60Cjbu08gOyhPG3GfWdg7QkdN6kR4V75MFlw624VY35DaXBvnlTJTgRg/EW72O1DiYVThkyCgpSYS8nmEQIDAQAB

The TXT record value must adhere to the following standards:

Tags

tags page anchor
TagNecessityMeaningFormatDefault valueNote
vRecommendedversionDKIM1If present, must be the first tag.
hOptionalacceptable hash algorithmsall
kOptionalkey typersa
nOptionalhuman-readable administrator notes
pRequiredpublic key database64 encodedIf the public key has been revoked, this can be empty.
sOptionalservice type*
tOptionaltoggle flagscolon-separated listnoneCan include y to test DKIM without rejecting failed signature verifications, s for subdomain strictness, or both

With DKIM turned on, an DKIM-Signature header gets added to each email message.

1
DKIM-Signature: v=1; a=rsa-sha256; d=example.net; s=brisbane;
2
c=relaxed/simple; q=dns/txt; i=foo@eng.example.net;
3
t=1117574938; x=1118006938; l=200;
4
h=from:to:subject:date:keywords:keywords;
5
z=From:foo@eng.example.net|To:joe@example.com|
6
Subject:demo=20run|Date:July=205,=202005=203:44:08=20PM=20-0700;
7
bh=MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=;
8
b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZVoG4ZHRNiYzR
TagNecessityPurpose
vRequiredversion
aRequiredsigning algorithm
dRequiredSigning Domain Identifier (SDID)
sRequiredselector
cOptionalcanonicalization algorithm(s) for header and body
qOptionaldefault query method
iOptionalAgent or User Identifier (AUID)
tRecommendedsignature timestamp
xRecommendedexpire time
lOptionalbody length
hRequiredheader fields - list of those that have been signed
zOptionalheader fields - copy of selected header fields and values
bhRequiredbody hash
bRequiredsignature of headers and body

The recipient email server requests verification at the DKIM DNS record. It decodes the t value in the header and compares it to the p value in the DNS record. If it matches, nothing happens using DKIM alone. DMARC handles that.


To improve your email deliverability, Twilio SendGrid turns on DKIM for all email on shared or dedicated-ip IP addresses.