- authenticate the sender (not spam or phishing)
- verify that the message was not modified.
How it works
- The sender's mail server signs outgoing email with a private key.
Generate a Private / Public Key Pair
As first step, you should generate a key pair for your domain.
If you use an email provider, the key is provided by them.
DKIM DNS Key
The DNS Key has the following structure:
where selector permits to have several dkim signatory. See the selector section for more information
The domain is the DNS domain and is known as signing domain identifier (sdid) in the DKIM jargon.
DKIM DNS Value
v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQUtHxTD63yxwq5fmjJ3RtXw2NP5/QEiSq3Xx85faTHnnj3/PA/igwWaueDsoeUuZOpkL74gDNGWBoQPecRaFrAXdPoEKGDYNBeMXzIkWQOth9Oaq4N+38LV08Ui86so8B2BhcvgXiqpACsrPur0hbDQWI183tZve7MKMPs3KPIQIDAQAB
Enable DKIM and control the DKIM signature header
A DKIM filter is the filter application or client that adds the DKIM signature to all outgoing messages.
After enabling DKIM processing:
- the signature is added as in the DKIM-Signature header field
- the filter is added as in the DKIM-Filter header field
DKIM-Filter: OpenDKIM Filter v2.11.0 server01.bytle.net 3E16E1FBE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytle.net; s=dkimSelector; t=1591988898; bh=WBggpZrfs7F0OzQkyE7LiZPHyfFFhl7N4CNav2f5YVw=; h=Date:To:Subject:From:From; b=ByN4Iw4U9RP8bzaPK0n3HJbFlvI60ett+V9pkoli+UNtdAcSdq/ANc3hL71PzjrT4 3yyTjK3MC5e2f/k+BAnIaAgnradAK/1CbMF4vMZVD6WoVIx7KTZlfWsW39Ir8PhqYQ 4TKvPpDUx8ToxUz1gwQlxJoExYW3McXJ2WdvUAf8=
- s is the dkim selector that you find in the domain record
- d is the domain known as sdid
- i is the Agent or User Identifier (AUID)
- t is the Signature Timestamp
- b is the signature (ie the output if the signature algorithm)
- h is the header fields used as input of the signature algorithm
- c specifies the canonicalization algorithms for the headers and body (default is simple/simple). It manages how the email can be modified in transit while preserving the signature:
- simple tolerates almost no email modification in transit
- relaxed tolerates common modifications such as whitespace replacement and header field line rewrapping.
The selector permits selecting the DNS record that contains the public key. It has generally the value of your mail provider that will sign your email.
The DKIM selector:
- is specified as an attribute of the DKIM-signature header field (the s key) in the emails send.
- permit multiple public keys (under the same organization's domain name).
Example with an entry for google:
Signing Domain Identifier (SDID)
The sdid 1) is the domain site where the public key can be found. In the DKIM Signature header, you can find it in the d property:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytle.net; s=dkimSelector; t=1591988898; ...
Agent or User Identifier (AUID)
You can find its value in the signature on the i property.
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=example.com; [email protected]; s=selector;
The value is an email value.
Example of values:
- Mailchimp: [email protected]
The default value is
- an empty local part
- followed by @
- followed by the signing_domain_identifier_sdid
How to lookup DKIM record ?
You can lookup the dkim record.
Example with Nslookup
# nslookup -type=TXT selector._domainkey.sdid nslookup -type=TXT google._domainkey.datacadamia.com
Non-authoritative answer: google._domainkey.datacadamia.com text = "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkGtLDG3wTcwJIuWDiKLXIAB1VmIRKbt0G6RamA6I+vbJf9HmTcKnVtcGsTl5fNnOdBCpyZXn6Kq+swwmQXH91D0yjStlExS2hr56qIEcCm2lecKq98PdQtQA0BKE0bEna1xryiwlNCKtH2ZqipIwFHmZgTV3WPOkjqwNQxoj4m93EXZktfslUnP88v9ArHOZM"
Below are libraries or software that can help you set up a DKIM process: