• 安装程序
sudo yum install opendkim
  • 生成keys
sudo mkdir /etc/opendkim/keys/mydomain.com
sudo opendkim-genkey -D /etc/opendkim/keys/mydomain.com/ -d mydomain.com -s default #mydomain.com改成自己的域名
sudo chown -R opendkim:opendkim /etc/opendkim/keys/mydomain.com
  • 编辑/etc/opendkim.conf如下
AutoRestart             Yes
AutoRestartRate         10/1h
LogWhy                  Yes
Syslog                  Yes
SyslogSuccess           Yes
Mode                    sv
Canonicalization        relaxed/simple
ExternalIgnoreList      refile:/etc/opendkim/TrustedHosts
InternalHosts           refile:/etc/opendkim/TrustedHosts
KeyTable                refile:/etc/opendkim/KeyTable
SigningTable            refile:/etc/opendkim/SigningTable
SignatureAlgorithm      rsa-sha256
Socket                  inet:8891@localhost
PidFile                 /var/run/opendkim/opendkim.pid
UMask                   022
UserID                  opendkim:opendkim
TemporaryDirectory      /var/tmp
  • /etc/opendkim/KeyTable
default._domainkey.mydomain.com mydomain.com:default:/etc/opendkim/keys/mydomain.com/default #把mydomain.com换成自己的域名
  • /etc/opendkim/SigningTable
*@mydomain.com default._domainkey.mydomain.com #把mydomain.com换成自己的域名
  • /etc/opendkim/TrustedHosts
127.0.0.1
mydomain.com #换成自己的域名
  • /etc/opendkim/keys/mydomain.com/default.txt
default._domainkey      IN      TXT     ( "v=DKIM1; k=rsa; "
          "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDApHRr7ZmXRaAB+RQRbP4VdMwIrIHIP18KFtXRsv/xpWc0Gix6ZXN13fcG03KNGKZo2PY+csPkGC5quDnH5V0JEhDZ78KcDWFsU6u4fr9ktVAdt6P7jWXjcyqdHOZ8+YN4cAeU4lRFNgQvdupIcByYwzPYMgBFHfJm9014HvRqhwIDAQAB" )  ; ----- DKIM key default for mydomain.com

DNS中再建个TXT项,并把括号中除去引号的所有信息填到DNS中的TXT中。

  • /etc/postfix/main.cf添加如下参数
smtpd_milters           = inet:127.0.0.1:8891
non_smtpd_milters       = $smtpd_milters
milter_default_action   = accept
milter_protocol         = 2
  • 设置自动启动
sudo systemctl enable opendkim
sudo systemctl start opendkim

参考文档:

http://www.linuxtechi.com/configure-domainkeys-with-postfix-on-centos-7/

https://www.rosehosting.com/blog/how-to-install-and-configure-dkim-with-opendkim-and-exim-on-a-centos-7-vps/

邮件分数检测地址

Related content