Question

Cannot get DKIM working with Exim4

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:

.ifdef DKIM_DOMAIN
dkim_domain = ${lc:${domain:$h_from}}
.endif
.ifdef DKIM_SELECTOR
dkim_selector = mail
.endif
.ifdef DKIM_PRIVATE_KEY
dkim_private_key = /etc/exim4/dkim/dkim.key
.endif
.ifdef DKIM_CANON
dkim_canon = relaxed
.endif

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!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

My question was answered on ServerFault! For anyone needing the answer, here it is: https://serverfault.com/questions/883666/cannot-get-dkim-working-with-exim4/883893#883893

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel