I've tried everything I can think of to get DKIM working with Exim4 on my Ubuntu 16.04 server, but emails sent from my server are still not signed with DKIM!

I am using Exim4, unsplit configuration.

I generated private and public keys using these commands in /etc/exim4/dkim:

sudo openssl genrsa -out dkim.key 1024
sudo openssl rsa -in dkim.key -pubout > dkim.pub

I edited the following lines in /etc/exim4/exim4.conf.template:

dkim_domain = ${lc:${domain:$h_from}}
dkim_selector = mail
dkim_private_key = /etc/exim4/dkim/dkim.key
dkim_canon = relaxed

Then ran these commands:

sudo update-exim4.conf
sudo service exim4 restart

Added this TXT record to my DNS records (using the public key):

TXT mail._domainkey "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvnoSm2o5X9JoCKfYlhkRv5mj4yRscjlv5JmNj1PfBeZGp57XgriRCcA4S5/egrPI2VfKzoCwRsGp4uCD/UJ7+6DgCVNseSlD+n6n4mRANWWlfY7LvHfp8sAR80aurwNyx7/PHGg+ZukHcllvYCtZtg4jtZTrl8w1yiKXyJ3G3fQIDAQAB"

Sent an email from my server to my Gmail address, and it went straight to spam. I click "Show original" and DKIM is not mentioned anywhere in the email headers.

Please tell me what I'm doing wrong! Thanks!

  • Do you have DKIM_* variables defined to trigger ifdefs? Do you have multiple sending domains or single one that can be defined explicitly? – Kondybas Nov 16 '17 at 6:23
  • @Kondybas Sorry, I'm not sure what you mean by "DKIM_* variables defined to trigger ifdefs". Could you explain to me how this works? I have multiple websites (sending domains) on this server, but I also have two more servers with just one sending domain each. – torjinx Nov 17 '17 at 2:20

eximallows conditional runtime configuration.

XXXX = something

.ifdef XXXX
<some directives>

If variable XXXX have some value assigned then it becomes "defined" and .ifdef XXXX is evaluated to TRUE. Even if XXXX is defined as XXXX = false it is still defined somehow. Line should be commented out to prevent definition. Bundled config contains lot of config snippents for many situations but they are usually disabled by control variables commented out.

In your case you have to find where the DKIM_DOMAIN, DKIM_SELECTOR, DKIM_PRIVATE_KEY and the rest of DKIM_* variables defined and uncomment them.

  • I could kiss you!!! I changed /etc/exim4/exim4.conf.template back to the default, created /etc/exim4/exim4.conf.localmacros and defined the four variables in there. Then ran sudo update-exim4.conf and sudo service exim4 restart. It's finally working, thanks so much!! – torjinx Nov 17 '17 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.