DKIM record generator
DKIM Record Generator: generate a DKIM key pair
Enter your domain and a selector. Your browser generates the key pair, and this page gives you the TXT record to publish and the private key for your mail server.
This browser couldn’t generate the key
Your DKIM record
Create a TXT record with this name and value at your DNS provider. Some panels add your domain automatically: there, enter only the part before it.
This record is too long for a single DNS string
Your private key
Install it in the system that signs your outgoing mail, with the same domain and selector.
Keep this private key secret
After publishing
DNS changes can take from minutes to a few hours to appear, depending on the TTL. Then confirm that the public key is visible and valid.
Generate the key with openssl
On Linux, macOS or WSL, these commands give you the same result on your own machine: a PEM private key and the TXT value to publish.
Replace selector and example.com with your own values, or fill in the form above and submit it.
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out selector.private.pem
printf 'v=DKIM1; k=rsa; p=%s\n' "$(openssl pkey -in selector.private.pem -pubout -outform DER | openssl base64 -A)"
printf 'v=DKIM1; k=rsa; p=%s' "$(openssl pkey -in selector.private.pem -pubout -outform DER | openssl base64 -A)" | fold -w 255 | sed 's/.*/"&"/' | paste -sd ' ' -
selector._domainkey.example.com
What to do with the result
Your record is ready, shown in two formats
A 2048-bit result shows one host name and the same value in two formats. Publish one format, as a single TXT record at mail1._domainkey.example.com. Use the DNS provider that your domain’s NS records point to, which may not be your registrar.
Do not add both formats as separate records. RFC 6376 §3.6.2.2 requires one TXT record per selector and leaves anything else undefined. If the selector already holds a key in use, start again with a new selector. Replacing that record makes mail signed with the old key fail verification.
The private key is on your screen
This key signs your mail, and it exists only in this browser tab. Choose Download .pem before you leave the page, then move the file to the system that signs. Make it readable only by the signing service. By default, OpenDKIM refuses a key file that other users can read or write. If you lose the key before signing starts, generate a new pair and replace the record.
Turn on signing only after the TXT record resolves. A signature with no key in DNS fails permanently. Under p=quarantine or p=reject, that mail can land in spam or be rejected unless SPF also passes for your From domain.
You chose 1024 bits and see a warning
Your key meets the minimum in RFC 8301 but falls short of the 2048 bits it recommends. Gmail accepts 1024 bits for personal accounts and also recommends 2048. The value fits in one string, so the page shows one version of it. The DKIM Checker will mark this length with a warning.
Treat this key as temporary. Once your DNS provider can store the longer record, generate a 2048-bit pair under a new selector and publish it. Then switch the signer. Keep the old record for a while, because mail signed with the old key may still be in transit.
The browser could not create the key, or JavaScript is off
The page creates keys with Web Crypto, a browser feature that needs JavaScript. When that fails, you get openssl commands for Linux, macOS or WSL. Run them in order on the system that will sign, and keep the .pem file there.
Check the names before you publish. The commands carry your selector only after the form reaches the server, which does not happen if Web Crypto started and then failed. If they show the placeholder selector, as in selector.private.pem, replace it with your own selector in every command. Your host name, key file and signer settings must all use the same selector. Publish the output of Step 2, or the split version if your DNS panel needs quoted strings.
You published the record and want to confirm it
Use the DKIM Checker with the same domain and selector. If it finds no key, wait for DNS to update, then look for a misspelled selector or a doubled name such as mail1._domainkey.example.com.example.com. If it calls the key unreadable, the value may have been cut short, so publish the split version.
Once the key reads correctly, paste a test message’s headers into the Email Header Analyzer. The d= domain must align with your From domain, which by default means the same organizational domain. If DMARC is absent, create one record at p=none with a rua= address. Otherwise add reporting to the existing record and preserve its policy. Read reports until every legitimate sender passes. Only then move toward p=quarantine or p=reject.
Explained
What the generator creates
A DKIM key pair has two halves. The private key stays on the system that sends your mail and signs each message. The public key goes in DNS, in a TXT record at <selector>._domainkey.<domain>, where receivers fetch it to verify the signature (RFC 6376).
Publishing a long record
One string in a TXT record holds at most 255 characters (RFC 1035). A 2048-bit DKIM record has about 410, so it has to be stored as two or more strings, written in quotes one after the other. Receivers join the strings with no spaces between them (RFC 6376), so the split doesn’t change the key. Some DNS panels split long values for you; in the others, paste the split version this page gives you.
Where the private key goes
Configure it in whatever signs your outgoing mail, such as OpenDKIM on your own server, and restrict who can read the file. Use the same domain and selector there: they become the d= and s= of each signature.
Hosted services such as Google Workspace or Microsoft 365 usually create the keys for you and give you the records to publish. In that case, follow their DKIM setup instead.
Frequently asked questions
How do I generate a DKIM key?
Is it safe to generate a DKIM key here?
Should I choose 2048 or 1024 bits?
What should I use as a selector?
mail1. Selectors let a domain keep several keys at once, which is how you rotate them: publish the new key under a new selector, switch the signer to it and remove the old record later.Why does my DNS panel reject the record?
selector._domainkey.How do I know it worked?
dkim=pass in its Authentication-Results header.Keep it healthy
Know the moment something breaks
Point your DMARC reports to DMARC Pulse and see who sends email as your domain, what fails and why — with a calm alert when anything changes.
Free plan: 1 domain, no credit card.
Related tools