Skip to content
DMARC Pulse

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.

A name you choose. It becomes part of the record name.

Key length

The keys are created in your browser. The private key is not sent to our server.

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.

Step 1: private key
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out selector.private.pem
Step 2: TXT value
printf 'v=DKIM1; k=rsa; p=%s\n' "$(openssl pkey -in selector.private.pem -pubout -outform DER | openssl base64 -A)"
Optional: TXT value split into quoted strings
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 ' ' -
Host / nameTXT
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?
Enter your domain and a selector above and press the button. Your browser creates an RSA key pair, and the page shows the TXT record to publish and the private key to install on your mail server. The openssl commands on this page do the same from the command line.
Is it safe to generate a DKIM key here?
The key pair is created by your browser’s Web Crypto API and the private key stays on the page: it isn’t sent in a form, in a URL or in an analytics event. If your security policy requires keys to be created on your own servers, use the openssl commands instead.
Should I choose 2048 or 1024 bits?
2048 bits. RFC 8301 requires signers to use at least 1024 bits and recommends at least 2048, and receivers must accept keys from 1024 to 4096 bits. Keep 1024 only if your DNS provider can’t publish the longer record.
What should I use as a selector?
Any name made of letters, numbers, hyphens and dots, such as 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?
Usually because a 2048-bit record is longer than the 255 characters allowed in one TXT string. Paste the version split into quoted strings. Also check the name: if the panel adds your domain automatically, the host is only selector._domainkey.
How do I know it worked?
After the record is published, run the DKIM Checker with the same domain and selector to confirm the key is visible and valid. Then send a test message and look for 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