Configuring multiple DKIM signatures with OpenDKIM and Postfix involves several steps. Here's a detailed guide to help you through the process:
- Install OpenDKIM:
First, you need to install OpenDKIM on your system. The installation process varies depending on your operating system. For example, on Debian-based systems like Ubuntu, you can use the following command:
sudo apt-get update
sudo apt-get install opendkim opendkim-tools
On CentOS/RHEL systems, you can use the following command:
sudo yum install opendkim opendkim-tools
- Configure OpenDKIM:
Create a directory to store OpenDKIM keys and configuration files:
sudo mkdir /etc/opendkim
sudo chown -R root:root /etc/opendkim
Next, create a symbolic link to the default configuration file:
sudo ln -s /usr/share/doc/opendkim/examples/opendkim.conf.example /etc/opendkim/opendkim.conf
- Configure Postfix to use OpenDKIM:
Edit the Postfix main.cf file to enable DKIM support and specify the OpenDKIM socket:
sudo nano /etc/postfix/main.cf
Add or modify the following lines:
milter_default_action = accept
smtp_milters = inet:localhost:8891
non_smtp_milters = inet:localhost:8891
- Configure OpenDKIM to sign emails:
Edit the OpenDKIM configuration file:
sudo nano /etc/opendkim/opendkim.conf
Modify the following lines to match your setup:
Socket = local:8891@UNIX:/var/run/opendkim/opendkim.sock
UserID = opendkim:opendkim
DetachTimeOut = 10
SignatureAlgorithm = rsa-sha256
KeyTable = /etc/opendkim/KeyTable
SignatureTable = /etc/opendkim/SignatureTable
Mode = sv
ExternalIgnoreList = /etc/opendkim/TrustedHosts
- Create the OpenDKIM signature table:
Create a new file for the SignatureTable, which specifies the DKIM keys to use:
sudo nano /etc/opendkim/SignatureTable
Add the following line for each domain you want to sign emails for. Replace your-domain.com with your actual domain name:
your-domain.com:*@your-domain.com:/etc/opendkim/keys/your-domain.com
- Create the OpenDKIM key table:
Create a new file for the KeyTable, which specifies the location of the DKIM keys:
sudo nano /etc/opendkim/KeyTable
Add the following line for each domain you want to sign emails for. Replace your-domain.com with your actual domain name and /path/to/your/key with the actual path to your key file:
your-domain.com:mail.your-domain.com:/path/to/your/key
- Generate DKIM keys:
Run the following command to generate a new DKIM key for each domain you want to sign emails for:
sudo opendkim-genkey -t -s your-domain.com -n mail._domainkey.your-domain.com -f /etc/opendkim/keys/your-domain.com
Replace your-domain.com with your actual domain name. This command will create a new private and public key in the /etc/opendkim/keys