I got DKIM setup on my mail server (postfix and ubuntu) so it signs outgoing emails. I used these instructions: https://help.ubuntu.com/community/Postfix/DKIM
However, I need it to sign emails from any domain (in the From address) and not just my own. I'm building an email newsletter service and clients will be sending their own email through the server.
First I set "Domain *" in /etc/dkim-filter.conf. This got it to include the DKIM headers in all outgoing emails, no matter what the domain.
However, the verification check fails on gmail because it is checking the domain in the from address, and not my domain (and dns record). Does anyone know how to do this?
Ok I managed to figure this out on my own, but I wanted to post the steps here for posterity because there was zero documentation on this (that I could find) and it was practically guess and check.
After I set "Domain *" as described above, it would sign it like this:
notice the "d=clientdomain.com". It was generating this based on the from address in the email, where the from address was something like "[email protected]". Obviously if it checked the client's domain and not mine no DNS TXT record was there and the verification would fail.
So anyway I found out in this documentaion that you can set a KeyList parameter. http://manpages.ubuntu.com/manpages/hardy/man5/dkim-filter.conf.5.html
It didn't really describe what I wanted to do, but I figured I'd play with it. I commented out KeyFile and set KeyList to "/etc/mail/dkim_domains.key" which is an arbitrary file name I made up. I then created that file and put this in it "*:feedmailpro.com:/etc/mail/dkim.key". This tells it for any client domain, sign it with my domain (feedmailpro.com), and use the dkim.key file.
Restarted DKIM and postfix
Now this is the key it generated when I sent a test email.
Improvement, you see the d= now is set to my domain (even though the from address of the email was not my domain). However s= got changed to "dkim.key" instead of the selector I chose in dkim-filter.conf. In the original setup instructions I'd set the selector to "mail". That was weird, but I noticed it changed it to the filename of my key, dkim.key.
So I went and renamed "/etc/mail/dkim.key" to "/etc/mail/mail". Also updated the reference to it in "/etc/mail/dkim_domains.key".
Restart dkim-filter and postfix again same as above, and now it started working. Here is the final header which signs correctly using the right selector (apparently based off the filename of the key).
Now s=mail is right, and d=feedmailpro.com is right. It works!
Overall this was way harder than I expected and there seemed to be zero documentation on how to do this (signing for all outgoing domains), but I guess it's open source software so I can't complain.
One final note, to check if the TXT DNS record was setup correctly you can do a command like with your domain
May need to install dig (sudo apt-get install dig). If you're using Slicehost manager to add the DNS entry, you'd enter the TXT record like this.
I don't really understand why the name is set to "mail._domainkey" without a period on the end or without my domain, like "mail._domainkey.feedmailpro.com". But whatever, it seems to work so I'm happy.
If you're trying to duplicate this, here are the instructions I started with: https://help.ubuntu.com/community/Postfix/DKIM
Inspired by Brian Armstrong's answer for dkim-filter here's how I did this for OpenDKIM.
/etc/opendkim.conf
Note that SigningTable has refile: in it's definition, this specifies that the file includes regular expressions; in our case the * wildcard.
/etc/mail/dkim_key_table
Here keyname is used to match the key between this file and the dkim_signing_table file. In my real file I named this the same as my selector.
example.com and selector should be replaced which the domain and selector that you wish to be used in your signature's d= and s= respectively.
/etc/mail/dkim_signing_table
This file simple maps address found in the From: header to a key in the dkim_key_table. In this case we want all email's sent via this server to be signed with the same key, so a * wildcard is used.
Old thread but maybe someone else who finds this has a use to knowing the 2.x version of opendkim works with KeyTable instead of KeyList.
You can convert your KeyList file with the opendkim-convert-keylist tool (http://manpages.ubuntu.com/manpages/lucid/man8/opendkim-convert-keylist.8.html)
You can read more about the implementation of KeyTable on the opendkim man page: (http://www.opendkim.org/opendkim.conf.5.html)
Documentation for DKIM filter is usually installed in thre unix man format. Only Google does know it :-) I also had a problem.
I tried it on Debian. If it is not not actually in your distibution, you can download source tarball and easy read doc.
etc.
--
So that you can use exacttly the same in both DNS records of different domains.