Era Host hosting
EraHost – Free Domain, Cheap Hosting!
Client Area
Support 24/7
Menu

Setting Up DKIM with Exim

4 min read
28.11.2025

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.

Exim DKIM Setup
Exim DKIM — keypair + DNS TXT + transport directives.

For closely related DKIM and Exim topics, see Fixing t_dkim_invalid (DKIM Signature Issue), Exim Syntax Errors — Causes and Fixes, Understanding cm._domainkey — DKIM Selector Example, and check-auth@verifier.port25.com.

Prerequisites

Before you begin:

  1. Exim Installed:
    • Ensure Exim is installed and running on your server.
    • Use the following command to check its status:
    • systemctl status exim
  2. Access to Server and DNS:
    • SSH access to your server.
    • Control over your DNS settings to publish DKIM public keys.
  3. 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 mkdir -p /etc/exim/dkim
sudo chmod 700 /etc/exim/dkim

Generate a DKIM Key Pair

Replace default with the selector you want to use:

openssl genrsa -out /etc/exim/dkim/default.private 2048
openssl rsa -in /etc/exim/dkim/default.private -pubout -out /etc/exim/dkim/default.public

Set Permissions

Restrict access to the private key:

sudo chmod 600 /etc/exim/dkim/default.private

Extract the Public Key

Format the public key for the DNS record:

awk 'NR > 1 && NR < 10' /etc/exim/dkim/default.public | tr -d '\n' > /etc/exim/dkim/default.txt

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:

default._domainkey.example.com IN TXT "v=DKIM1; k=rsa; p=PUBLIC_KEY"

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:

dig TXT default._domainkey.example.com
Linux VDS
High performance for your projects
  • Root access and flexible setup
  • Control panel
  • NVMe disks
  • DDR5
Linux VDS

Configure Exim for DKIM

Edit Exim Configuration

Open the Exim configuration file (/etc/exim/exim.conf or /etc/exim4/exim4.conf):

sudo nano /etc/exim/exim.conf

Add DKIM Settings

Add the following to the configuration:

# DKIM Settings

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:

sudo systemctl restart exim

Test DKIM Configuration

  1. Send a Test Email:
    • Send an email to a DKIM testing service like:
    • check-auth@verifier.port25.com
    • mail-tester.com
  2. 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;
  3. Review the DKIM Result:
    • The test report will indicate if the DKIM check passed.

Troubleshooting

Issue Solution
No DKIM-Signature Header
  • Verify Exim logs for errors:
  • sudo tail -f /var/log/exim4/mainlog
  • Check if the dkim_private_key path is correct.
DKIM Validation Fails
  • Ensure the public key is correctly added to the DNS TXT record.
  • Check for formatting issues: no extra spaces or line breaks in the p= value.
  • Verify DNS propagation using:
  • dig TXT default._domainkey.example.com
Emails Flagged as Spam
  • Ensure SPF and DMARC are also configured:
  • SPF Record:
  • v=spf1 mx include:yourmailserver.com -all
  • DMARC Record:
  • _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.

Frequently asked questions
Key file readable only by Exim's user (typically `Debian-exim` or `exim`). `chown Debian-exim:Debian-exim dkim.private` then `chmod 600`. Anyone else able to read the file can sign as you and your DKIM auth is compromised. Never world-readable.
Inside the `remote_smtp` transport block, under `transport_filter` and any ACL conditions, add: `dkim_domain = $sender_address_domain`, `dkim_selector = default`, `dkim_private_key = ${if exists{/etc/exim4/dkim/...}}`. Then reload Exim. On cPanel, manage in `/etc/exim.conf.local` or via WHM's Email Deliverability UI.
One selector per domain is cleanest. Each domain has its own DKIM TXT and its own private key. In Exim: `dkim_domain = $sender_address_domain`, `dkim_private_key = /etc/exim4/dkim/$sender_address_domain.private`. Each key file named after the domain. Then Exim auto-picks the right key per domain at signing time.
Send a test from your Exim server to check-auth@verifier.port25.com. Reply email includes "DKIM check details:" — pass means it's working, anything else is misconfigured. Or mail-tester.com gives a more detailed score across SPF/DKIM/DMARC/blacklists. Both free, both reliable.
Related articles
How to Link a Domain with Yahoo Mail and Use It as a Corporate Email
SpamRL Blacklist: How to Block Malicious Emails Using SpamRL
DKIM=Temperror: No Key for Signature