For a while now, I’ve been having problems with DKIM. It wasn’t working. My logs always had the same error:
warning: connect to Milter service inet:localhost:12345: Connection refused
And I’d look for a fix but never find anything useful.
Today I decided to go through my mail quarantine folders. In them I found several emails from a friend who is having problems with spammers using his email address. None of them are going through his mail server, they’re all spoofed. We’ve compared our SPF records and they look right. So I went and looked up why I’m seeing all these mails.
Turns out that not all mail admins have set up their servers right to look at SPF and block. That was my problem.
So I went and found a howto for my operating system to fix SPF with my Mail Transfer Agent (MTA). The document, provided by my VPS hosting provider, had how to set up SPF, how to configure my MTA to quarntine emails that fail SPF, a DKIM walk through, a ADSP howto, and a DMARC howto, all on the same page.
First things first. I fixed the SPF inbound. Now it should do the stuff it needs to. Then I figured since I still had time, I’d go after the DKIM problem.
So I backed up my existing files and followed along. AND NOTHING WORKED!. Still the same problem. Heck even the same error message.
apt-get remove --purge opendkim opendkim-tools
apt-get install opendkim opendkim-tools
later and I started completely fresh. Nothing old, not even the old backup files.
And it still didn’t work. sysctrl status -l opendkim.service and journalctrl -xe were not much help either. Neither one gave enough information on what was wrong.
I did some searching through the logs, and found that even after changing the port to a local socet for Milter it still couldn’t work. But this time I found that it couldn’t see the files, and searching the directory that local socket should be in, it wasn’t there. After much googling I found an old bug report for Debian (my OS of choice). If the socket and pid files were missing, do this:
service opendkim restart
And suddenly everything was working. I sent test emails to test services, and they seem to be working. At least they told me that everything works.
Then I went why not and set up the ADSP and DMARC stuff in DNS.
Really just happy to get past the problem where dkim isn’t working. Now to go finish clearing out the quarantine files.