GoAdmio

checkdkim

Check whether each domain's DKIM DNS record exists and matches the DKIM key on this server

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

DKIM signs outgoing mail so that other servers can confirm it really came from your domain. Mail is signed with a private key on this server, and the matching public key must be published in the domain's DNS. /go/checkdkim verifies that this is set up correctly. It checks:

You can check one domain or every hosted domain.


Quick start

# Check one domain
/go/checkdkim example.com

# Check every hosted domain
/go/checkdkim

Syntax

/go/checkdkim [domain]

If you run it without root, it re-runs itself with sudo.


Options

Argument What it does
<domain> Checks that domain.
(none) Checks every domain in /home that has a www folder, and prints a line of dashes after each one.

A domain without a /home/<domain>/www folder prints nothing. The DKIM selector is always dkim, so the DNS name checked is dkim._domainkey.<domain>.


Output

The command prints one line for each domain:

Result Meaning
example.com DKIM: Pass The key test succeeded and the public key in DNS matches the one on this server.
example.com DKIM: Invalid The key test succeeded, but the public key in DNS is different from the one on this server.
example.com DKIM: None The key test did not succeed. The DNS record is missing, cannot be read, or does not match the private key.

Each run also adds a line to /var/log/go/checkdkim.log.


Examples

# One domain
/go/checkdkim example.com
example.com DKIM: Pass
# Show only the domains that have a problem
/go/checkdkim | grep -E 'None|Invalid'
# Look at the DNS record yourself
dig TXT dkim._domainkey.example.com +short

Troubleshooting

Symptom Likely cause Fix
DKIM: None for a new domain No DKIM key was created, or the DNS record is not published yet. Create the key with installdkim, publish the record with dkim, and wait for DNS to update.
DKIM: None for an older domain The DNS record was removed, or the domain now uses other nameservers. Check the nameservers, then publish the record again with dkim.
DKIM: Invalid The DNS record holds an old key, for example after the key was regenerated. Replace the DNS record with the current key, using dkim.
Result does not change after a DNS update The resolver on this server is still using the old answer. Wait for the TTL to pass, then run the command again.
Nothing is printed for a domain The domain has no /home/<domain>/www folder. Check the domain name.
command not found opendkim-testkey or dig is not installed. Install OpenDKIM with installdkim, and the DNS tools (dnsutils).

Details

How the check works

For each domain, the command:

  1. Runs opendkim-testkey for the domain with the selector dkim. If the result does not contain OK, it prints None.
  2. Reads the public key (p=) from /etc/opendkim/<domain>/dkim.txt.
  3. Reads the public key (p=) from the DNS TXT record dkim._domainkey.<domain> with dig.
  4. Prints Pass if the two keys are the same, and Invalid if not.

Known issues


See also

Command Description
dkim Add a DKIM TXT record in Cloudflare (auto-generated or custom value)
installdkim Install and configure OpenDKIM
dmarc Add a DMARC TXT record in Cloudflare (auto-generated or custom value)
spf Add or refresh the SPF TXT record via Cloudflare
troubleshoot Troubleshoot email problems in GoAdmio
reversedns Check reverse DNS (rDNS) in GoAdmio