12月 7th, 2011对debian 下的exim4添加DKIM支持
exim是一款常见的邮件发送软件, 用自带的apt-get安装的exim4版本是不支持DKIM,我们必须要对其源码进行改造才行。
这里介绍一下在debian环境下对exim进行DKIM(DomainKeys Identified Mail)邮件签名的支持。
# apt-get install libdkim-dev dpatch
在/etc/apt/sources.list中添加:
deb-src http://ftp.us.debian.org/debian lenny main contrib non-free
添加必要的软件:
# cd /usr/src
# apt-get --force-yes -y install build-essential devscripts docbook-xsl xsltproc docbook-xml libpcre3-dev libldap2-dev libpam0g-dev libident-dev libdb4.6-dev libxmu-dev libxt-dev libxext-dev libx11-dev libxaw7-dev libpq-dev libmysqlclient15-dev libsqlite3-dev libperl-dev libgnutls-dev libsasl2-dev
# apt-get source exim4
# cd exim4-4.69/
# fakeroot debian/rules unpack-configs
# apt-get --force-yes -y install build-essential devscripts docbook-xsl xsltproc docbook-xml libpcre3-dev libldap2-dev libpam0g-dev libident-dev libdb4.6-dev libxmu-dev libxt-dev libxext-dev libx11-dev libxaw7-dev libpq-dev libmysqlclient15-dev libsqlite3-dev libperl-dev libgnutls-dev libsasl2-dev
# apt-get source exim4
# cd exim4-4.69/
# fakeroot debian/rules unpack-configs
然后复制配置文件
# cp EDITME.exim4-heavy EDITME.exim4-custom
# echo "EXPERIMENTAL_DKIM=yes" >> EDITME.exim4-custom
# echo "LDFLAGS += -ldkim" >> EDITME.exim4-custom
# fakeroot debian/rules pack-configs
# echo "EXPERIMENTAL_DKIM=yes" >> EDITME.exim4-custom
# echo "LDFLAGS += -ldkim" >> EDITME.exim4-custom
# fakeroot debian/rules pack-configs
修改
vi debian/rules
找到extradaemonpackages这行,修改为:
extradaemonpackages=exim4-daemon-heavy exim4-daemon-custom
为了让exim找到libdkim,还需要
echo "80_libdkim_patch" >> debian/patches/00list
cd debian/patches
wget 'http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=99_libdkim_1.0.19.dpatch;att=1;bug=486437' -O - | \
cat >> 80_libdkim_patch.dpatch
cd debian/patches
wget 'http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=99_libdkim_1.0.19.dpatch;att=1;bug=486437' -O - | \
cat >> 80_libdkim_patch.dpatch
完成以上步骤,并无提示出错i后就可以编译了
debuild -uc -us
之后就可以得到安装包了:
# ls ../*.deb | grep exim4
../exim4_4.69-7_all.deb
../exim4-base_4.69-7_amd64.deb
../exim4-config_4.69-7_all.deb
../exim4-daemon-custom_4.69-7_amd64.deb
../exim4-daemon-custom-dbg_4.69-7_amd64.deb
../exim4-daemon-heavy_4.69-7_amd64.deb
../exim4-daemon-heavy-dbg_4.69-7_amd64.deb
../exim4-daemon-light_4.69-7_amd64.deb
../exim4-daemon-light-dbg_4.69-7_amd64.deb
../exim4-dbg_4.69-7_amd64.deb
../exim4-dev_4.69-7_amd64.deb
../eximon4_4.69-7_amd64.deb
../exim4_4.69-7_all.deb
../exim4-base_4.69-7_amd64.deb
../exim4-config_4.69-7_all.deb
../exim4-daemon-custom_4.69-7_amd64.deb
../exim4-daemon-custom-dbg_4.69-7_amd64.deb
../exim4-daemon-heavy_4.69-7_amd64.deb
../exim4-daemon-heavy-dbg_4.69-7_amd64.deb
../exim4-daemon-light_4.69-7_amd64.deb
../exim4-daemon-light-dbg_4.69-7_amd64.deb
../exim4-dbg_4.69-7_amd64.deb
../exim4-dev_4.69-7_amd64.deb
../eximon4_4.69-7_amd64.deb
安装包的顺序
dpkg -i exim4-config*.deb
dpkg -i exim4-base*.deb
dpkg -i exim4-daemon-light*.deb
dpkg -i daemon-custom*.deb
最后,修改配置文件/etc/exim4/exim4.conf.template在remote_smtp 处
添加:
dkim_selector = dkim
dkim_domain = ${lc:${domain:$h_from:}}
dkim_private_key = /root/dkim.private.key
dkim_strict = 0
dkim_canon = relaxed
dkim_domain = ${lc:${domain:$h_from:}}
dkim_private_key = /root/dkim.private.key
dkim_strict = 0
dkim_canon = relaxed