Postfix/DKIM

OpenDKIM
For more information on DKIM, see its Wikipedia page.

First, install :

Configure the package, to generate the domain keys:

The default opendkim configuration file has some defaults setup, but needs some modification as shown below. Note that the  line in the  file is overridden by the settings in the  file. 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  and had as a hostname also   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 with one domain per line. More complex configurations, like separate key per domain, are possible, but are beyond the scope of this example.

Example config:

Also prepare the socket/pidfile location:

With this, opendkim can be started and should be functional:

Start "on boot":

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.

An example of 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 for the   host:

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:

Opendkim runs under the  user. This is good, but postfix can't access this. Adding postfix to the  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:

SPF
To activate SPF (Sender Policy Framework), just add the appropriate DNS entries. SPF works by looking up the given domain (example.com), and searching for DNS TXT entries that hold SPF information. This comes as a list of IP addresses that are allowed to send mail on behalf of the domain. If the IP of the sending server is not found in the SPF record, this counts as a violation of the SPF policy. Thus, it is important that to add ALL servers that are allowed to send mail on behalf of the domain:

Testing
To test the DKIM setup, a blank email can be sent to. An e-mail will be sent within 30 seconds with a test report.