OpenDKIM issues - possible Virtualmin bugs?

I’ll try and keep this short and simple :slight_smile:

/etc/opendkim.conf (as installed by Virtualmin) includes these lines :

Domain /etc/dkim-domains.txt

KeyFile /etc/dkim.key

Selector myselector

SigningTable refile:/etc/dkim-signingtable

KeyTable /etc/dkim-keytable

Virtualmin adds ‘Additional domains to sign for’ to /etc/dkim-domains.txt. However, the ‘Domain’ parameter is ignored if a KeyTable is defined (source:


Outbound emails are being incorrectly signed as follows :

DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=*; s=myselector;

This causes DKIM to be invalid. The correct format should be like this :

DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;; s=myselector;

This appears to be caused by the following line in /etc/dkim-keytable :

default *:myselector:/etc/dkim.key

Which should be like this :



Remove these two lines from /etc/opendkim.conf

SigningTable refile:/etc/dkim-signingtable

KeyTable /etc/dkim-keytable

This allows the ‘Domain’ parameter to work, so you can add manually add your domains as ‘Additional domains to sign for’ and they will be DKIM-signed correctly.

The problem is that Virtualmin will overwrite opendkim.conf and add the two lines back in, which disables the ‘Domain’ parameter.

Another workaround is to use a custom key by copying the key from /etc/dkim.key into Virtualmin > > Server Configuration > Domain Key Options, and do this for every domain on the system. This correctly adds a line to /etc/dkim-keytable as follows :


This is the best workaround because it doesn’t get overwritten, but it does mean that you must manually add the custom key for every domain on the system.

This appears to be a bug in the currently Virtualmin implementation of OpenDKIM, so can you maybe take a look? Thanks.

I noticed this issues and spent DAYS tearing my hair out trying to make it work. I posted here but as yet have not established the consequences of what I did to get it working. . .

I didn’t realise the lines were being written back in by Virtualmin! :frowning:

DKIM is becoming increasingly important implementation for webmasters, it’d be good if we can get to the bottom of this and fix it sooner rather than later.

Glad to see somebody reply. I’ve been checking back here every few hours hoping for a fix myself. I just replied to your other post at - hopefully it gives you a workaround until this is fixed in Virtualmin.

Thank you lewisjenkins for the workaround. I was raging, because it didn’t work.