How To Setup DKIM For Multiple Domains in Virtualmin

Category: Linux Administration

I am hosting multiple domains using Webmin and wanted to setup DKIM for multiple domains. If you are using DNS server from Virtualmin, it would be easy to setup DKIM because Virtualmin takes care of not only enabling the DKIM for the domain but also setting up correct DNS record.

I use 3rd party DNS server and I did not know technical details behind DKIM. It was a big learning curve for me to understand and setup DKIM. Setting up the DKIM wrong way would result in all emails being marked as spam. Finally I setup DKIM correctly for all domains. Here are steps to setup DKIM using Virtualmin.

Steps to Setup DKIM in Virtualmin

Here are the steps to setup DKIM for multiple domains in Virtualmin.

  • Go to Virtualmin > Email Settings > DomainKeys Identified Mail > Enable it (Keep Selector of DKIM record name as default of YYYYMM) > Click Save button
  • Once you save it, the same page provides more options. Set “Signing of outgoing mail enabled?” = Yes, “Reject incoming email with invalid DKIM signature?” = No and “Force generation of new private key?” = No.
  • Keep “Size of new DKIM key” = 2048, list out only 1 domain under “Domains to sign for” for which you want DKIM. Don’t list all the domains at this moment. We want to test out the setup for single domain before we setup for all domains.
  • Click “Save” button.
  • “DKIM DNS records for domains” will show value like
    202008._domainkey IN TXT ( “v=DKIM1; k=rsa; t=s; p=LONG_RANDOM_CHAR_LINE_1”
    “LONG_RANDOM_CHAR_LINE_2”
    “LONG_RANDOM_CHAR_LINE_3”
    “LONG_RANDOM_CHAR_LINE_4”
    “LONG_RANDOM_CHAR_LINE_5”
    “LONG_RANDOM_CHAR_LINE_6” )
  • When you copy the DNS record in text editor, it is show in the individual lines and not on a single line. If your DNS provider accepts TXT record in individual line, you can use it as it is provided from Virtualmin.
  • If your DNS provider accepts only one line for TXT record, you need to replace new line (plus multiple spaces) with a single space but still keep the double quote as it is.
  • Login to your DNS provider Website and select the domain for which you enabled DKIM.
  • For adding TXT record, in Hostname, use “202008._domainkey” and for Value, use “v=DKIM1; k=rsa; t=s; p=LONG_RANDOM_CHAR_LINE_1” “LONG_RANDOM_CHAR_LINE_2” “LONG_RANDOM_CHAR_LINE_3” “LONG_RANDOM_CHAR_LINE_4” “LONG_RANDOM_CHAR_LINE_5” “LONG_RANDOM_CHAR_LINE_6”
  • Value is all in a single line but segments are included within double quote and separated by single space.
  • Save this TXT record.
  • If you have already setup SPF record, it is also a good idea to setup “_dmarc” TXT DNS record.
  • To setup “_dmarc” TXT record, use “_dmarc” for Hostname and “v=DMARC1; p=none” for Value and save TXT DNS record.
  • You may verify DKIM setup using this free online service https://www.mail-tester.com/
  • Once verified, you may repeat the same process for additional domains.

Share

0 comments

Your email address will not be published. Required fields are marked *