Fight against spam part 2 – Postfix DKIM

DomainKeys Identified Mail (DKIM) – is an email authentication method designed to detect email spoofing by providing a mechanism to allow receiving mail exchangers to check that incoming mail from a domain is authorized by that domain’s administrators. It is intended to prevent forged sender addresses in emails, a technique often used in phishing and email spam. – Wikipedia


This is a continuation of topic about fighting against spam when you are self-hosting your mail server which in this case should be Postfix.


Install needed packages:

Let us configure opendkim, if 12301port is use by some other service change it in below configuration:

Add support for this tool inside postfix:

If we already have something in lines smtpd_milters i/lub non_smtpd_milters we can add new tools after comma.

Create needed folders and configuration files, which we used as table source in configuration above:

Let us generate keys to use with DKIM:

Now we need to add proper key to TXT record in our DNS server:

We need to restart every service that we just edit configuration file:

To ensure we configure this properly the best way would be send email to service that check this for us, for example: check-auth(at)


Rest post related to this topic:

Postfix i Dovecot – perfect duo for mail server

Fight against spam part 1 – Postfix SPF

Fight against spam part 3 – Postfix DMARC

Fight against spam part 4 – Postfix SpamAssassin

Fight against spam part 5 – Dovecot Sieve



Leave a Reply

Your email address will not be published. Required fields are marked *