$linuxjunkies
>

opendkim-testkey(8)

Test DKIM keys and configuration for OpenDKIM to verify they are properly set up and functional.

UbuntuDebianFedoraArch

Synopsis

opendkim-testkey [-d domain] [-s selector] [-k keyfile] [-t testfile]

Description

opendkim-testkey validates DKIM signing keys and DNS records for the OpenDKIM mail filter. It verifies that public keys are correctly published in DNS and that private keys can be loaded and used for signing.

This tool is essential for troubleshooting DKIM setup issues before deploying OpenDKIM in production. It tests the cryptographic key pair and confirms DNS records match the expected format.

Common options

FlagWhat it does
-d domainSpecify the domain to test (e.g., example.com)
-s selectorSpecify the selector name (e.g., default, mail, or dkim1)
-k keyfilePath to the private key file to load and verify
-t testfilePath to test message file for signature verification
-xTest mode; don't actually sign messages
-vVerbose output with detailed diagnostic information

Examples

Test the DKIM key for example.com using the 'default' selector and check DNS records

opendkim-testkey -d example.com -s default

Verify a specific private key file can be loaded and matches the DNS public key

opendkim-testkey -d mail.example.com -s default -k /etc/opendkim/keys/mail.example.com/default.private

Run test with verbose output to see detailed key matching results

opendkim-testkey -d example.com -s selector1 -v

Test signing a sample message file with the DKIM key configuration

opendkim-testkey -d example.com -s default -t /tmp/test-message.txt

Related commands