Good! I figured this out from the post mentioned in the question. I made a kind of mix between the answer itself and the links provided in it. Specially the fourth link is the one I used.
So the thing goes like this. Suppose you've got a server or VPS and make one of your domains to be the main domain and be used as the server name (in my example: mydomain.com).
So, firts of all, we'll change to root to make things easier, but you can skip this step and use sudo befor every command.
Now, we install OpenDKIM:
apt-get install opendkim opendkim-tools
Lets fix the configuration file. We're opening
/etc/opendkim.conf for edition. I use nano, but it's the same with other editor.
Once opened, make it look like this. If you feel comfortable, you can change some options, but the
Selector must remain commented.
# This is a basic configuration that can easily be adapted to suit a standard
# installation. For more advanced options, see opendkim.conf(5) and/or
# Commonly-used options
# Log to syslog
# Required to use local socket with MTAs that access the socket as a non-
# privileged user (e.g. Postfix)
Next, we create some of the folder and files that will hold information about what should OpenDKIM use and process. For now, the
TrustedHosts file. We create and edit it:
We must put into this file a list of trusted addresses: localhost and 127.0.0.1, and your server name and IP:
Now we edit OpenDKIM config file.
And add these lines at the end of the file. They'll tell OpenDKIM in which port it should expect signing requests:
SOCKET="inet:8891@localhost" # listen on loopback on port 8891
We open Postfix config file.
And add these lines to the end of the file. They'll tell Postfix that it should send e-mails to be signed and where.
milter_default_action = accept
milter_protocol = 6
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
If you're not adding domains right now, you can restart everything, so the configuration takes effetc.
Done! The server is ready to work with DKIM. Now, you need to add your domains to this system. The following process is the same for all the domains you want to add. I'll use otherdomain.com for the example, rplace it with your own.
Remember I was root from before, but if you're not, run
sudo su or precede your commands with the keyword
First, we create a directory for our domain and go inside of it:
mkdir -p /etc/opendkim/keys/otherdomain.com
Now we generate a key for the domain:
opendkim-genkey -r -d otherdomain.com
We give OpenDKIM user the ownership of the newly created file:
chown opendkim:opendkim default.private
And we open the
KeyTable file to add our new key for our new domain:
We add to the end of the file (after all other domains we may have here):
We open the
And append at the end of the file (again, we'll have one line for each domain):
I'm not sure of the necessity to do the next step, but I just did it, just in case... We open the
And add at the end of the file:
One last thing: we show the contents of the file
And add the information between the quotes to a
TXT record in the DNS Zone of the domain, and we must also use
default._domainkey as the name of the record. NOTE: "between the quotes" is the text that starts with "
If we're done adding domains (by now), we restart everything to apply the cnages.