Setup OpenDKIM With Postfix On Linux

This guide is going to work off the assumption that you already have a functional email server running with postfix on your server. This guide will show you how to setup OpenDKIM with postfix on a linux server

 

Now that opendkim is installed, you need to generate the dkim keys that you need to use to sign the emails with. There are multiple ways to do this. You can do it through the command line or you can use this serviceĀ http://dkimcore.org/tools/keys.html.

Open up this directory and open the file called “default”. Paste your private key into this file. For safe keeping you could also create another file called “public.txt” and pop the public key into this file so you can access it in the future if you need it.

Sometimes default permissions dont get correctly set. In the event that this happens run the following. There is no harm just running this query anyway.

Open up “/etc/opendkim.conf” and replace everything with the following

You now need to add a key to the keytable. This file is located in /etc/opendkim/keytable

You will also need to add a line to the signing table.
If the file doesnt exist, create it. “/etc/opendkim/SigningTable”

Open or create “/etc/opendkim/TrustedHosts” and add the following.

Add the following to your postfix main.cf file. This will instruct postfix to sign the emails with the DKIM key you setup.

Thats all thats needed. Now run opendkim and restart postfix and you should be good to go.

 

1 comment

  1. Hello, thanks for the detailed write up. I just tried this out, but after implementation I get this error SMTP Error: [451] 4.7.0 resource unavailable

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.