postfix/smtpd: warning: connect to Milter service unix:/var/run/opendkim/opendkim.sock: No such file or directory
- Check if opendkim is running. (I assume it is as you saw the socket file.)
Did you configure opendkim? The configuration file is
/etc/opendkim.conf
.You need to update the file to match your site/domain and dkim.key path.
Add postfix to opendkim group
If opendkim.sock permission is as follow
$ ls -l /var/run/opendkim -rw-rw-r-- 1 opendkim opendkim 6 May 2 14:56 opendkim.pid srwxrwxr-x 1 opendkim opendkim 0 May 2 14:56 opendkim.sock
If Not, make sure
UMask
is set to0002
in/etc/opendkim.conf
.Then do the following
sudo adduser postfix opendkim
Postfix running in chroot
Modify
/etc/default/opendkim
, change SOCKET option to postfix chroot locationSOCKET="local:/var/spool/postfix/var/run/opendkim/opendkim.sock"
You will have to create directory
/var/spool/postfix/var/run/opendkim
and change its permissionsudo mkdir -p /var/spool/postfix/var/run/opendkim sudo chown opendkim:opendkim /var/spool/postfix/var/run/opendkim
Restart opendkim
sudo service opendkim restart
Quick summary that helped me to fix this warning on Ubuntu 16.04 LTS: Postfix version 3.1.0-3ubuntu0.2 Opendkim version 2.10.3-3build1
(I assume that Postfix and Opendkim are already installed, integrated with each other and the only warning you are getting is 'connect to Milter service local:/var/spool/postfix/opendkim/opendkim.sock: No such file or directory')
Add user postfix to group opendkim (skip if already done)
sudo adduser postfix opendkim
- Create directory and set owner (skip if already done)
sudo mkdir -p /var/spool/postfix/var/run/opendkim
sudo chown opendkim:opendkim /var/spool/postfix/var/run/opendkim
- Check permissions:
ls -l /var/spool/postfix/var/run/opendkim
srwxrwxr-x 1 opendkim opendkim 0 Nov 12 14:34 opendkim.sock
- Edit opendkim configuration files: /etc/opendkim.conf, add line
Socket local:/var/spool/postfix/var/run/opendkim/opendkim.sock
/etc/defaults/opendkim, add
SOCKET="local:/var/spool/postfix/var/run/opendkim/opendkim.sock"
- Edit postfix configuration: /etc/postfix/main.cf
# Milter configuration # Postfix ≥ 2.6 milter_protocol = 6, Postfix ≤ 2.5 milter_protocol = 2 milter_protocol = 6 milter_default_action = accept smtpd_milters = unix:var/run/opendkim/opendkim.sock non_smtpd_milters = unix:var/run/opendkim/opendkim.sock
- Restart services (or reboot)
systemctl restart opendkim
systemctl restart postfix
That's it. I don't know why it's necessary to write
smtpd_milters = unix:var/run/opendkim/opendkim.sock
instead of
smtpd_milters = local:/var/spool/postfix/var/run/opendkim/opendkim.sock
. If somebody knows, explanations are welcome.
I was facing the same issue on Debian stretch, which turned out to be caused by a broken systemd service file for opendkim. See this answer for a solution: https://serverfault.com/a/847442/84962
This fix boils down to:
/lib/opendkim/opendkim.service.generate
systemctl daemon-reload
service opendkim restart