DomainKeys, a previous proposal by Yahoo, has been obsoleted by DKIM.
First install mail-filter/opendkim:
emerge --ask opendkim
and then configure the package, to generate the domain keys.
emerge --ask --config opendkim
The default opendkim configuration file has some defaults setup for us, but needs some modification as shown below.
Depending whether tcp or unix sockets are required, the Socket line has to be modified. By default opendkim configures itself using an ipv4 socket, but if opendkim is run on the same server as postfix, a unix socket may be preferable. In the following example configuration file, the mail server is under the domain
mail.example.com and had as a hostname also
If this host handles more (virtual) domains and the same single key is to be used for all the virtual hosts, Domain can point to a file, for example /etc/opendkim/domains with one domain per line. More complex configurations, like separate key per domain, are possible, but are beyond the scope of this example.
Domain example.com Selector mail KeyFile /etc/opendkim/mail.private Socket local:/var/run/opendkim/opendkim.sock UMask 002 ReportAddress firstname.lastname@example.org PidFile /var/run/opendkim/opendkim.pid UserID milter
Also prepare the socket/pidfile location.
chown milter:milter /var/run/opendkim
With this, opendkim can be started (by default) and should be functional.
rc-update add opendkim default
Mail and spam filters will verify the signed e-mails by using the key in the DNS system and thus, access to the DNS records is required. A TXT entry needs to be added for domain that is being used to send signed e-mail.
And example how to add this information to bind is shown here, the public key for the domain is printed in the package configuration step, but can also be found in the example dns record in /etc/opendkim/mail.txt for our
mail._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MIGaslkjD08u98adfaSDSDaasda898932asd...afDaDSD898sDSLSKDJLSDJSLDKJLDSKJ;"
The private key is written to /etc/opendkim/mail.private and should not be shared with anyone.
A restart or reload may be required to synchronize this new record to the secondary servers and propagated through the DNS system. Once the record is visible in the DNS system, the key can be used. Keep this in mind if testing fails, check the domains TXT record.
Finally, postfix needs to be informed of the change, depending on whether the inet or unix socket is being used, this has to be added to the postfix configuration file. In the following example both approaches are shown, where the socket variant is preferred. Double check that the socket or port used here, match the one from the opendkim configuration file.
# OpenDKIM mail verification smtpd_milters = unix:/var/run/opendkim/opendkim.sock non_smtpd_milters = unix:/var/run/opendkim/opendkim.sock #smtpd_milters = inet:localhost:8891 #non_smtpd_milters = inet:localhost:8891
Opendkim runs under the milter user. This is good, but postfix can't access this. Adding postfix to the milter group solves this easily however.
usermod -a -G milter postfix
Informing postfix of the change makes immediate use of DKIM, a restart is required due to the change of permissions.
To test the DKIM setup a blank email can be sent to
email@example.com. An e-mail will be sent within 30 seconds with a test report.
Anything related to DomainKeys can be ignored: it is an obsolete standard.