Postfix/DKIM

= Introduction = This guide will show you how to configure Postfix to use DKIM. DKIM functionality is provided by the package. To read more about DKIM, see its wiki page.

OpenDKIM
First install :

and then configure the package, to generate the domain keys.

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 'mail' which the configuration of the package picked up. 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.

With this, opendkim can be started (by default) and should be functional.

DNS
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 host.

{Note: 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.

Postfix
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.

By default, 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.

Informing postfix of the change makes immediate use of DKIM, a restart is required due to the change of permissions.

Testing
To test the DKIM setup a blank email can be sent to 'check-auth@verifier.port25.com'. An e-mail will be sent within 30 seconds with a test report. Anything related to DomainKeys can be ignored.