Configuring DKIM (DomainKeys Identified Mail) in Exim ensures that outgoing emails are signed with a digital signature to verify the authenticity of the sender. Here is a step-by-step guide to setting up DKIM with Exim.
Prerequisites
Before you begin:
- Exim Installed:
- Ensure Exim is installed and running on your server.
- Use the following command to check its status:
systemctl status exim - Access to Server and DNS:
- SSH access to your server.
- Control over your DNS settings to publish DKIM public keys.
- Install OpenSSL:
- OpenSSL is required to generate DKIM keys:
sudo apt install openssl
Generate DKIM Keys
Create a Directory for Keys
Choose a directory to store DKIM keys, such as /etc/exim/dkim/:
sudo chmod 700 /etc/exim/dkim
Generate a DKIM Key Pair
Replace default with the selector you want to use:
openssl rsa -in /etc/exim/dkim/default.private -pubout -out /etc/exim/dkim/default.public
Set Permissions
Restrict access to the private key:
Extract the Public Key
Format the public key for the DNS record:
The output is the key you will add to your DNS.
Configure DNS for DKIM
Add a TXT Record
Use the following format to create a TXT record in your DNS settings:
Replace:
- default with the selector you chose.
- example.com with your domain.
- PUBLIC_KEY with the content from /etc/exim/dkim/default.txt.
Verify DNS Propagation
Check the DKIM record using:
Configure Exim for DKIM
Edit Exim Configuration
Open the Exim configuration file (/etc/exim/exim.conf or /etc/exim4/exim4.conf):
Add DKIM Settings
Add the following to the configuration:
dkim_domain = ${sender_address_domain}
dkim_selector = default
dkim_private_key = /etc/exim/dkim/default.private
dkim_canon = relaxed
dkim_strict = false
This tells Exim to:
- Use the sender domain for DKIM signing.
- Use the default selector.
- Load the private key from /etc/exim/dkim/default.private.
Save and Exit
Save the file and exit (Ctrl+O, Ctrl+X).
Restart Exim
Apply the changes by restarting Exim:
Test DKIM Configuration
- Send a Test Email:
- Send an email to a DKIM testing service like:
- check-auth@verifier.port25.com
- mail-tester.com
- Check Headers:
- Look for the DKIM-Signature header in the email.
- A successful DKIM signature should appear as:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=default; - Review the DKIM Result:
- The test report will indicate if the DKIM check passed.
Troubleshooting
| Issue | Solution |
|---|---|
| No DKIM-Signature Header |
sudo tail -f /var/log/exim4/mainlog
|
| DKIM Validation Fails |
dig TXT default._domainkey.example.com
|
| Emails Flagged as Spam |
v=spf1 mx include:yourmailserver.com -all
_dmarc.example.com IN TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"
|
With DKIM configured, your emails will now include a digital signature that improves email authentication and deliverability. Combine DKIM with SPF and DMARC for robust email security.


