Mailtest.me

DKIM key generator

Ephemeral RSA key pair generation to sign your emails (RFC 6376/8301). The private key is never stored: copy it now. A Postfix + OpenDKIM setup guide follows below.

Accepted but weak — may be rejected (Gmail refuses keys < 1024 bits, recommends 2048).
Recommended — Gmail has required at least 1024 bits since 2018; 2048 is the current standard.
Maximum — slower to generate and verify, useful for legitimate paranoids.
Generating...
@
Spam test
Send an email to a disposable address and get a full deliverability score.
>
Deliverability guide
Step-by-step SPF/DKIM/DMARC, full SMTP tutorial.
$
DNS check
NS, SOA, MX, SPF, DMARC, DKIM, DNSSEC and SMTP banner.
#
Blacklist
Check if your IP or domain is listed on 25+ DNSBLs.
?
DNS lookup
Look up any DNS record type.

Table of contents

1. The DKIM principle 2. Install Postfix and OpenDKIM 3. Generate and install the key 4. Configure OpenDKIM 5. Hook up Postfix 6. Publish the DNS record 7. Test Pitfalls to avoid

Guide: self-hosted SMTP server with Postfix + OpenDKIM

DKIM cryptographically signs your emails to prove they genuinely come from your domain. This guide details the complete setup on Debian/Ubuntu: Postfix for sending, OpenDKIM for signing, and DNS publication.

1. The DKIM principle

DKIM adds a digital signature in the DKIM-Signature header of every sent email. The receiving server verifies this signature using the public key published in DNS (TXT on selector._domainkey.yourdomain.com). If the signature is valid and aligned with the sender's domain, the email passes DKIM authentication.

2. Install Postfix and OpenDKIM

On Debian/Ubuntu, install the required packages. opendkim-tools provides opendkim-genkey and opendkim-testkey — a classic pitfall: "command not found" without this package.

sudo apt update sudo apt install postfix opendkim opendkim-tools # During Postfix installation, choose "Internet Site" # and enter your fully qualified domain name (FQDN).

3. Generate and install the key

You can use the generator above, or generate directly on the server with opendkim-genkey (the .txt file contains the DNS record to publish, the .private the key to keep secret). Place the key in a dedicated directory and restrict its permissions.

sudo mkdir -p /etc/opendkim/keys/yourdomain.com sudo opendkim-genkey -b 2048 -d yourdomain.com -D /etc/opendkim/keys/yourdomain.com \ -s default -v sudo chown -R opendkim:opendkim /etc/opendkim sudo chmod 600 /etc/opendkim/keys/yourdomain.com/default.private # The default.txt file contains the DNS record to publish

4. Configure OpenDKIM

Edit /etc/opendkim.conf to enable signing, then create the tables that map domains, selectors and keys.

# /etc/opendkim.conf Mode sv Domain yourdomain.com RequireSafeKeys true Socket inet:8891@localhost KeyTable refile:/etc/opendkim/key.table SigningTable refile:/etc/opendkim/signing.table ExternalIgnoreList refile:/etc/opendkim/trusted.hosts InternalHosts refile:/etc/opendkim/trusted.hosts # /etc/opendkim/signing.table *@yourdomain.com default._domainkey.yourdomain.com # /etc/opendkim/key.table default._domainkey.yourdomain.com yourdomain.com:default:/etc/opendkim/keys/yourdomain.com/default.private # /etc/opendkim/trusted.hosts 127.0.0.1 localhost yourdomain.com

5. Hook up Postfix

Add the OpenDKIM milter to Postfix's configuration so every outgoing email is signed automatically, then restart both services.

# /etc/postfix/main.cf — add at the end: milter_default_action = accept milter_protocol = 6 smtpd_milters = inet:localhost:8891 non_smtpd_milters = inet:localhost:8891 sudo systemctl restart opendkim postfix sudo systemctl enable opendkim postfix

6. Publish the DNS record

Publish the contents of the default.txt file (or the one generated above) as a TXT record on default._domainkey.yourdomain.com. A 2048-bit RSA key exceeds 255 characters: split the value into several quoted strings (the DNS standard allows this). Set a low TTL (300 s) during testing, then raise it (3600 s) once validated.

# Example TXT record (value split into 2 strings) default._domainkey.yourdomain.com. 300 IN TXT ("v=DKIM1; k=rsa; " "p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC...")

7. Test

First verify DNS publication with opendkim-testkey (the "key OK" confirms the public key is properly deployed), then send a test email and check that the DKIM-Signature header is present and valid. The site's spam test checks DKIM, SPF, DMARC and the SpamAssassin score in real time.

sudo opendkim-testkey -d yourdomain.com -s default -vvv # Expected result: « key OK » # Send a test email and check the headers echo "DKIM test" | mail -s "DKIM test" you@example.com # Then check the DKIM-Signature header in the received message

Pitfalls to avoid