CentOS 6.x setup postfix + opendkim

first, you need to enable epel. after you enabled epel. please install opendkim packages

# yum install -y opendkim

second, you need to create dkim key.

# export DOMAIN=your.domain.tw
# mkdir /etc/opendkim/keys/$DOMAIN
# cd /etc/opendkim/keys/$DOMAIN
# opendkim-genkey -d $DOMAIN -s default
# chown -R opendkim: /etc/opendkim/keys/$DOMAIN
# echo “default._domainkey.$DOMAIN $domain:default:/etc/opendkim/keys/$DOMAIN/default.private” >> /etc/opendkim/KeyTable
# echo “*@$DOMAIN default._domainkey.$domain” >> /etc/opendkim/SigningTable

add your dkim key to your dns record, you need to copy the following result to add into your dns record.

echo /etc/opendkim/keys/$DOMAIN/default.tx

update the /etc/opendkim.conf

## Selects operating modes. Valid modes are s (sign) and v (verify). Default is v.
## Must be changed to s (sign only) or sv (sign and verify) in order to sign outgoing
## messages.
Mode sv

## Gives the location of a private key to be used for signing ALL messages. This
## directive is ignored if KeyTable is enabled.
#KeyFile /etc/opendkim/keys/default.private

## Gives the location of a file mapping key names to signing keys. In simple terms,
## this tells OpenDKIM where to find your keys. If present, overrides any KeyFile
## directive in the configuration file. Requires SigningTable be enabled.
KeyTable /etc/opendkim/KeyTable

## Defines a table used to select one or more signatures to apply to a message based
## on the address found in the From: header field. In simple terms, this tells
## OpenDKIM how to use your keys. Requires KeyTable be enabled.
SigningTable refile:/etc/opendkim/SigningTable

edit the /etc/postfix/main.cf to add following lines

# opendkim setup
smtpd_milters = inet:127.0.0.1:8891
non_smtpd_milters = inet:127.0.0.1:8891
milter_default_action = accept

restart the opendkim & postfix

# service opendkim restart
# service postfix restart
# chkconfig opendkim on

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.