4

I want to setup automatic signing with DKIM for all outgoing emails. This ir virtual private server and hosts a single website. I have tried lots of tutorials on how to implement dkim email signing, but when i send email, anything related to dkim does not even show in syslog. Server is Ubuntu 14.04.

Postfix:

milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8892
non_smtpd_milters = inet:localhost:8892

opendkim.conf:

Syslog                  yes
LogWhy                  yes
LogResults              yes
Mode                    s
Domain                  *
KeyFile                 /etc/opendkim/email.key
Selector                email
Socket                  inet:8892@localhost

All that is showing when i start opendkim is

Jan 15 11:57:55 xxx opendkim[19947]: OpenDKIM Filter: mi_stop=1
Jan 15 11:57:55 xxx opendkim[19947]: OpenDKIM Filter v2.9.1 terminating with status 0, errno = 0
Jan 15 11:57:55 xxx opendkim[19999]: OpenDKIM Filter v2.9.1 starting (args: -x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid)

This is what happens after postfix restart and mail sending:

Jan 15 15:55:52 example postfix/master[21899]: daemon started -- version 2.11.0, configuration /etc/postfix
Jan 15 15:55:54 example named[491]: client 82.146.43.2#14622 (example.ru): query (cache) 'example.ru/SOA/IN' denied
Jan 15 15:56:00 example opendkim[21598]: OpenDKIM Filter: mi_stop=1
Jan 15 15:56:00 example opendkim[21598]: OpenDKIM Filter v2.9.1 terminating with status 0, errno = 0
Jan 15 15:56:00 example opendkim: "X-Header" deprecated; use "SoftwareHeader" instead
Jan 15 15:56:00 example opendkim[21912]: OpenDKIM Filter v2.9.1 starting (args: -x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid)

Jan 15 15:56:17 example postfix/pickup[21902]: 73C043C7C: uid=33 from=<zet@example.ru>
Jan 15 15:56:17 example postfix/cleanup[21922]: 73C043C7C: message-id=<1421326577.54b7b8f16b84b@www.example.ru>
Jan 15 15:56:17 example postfix/qmgr[21903]: 73C043C7C: from=<zet@example.ru>, size=954, nrcpt=1 (queue active)
Jan 15 15:56:18 example postfix/smtp[21924]: 73C043C7C: to=<web-y5pBEq@mail-tester.com>, relay=mail-tester.com[37.59.112.152]:25, delay=0.6, delays=0.02/0/0.44/0.13, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 0366B1241E58)
Jan 15 15:56:18 example postfix/qmgr[21903]: 73C043C7C: removed
Deniss Kozlovs
  • 191
  • 1
  • 9
  • What about your `/etc/default/opendkim` file, I believe you need the line `SOCKET="inet:8892@localhost"` there also (or maybe only). – NickW Jan 15 '15 at 11:22
  • Hi, comment in the file states that "Command-line options specified here will override the contents of /etc/opendkim.conf". Anyway, i put there also, no changes. – Deniss Kozlovs Jan 15 '15 at 12:17
  • So, when you run netstat, can you see the opendkim port there in the list? – NickW Jan 15 '15 at 12:19
  • Actually, no, i can see it in process list: opendkim 21598 0.0 0.0 225016 2392 ? Ssl 15:31 0:00 /usr/sbin/opendkim -x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid – Deniss Kozlovs Jan 15 '15 at 12:32
  • Yes now i see it in nestat also: *tcp 0 0 localhost.localdom:8892* – Deniss Kozlovs Jan 15 '15 at 12:45
  • I'm honestly surprised that postfix isn't at least logging attempts to use the port, normally it attempts to connect to it on any incomng mail.. you've restarted postfix (stupid question, but I need to ask it) right? – NickW Jan 15 '15 at 12:50
  • Yes. service postfix restart && service opendkim restart. I updated the question with syslog results. – Deniss Kozlovs Jan 15 '15 at 12:57

2 Answers2

4

Fixed it. I don't know how but I had no_milters set in /etc/postfix/master.cf in "pickup" service. It prevents postfix to send email to milter.

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
Deniss Kozlovs
  • 191
  • 1
  • 9
0

I found cat /var/run/opendkim/opendkim.pid = 3091.

I inserted the line Socket inet:3091@localhost in opendkim.conf.

I added

smtpd_milters = inet:localhost:3091
non_smtpd_milters = inet:localhost:3091. 

And finally, opendkim is communicating with postfix.

I checked with netstat -apn | grep opendkim:

tcp        0      0 127.0.0.1:3091          0.0.0.0:*               LISTEN      593/opendkim
unix  3      [ ]         STREAM     CONNECTED     19033    593/opendkim
unix  3      [ ]         STREAM     CONNECTED     19034    593/opendkim
unix  3      [ ]         STREAM     CONNECTED     19036    593/opendkim
unix  3      [ ]         STREAM     CONNECTED     19035    593/opendkim
unix  2      [ ]         DGRAM                    18155    593/opendkim

Up and running!

Daniele Santi
  • 2,529
  • 1
  • 25
  • 22