4

I'm on Ubuntu 16 LTS, trying to sign mail with opendkim and I'm getting:

$ tail /var/log/mail.err
...
Milter (opendkim): error connecting to filter: Connection refused by localhost

I have sendmail configured with:

INPUT_MAIL_FILTER(`opendkim', `S=inet:8891@localhost')dnl

And in /etc/opendkim.conf I have:

Socket inet:8891@localhost

When I check with lsof I don't see anything listening on 8891:

 $ sudo lsof -i :8891 -n
 [nothing]

Looking at opendkim's status it says it's running:

 $ systemctl status opendkim.service
 ...
 Active: active (running)
 ...

Why isn't it listening on 8891?

Jeff Kaufman
  • 201
  • 2
  • 8

2 Answers2

4

There's another configuration file for opendkim, /etc/default/opendkim, and that file specifies a different default socket:

# Command-line options specified here will override the contents of
# /etc/opendkim.conf. See opendkim(8) for a complete list of options.
...
SOCKET="local:/var/run/opendkim/opendkim.sock"

Commenting out that line, and putting in SOCKET="inet:8891@localhost" below, worked.

Jeff Kaufman
  • 201
  • 2
  • 8
  • Sockets have less overhead than network connections. – sebix Jul 22 '17 at 09:08
  • This was totally it for me. Followed a tutorial... had everything right but missed that there was this previous SOCKET line in the conf file – JoshP Nov 30 '17 at 02:30
2

On my system, I found that I had to change

/etc/systemd/system/multi-user.target.wants/opendkim.service

from

ExecStart=/usr/sbin/opendkim -P /var/run/opendkim/opendkim.pid -p local:/var/run/opendkim/opendkim.sock

to

ExecStart=/usr/sbin/opendkim -P /var/run/opendkim/opendkim.pid -p inet:8891@localhost

And then to

systemctl daemon-reload

and

service opendkim restart

after which I could see it listening:

netstat -nalp | grep 8891

For some reason the opendkim.conf was not used to specify the port.

HTH,

M

eMaX
  • 21
  • 1
  • Wow totally intense I had to combine your solution with the accepted answer to get it working. I originally followed this guide: https://philio.me/setting-up-dkim-with-sendmail-on-ubuntu-14-04/ – Eugene van der Merwe Jan 04 '19 at 18:54