DKIM (DomainKeys Identified Mail) with Postfix on Ubuntu

Google mail system repeatedly put mail from my domain to spam, I found, that there should be done certain steps in order to fix this problem. The most important and the most effective solution was to sign outcoming e-mails with DKIM signature.

Installation

Setup

Opendkim configuration

In file /etc/opendkim.conf add the following lines:

In file /etc/default/opendkim the following lines

In file /etc/systemd/system/multi-user.target.wants/opendkim.service

File /etc/opendkim/KeyTable

File /etc/opendkim/SigningTable

File /etc/opendkim/TrustedHosts

Key creation

Postfix configuration

Configure postfix. In /etc/postfix/main.cf write the following:

Restart services

Note: Replace domain.com with your domain name.

DNS entry

opendkim-genkey generated dkim.txt file. In this file you will find some code. You need to copy line starting with “v=DKIM1;” and will last double quotes. You can omit “h=sha256; k=rsa; t=y;” as they are default

In your DNS management system you need to add following TXT entry

after this you will be able to dig the value

After these steps, you will see a running daemon opendkim on port 8891 and Postfix will ask for signature from it. In my case gmail accepts all my e-mails.