[Postfix进阶]CentOS邮件系统添加DKIM签名

in postfix •  8 years ago 

postfixdkim
在之前的帖子里(《Postfix添加DKIM协议,完善DNS中的SPF解析》),最后实现的DKIM效果是失败的,发送出的邮件并不带DKIM签名。但是我一直没有发现问题所在。

使用DKIM可以使得vps邮件系统发送出去的邮件被标记为Spam的程度降低了(DKIM是个评分标准)。这样会减少可能被标记为Spam的机会。所以使用DKIM还是比较有必要的。

对于DKIM,它的全称是电子邮件验证标准——域名密钥识别邮件标准,是DomainKeys Identified Mail的缩写。

今天在无意发现syslog服务被我禁用后,我总算知道为毛我一直没看到任何错误,fuck。

在启用了服务后,终于在/var/log/maillog看到了错误报告:
warning: connect to Milter service local:/var/run/dkim-milter/dkim.sock: Permission denied
检查了权限问题,发现毫无问题。

不巧,还是今天,承蒙Roy(PaulHost、PaulVPS、WitLayer Cloud创立者)的慷慨,借用了临时vps(与现在vps相同配置),使用了Debian系统,测试是没有问题,邮件生成并带有DKIM签名。

回到CentOS,在尝试了重装postfix,dkim-milter等之类失败后,我尝试修改配置,Socket不以文件方式,而直接使用port,并且对配置进行其它微调(后面会给出shell)。

好消息是成功了,在/var/log/maillog中提示了:
dkim-filter[13247]: Sendmail DKIM Filter v2.8.3 starting
并且发出去的邮件都带有DKIM签名。如下图所示:
QQ截图20130807214512

下面是安装方式,原创(* 记得一些参数要根据你的情况修改):
#本教程可以保存为sh,执行安装
#有bug或者一些错误,欢迎交流!
rpm -ivh http://download4.fedora.redhat.com/pub/epel/5/uname -i/dkim-milter-2.8.3-8.el5.uname -i.rpm --nodeps
wget -O dkim-milter.tar.gz http://sourceforge.net/projects/dkim-milter/files/latest/download?source=files
tar zxvf dkim-milter.tar.gz
cd dkim-milter-*
mkdir -p /etc/dkim-milter/keys/
cp ./dkim-filter/dkim-genkey.sh /etc/dkim-milter/keys/
cd /etc/dkim-milter/keys/
chmod +x ./dkim-genkey.sh
chown dkim-milter /etc/dkim-milter
chmod 700 /etc/dkim-milter
chgrp postfix /var/run/dkim-milter
chmod 770 /var/run/dkim-milter
./dkim-genkey.sh -r -d hostname -f
chown dkim-milter /etc/dkim-milter/keys/default.private
mv /etc/dkim-milter/keys/default.private /etc/dkim-milter/keys/default.key.pem
#会生成default.txt 和 default.private
#根据default.txt 里面的内容,将DNS的TXT记录添加好
#default.private已安置好,并改名为default.key.pem,可以使用了
#下面的命令,大家根据实际微调
echo "*@kn007.net:kn007.net:/etc/dkim-milter/keys/default.key.pem" >> /etc/mail/dkim-milter/keys/keylist
echo 'AutoRestart yes' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'AutoRestartRate 10/1h' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'Domain kn007.net' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'SubDomains yes' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'Selector default' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'KeyFile /etc/dkim-milter/keys/default.key.pem' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'Background yes' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'Socket inet:8891' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'Userid dkim-milter' >> /etc/mail/dkim-milter/dkim-filter.conf
echo 'smtpd_milters = inet:8891' >> /etc/postfix/main.cf
echo 'non_smtpd_milters = inet:8891' >> /etc/postfix/main.cf
echo 'milter_protocol = 2' >> /etc/postfix/main.cf
echo 'milter_default_action = accept' >> /etc/postfix/main.cf
echo "" > /var/log/maillog
chkconfig --level 345 dkim-milter on
service dkim-milter start
service postfix restart
cat /var/log/maillog


题外话:话说Debian的apt-get源蛮多的,安装什么都挺省事的。。。CentOS的yum有时真让人崩溃。
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!