Step1
、安装apache+mysql+php,配置dns
Step2
、安装cyrus-sasl-2.1.22
删除以前的rpm包以及相关目录
rpm -e --nodeps cyrus-sasl-2.1.10-4 cyrus-sasl-plain-2.1.10-4 cyrus-sasl-md5-2.1.10-4 cyrus-sasl-devel-2.1.10-4
rm -rf /usr/lib/sasl
rm -rf /usr/lib/sasl2
tar -zxvf cyrus-sasl-2.1.22.tar.tar
cd cyrus-sasl-2.1.22
./configure --enable-plain --enable-cram --disable-digest --enable-login --enable-sql --disable-anon --disable-ntlm --disable-gssapi --disable-krb4 --disable-otp --disable-srp --disable-srp-setpass --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket --with-mysql=/usr/local/mysql --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
Make
make install
ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
(重要)
增加"/usr/local/lib"到你的"/etc/ld.so.conf",并执行ldconfig命令。
Setp3.
编译postfix2.x
建立所需要的用户和组
# groupadd -g 1000 postfix
# groupadd postdrop
# useradd -u 1000 -g postfix -G postdrop -c "Postfix user" -d /dev/null -s /sbin/nologin -M postfix
# groupadd -g 1002 vmail
# useradd -g vmail -u 1002 -M -s /sbin/nologin vmail
# mkdir /home/mail
如果你的系统上原来有sendmail,先将其停止并将其文件改名
# /etc/init.d/sendmail stop
# chkconfig --level 2345 sendmail off
# mv /usr/bin/newaliases /usr/bin/newaliases.old
# mv /usr/bin/mailq /usr/bin/mailq.old
# mv /usr/sbin/sendmail /usr/sbin/sendmail.old
# rpm -e sendmail --nodeps
tar -zvxf postfix-2.4.5.tar.gz
cd postfix-2.4.5
make tidy
make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/include/sasl' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/lib -lsasl2'
make
make install
# mv /etc/aliases /etc/aliases.old
# ln -s /etc/postfix/aliases /etc/aliases
# /usr/bin/newaliases
vi /etc/postfix/main.cf
#=====================BASE=========================
myhostname = mail.lin.net
mydomain = lin.net
myorigin = $mydomain
mydestination = $myhostname localhost localhost.$mydomain
mynetworks = 127.0.0.0/8
inet_interfaces = all
home_mailbox = Maildir/
在 /etc/postfix/main.cf中加入:
#=====================Vritual Mailbox settings====================
#
指定用户邮箱所在的根目录
virtual_mailbox_base = /home/mail/
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
# use this for virtual delivery
(如果没有安装maildrop,则此处为virtual)
#virtual_transport = virtual
#use this for maildrop-delivery
(如果有maildrop,则此处为maildrop)
virtual_transport = maildrop
#Maildrop-Options for usage with maildrop
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
#/home/mail/
最后的"/"字符不能省略
#====================QUOTA========================
message_size_limit = 14336000
virtual_mailbox_limit = 102400000
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later
virtual_overquota_bounce = yes
#====================SASL========================
broken_sasl_auth_clients = yes
#In order to allow mail relaying by authenticated clients
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_invalid_hostname,
reject_non_fqdn_hostname,
reject_unknown_sender_domain,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_recipient_domain,
reject_unauth_pipelining,
reject_unauth_destination,
permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner=$myhostname ESMTP "Version not Available
#=============================================
mailbox_command = /usr/bin/maildrop
mail_owner = postfix
mailq_path = /usr/bin/mailq
manpage_directory = /usr/local/man
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
启动和停止postfix服务
/usr/sbin/postfix start
/usr/sbin/postfix stop
Step4
、安装 courier-authlib
# tar jxvf courier-authlib-0.60.2.tar.bz2
# cd courier-authlib-0.60.2
#
./configure --prefix=/usr/local/courier-authlib --without-authuserdb --without-authpam --without-authldap --without-authpwd --without-authshadow --without-authvchkpw --without-authpgsql --without-stdheaderdir
--without-authcustom
--with-authmysql --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql --with-redhat --with-authmysqlrc=/usr/local/courier-authlib/etc/authmysqlrc --with-authdaemonrc=/usr/local/courier-authlib/etc/authdaemonrc
# make
# make install
# make install-migrate
# make install-configure
chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
vi /usr/local/courier-authlib/etc/authdaemonrc
可以不修改
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10
DEBUG_LOGIN=2
vi /usr/local/courier-authlib/etc/authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_SOCKET /tmp/mysql.sock
自定义安装(MYSQL_SOCKET /var/lib/mysql/mysql.sock默认安装)
MYSQL_PORT 3306
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD uidnumber
MYSQL_GID_FIELD gidnumber
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD '/home/mail/' #
设置postfix存储邮件的目录
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD
concat(quota,'s')
注意: MYSQL_GID_FIELD 和MYSQL_UID_FIELD是postfix的UID和GID,而不是MySQL的。
如果想使用md5密码,把MYSQL_CLEAR_PWFIELD password改成MYSQL_CRYPT_PWFIELD password
# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
# chmod 755 /etc/init.d/courier-authlib
# chkconfig --add courier-authlib
# chkconfig --level 2345 courier-authlib on
增加"/usr/local/courier-authlib/lib/courier-authlib"到你的"/etc/ld.so.conf",并执行ldconfig命令。
echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf
ldconfig
# service courier-authlib start (
启动服务)
Step5
、
安装 courier-imap
# tar jxvf courier-imap-4.1.0.tar.bz2
# cd courier-imap-4.1.0
#
./configure --prefix=/usr/local/courier-imap --with-redhat --enable-unicode --disable-root-check --with-trashquota --without-ipv6
--with-authmysql
CPPFLAGS='-I/usr/local/courier-authlib/include' COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig' (CPPFLAGS='-I/usr/local/courier-authlib/include'
make
make install-strip
(先install-strip,如果失败,再make install)
make install-configure
配置Courier-IMAP,为用户提供pop3服务:
vi /usr/local/courier-imap/etc/pop3d
POP3DSTART=yes
如果你想为用户提供IMAP服务,可以在"/usr/local/courier-imap/etc/imapd"文件中设置"IMAPDSTART=yes"。
cp courier-imap.sysvinit /etc/rc.d/init.d/imapd
chmod 755 /etc/rc.d/init.d/imapd
chkconfig --add imapd
/etc/rc.d/init.d/imapd start
chkconfig --level 235 imapd on
Step6
、
配置SMTP 认证
编辑 /usr/lib/sasl2/smtpd.conf 为以下内容
vi /usr/local/lib/sasl2/smtpd.conf
pwcheck_method: authdaemond
log_level: 3
mech_list: plain login
authdaemond_path: /usr/local/courier-authlib/var/spool/authdaemon/socket
Step7
、
安装Extmail-1.0.3
1、
安装
# tar zxvf extmail-1.0.3.tar.gz
# mkdir -pv /usr/local/apache/htdocs/extsuite
# mv extmail-1.0.3 /usr/local/apache/htdocs/extsuite/extmail
# cp /usr/local/apahehtdocs/extsuite/extmail/webmail.cf.default /usr/local/apache/htdocs/extsuite/extmail/webmail.cf
2、
修改主配置文件
#vi /usr/local/apache/htdocs/extsuite/extmail/webmail.cf
部分修改选项的说明:
SYS_CONFIG = /usr/local/apache/htdocs/extsuite/extmail/
SYS_LANGDIR = /usr/local/apache/htdocs/extsuite/extmail/lang
SYS_TEMPLDIR = /usr/local/apache/htdocs/extsuite/extmail/html
SYS_MESSAGE_SIZE_LIMIT = 5242880
用户可以发送的最大邮件
YS_USER_LANG = en_US
语言选项,可改作:
SYS_USER_LANG = zh_CN
SYS_MAILDIR_BASE = /home/domains
此处即为您在前文所设置的用户邮件的存放目录,可改作:
SYS_MAILDIR_BASE = /home/mail
SYS_MYSQL_USER = db_user
SYS_MYSQL_PASS = db_pass
以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库,这里修改为:
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_HOST = localhost
指明数据库服务器主机名,这里默认即可
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
连接数据库的sock文件位置,这里修改为:
SYS_MYSQL_SOCKET = /tmp/mysql.sock
SYS_CRYPT_TYPE = cleartext(
使用明文密码,配合/usr/local/courier-authlib/etc/authlib/authmysqlrc文件设置
)
SYS_MYSQL_TABLE = mailbox
SYS_MYSQL_ATTR_USERNAME = username
SYS_MYSQL_ATTR_DOMAIN = domain
SYS_MYSQL_ATTR_PASSWD = password
以上用来指定验正用户登录里所用到的表,以及用户名、域名和用户密码分别对应的表中列的名称;这里默认即可
SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket
此句用来指明authdaemo socket文件的位置,这里修改为:
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
3
、apache相关配置
# vi /usr/local/apache/conf/httpd.conf
User postfix
Group postfix
<VirtualHost *:80>
ServerName mail.lin.net
DocumentRoot /usr/local/apache/htdocs/extsuite/extmail/html/
ScriptAlias /extmail/cgi /usr/local/apache/htdocs/extsuite/extmail/cgi
Alias /extmail /usr/local/apache/htdocs/extsuite/extmail/html
</VirtualHost>
修改 cgi执行文件属主为apache运行身份用户:
# chown -R postfix.postfix /usr/local/apache/htdocs/extsuite/extmail/cgi/
3、
依赖关系的解决
extmail
将会用到perl的DBD::Mysql和Unix::syslogd功能
# tar zxvf Unix-Syslog-0.100.tar.gz
# cd Unix-Syslog-0.100
# perl Makefile.PL
# make
# make install
安装DBD::Mysql前先要安装DBI包
tar -zxvf DBI-1.604.tar.gz
cd DBI-1.604
perl Makefile.PL
make
make install
# tar zxvf DBD-mysql-3.0002_4.tar.gz
# cd DBD-mysql-3.0002_4
# perl Makefile.PL (
此步骤中如果出现类同Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.的错误是因为您的mysql的bin目录没有输出至$PATH环境变量 export PATH=$PATH:/usr/local/mysql/bin)
# make
# make install
好了,到此为止,您的Webmail已经可以使用了
Step8
、
安装Extman-0.2.4
# tar zxvf extman-0.2.4.tar.gz
# mv extman-0.2.4 /usr/local/apache/htdocs/extsuite/extman
# cd /usr/local/apache/htdocs/extsuite/extman/docs
# cp mysql_virtual_*.cf /etc/postfix/
# chmod 640 /etc/postfix/mysql_*
# chgrp vmail /etc/postfix/mysql_*
(执行下面的命令导入 ExtMail 和 ExtMan 的数据库结构及初始化数据)
# /usr/local/mysql/bin/mysql -u root -p < extmail.sql
# /usr/local/mysql/bin/mysql -u root -p < init.sql
(执行下面的命令链接基本库到 ExtMail 中)
# cd /usr/local/apache/htdocs/extsuite/extman/libs/Ext
# ./buildpkg.sh build /usr/local/apache/htdocs/extsuite/extmail/libs/Ext
# mkdir /usr/local/apache/htdocs/extsuite/extman/tmp
# chown -R postfix.postfix /usr/local/apache/htdocs/extsuite/extman/tmp
# cd /usr/local/apache/htdocs/extsuite/extman/tools
# ./maildirmake.pl /home/domains/extmail.org/test/Maildir
# chown -R postfix.postfix /home/mail
修改配置文件以符合本例的需要:
# vi /var/www/extsuite/extman/webman.cf
SYS_CONFIG = /usr/local/apache/htdocs/extsuite/extman/
SYS_LANGDIR = /usr/local/apache/htdocs/extsuite/extman/lang
SYS_TEMPLDIR = /usr/local/apache/htdocs/extsuite/extman/html
SYS_MAILDIR_BASE = /home/domains
此处即为您在前文所设置的用户邮件的存放目录,可改作:
SYS_MAILDIR_BASE = /home/mail
SYS_CAPTCHA_ON = 0
控制在首页是否使用校验码(1为使用,0为不使用)
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
此处修改为:
SYS_MYSQL_SOCKET = /tmp/mysql.sock
SYS_CRYPT_TYPE = cleartext
(
使用明文密码,配合/usr/local/courier-authlib/etc/authlib/authmysqlrc文件设置)
# chown -R postfix.postfix /home/mail
修改cgi目录的属主:
# chown -R postfix.postfix /usr/local/apache/htdocs/extsuite/extman/cgi/
如果extman访问数据库权限不足的话,可采用以下命令将新生成的数据库赋予webman用户具有所有权限:
mysql> GRANT all privileges on extmail.* TO webman@localhost IDENTIFIED BY 'webman';
在apache的主配置文件中Extmail的虚拟主机部分,添加如下两行:
ScriptAlias /extman/cgi /usr/local/apache/htdocs/extsuite/extman/cgi
Alias /extman /usr/local/apache/htdocs/extsuite/extman/html
创建其运行时所需的临时目录,并修改其相应的权限:
#mkdir -pv /tmp/extman
#chown postfix.postfix /tmp/extman
(1)
如果您安装后无法正常显示校验码,安装perl-GD模块会解决这个问题。如果想简单,您可以到以下地址下载适合您的平台的rpm包
# rpm -vih perl-GD-2.35-1.el4.rf.i386.rpm
(2) extman-0.2.2
自带了图形化显示日志的功能;此功能需要rrdtool的支持,您需要安装此些模块才可能正常显示图形日志。
安装Time::HiRes
#tar zxvf Time-HiRes-1.9707.tar.gz
#cd Time-HiRes-1.9707
#perl Makefile.PL
#make
#make test
#make install
安装File::Tail
#tar zxvf File-Tail-0.99.3.tar.gz
#cd File-Tail-0.99.3
#perl Makefile
#make
#make test
#make install
安装与rrdtool相关的包
# rpm -ivh libart_lgpl-devel-2.3.16-3.i386.rpm
# ls -l /usr/lib/pkgconfig/libart-2.0.pc
(确定是否有此文件,有才说明 libart 正确安装)
安装rrdtool-1.2.26
#tar zxvf rrdtool-1.2.26.tar.gz
#cd rrdtool-1.2.26
#./configure --prefix=/usr/local/rrdtool
#make
#make install
创建必要的符号链接(Extman会到这些路径下找相关的库文件)
#ln -sv /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/auto/RRDs/RRDs.so /usr/lib/perl5/5.8.8/i386-linux-thread-multi/
#ln -sv /usr/local/rrdtool/lib/perl/5.8.8/RRDp.pm /usr/lib/perl5/5.8.8
#ln -sv /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/RRDs.pm /usr/lib/perl5/5.8.8
复制mailgraph_ext到/usr/local,并启动之
# cp -r /usr/local/apache/htdocs/extsuite/extman/addon/mailgraph_ext /usr/local
# / usr/local/mailgraph_ext/mailgraph-init start
# /usr/local/mailgraph_ext/qmonitor-init start
添加到自动启动队列
echo "/usr/local/mailgraph_ext/mailgraph-init start" >> /etc/rc.local
echo "/usr/local/mailgraph_ext/qmonitor-init start" >> /etc/rc.local
Step9
、
安装maildrop-2.0.4
1
、安装
将courier-authlib的头文件及库文件链接至/usr目录(编译maildrop时会到此目录下找此些相关的文件):
# ln -sv /usr/local/courier-authlib/bin/courierauthconfig /usr/bin
# ln -sv /usr/local/courier-authlib/include/* /usr/include/
maildrop
需要pcre的支持,因此,接下来将首先安装pcre
# tar jxvf pcre-7.6.tar.bz2
# cd pcre-7.6
# ./configure
# make
# make check
# make install
tar -jxvf maildrop-2.0.4.tar.bz2
cd maildrop-2.0.4
# ./configure --enable-sendmail=/usr/sbin/sendmail --enable-trusted-users='root vmail' --enable-syslog=1 --enable-maildirquota --enable-maildrop-uid=1002 --enable-maildrop-gid=1002 --with-trashquota --with-dirsync
# make
# make install
检查安装结果,请确保有"Courier Authentication Library extension enabled."一句出现:
# maildrop �Cv
maildrop 2.0.4 Copyright 1998-2005 Double Precision, Inc.
GDBM extensions enabled.
Courier Authentication Library extension enabled.
Maildir quota extension enabled.
This program is distributed under the terms of the GNU General Public
License. See COPYING for additional information.
2
、新建其配置文件/etc/maildroprc文件,首先指定maildrop的日志记录位置:
# vi /etc/maildroprc
添加:
(文件内容如下,中间的空格用 TAB 键)
logfile "/var/log/maildrop.log"
# touch /var/log/maildrop.log
# chown vmail.vmail /var/log/maildrop.log
3
、配置Postfix
编辑master.cf
# vi /etc/postfix/master.cf
启用如下两行
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
注意:定义transport的时候,即如上两行中的第二行,其参数行
必须以空两格开头
,否则会出错。
编辑main.cf
# vi /etc/postfix/main.cf
virtual_transport = virtual
修改为:
virtual_transport = maildrop
将下面两项指定的UID和GID作相应的修改:
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
修改为:
virtual_uid_maps = static:1002
virtual_gid_maps = static:1002
4、
编辑authmysqlrc
# vi /usr/local/courier-authlib/etc/authmysqlrc
MYSQL_UID_FIELD '1000'
MYSQL_GID_FIELD '1000'
更改为:
MYSQL_UID_FIELD '1002'
MYSQL_GID_FIELD '1002'
注意:
没有此处的修改,maildrop可能会报告 “signal 0x06”的错误报告。
5
、编辑/usr/local/apache/conf/httpd.conf,修改运行用户:
将前文中的如下项
User postfix
Group postfix
修改为:
User vmail
Group vmail
5、
将用户邮件所在的目录/home/mail和extman的临时目录/tmp/extman的属主和属组指定为vmail
#chown -R vmail.vmail /home/mail
#chown -R vmail.vmail /tmp/extman
#
chown -R vmail.vmail /usr/local/apache/htdocs/extsuite/extman/cgi/
#
chown -R vmail.vmail /usr/local/apache/htdocs/extsuite/extmail/cgi/
Step10
、安装 clamav
# groupadd clamav
# useradd -g clamav -M clamav
# tar -zxvf clamav-0.93.3.tar.gz
# cd clamav-0.93.3
# ./configure
# make
# make install
#
设定clamd.conf
# vi /usr/local/etc/clamd.conf
#Example
注释掉Example行
编辑/usr/local/etc/freshclam.conf
# vi /usr/local/etc/freshclam.conf
#Example
注释掉Example行
#
执行 Clamavs病毒库升级
# /usr/local/bin/freshclam
运行时报错:
./freshclam: error while loading shared libraries: libclamav.so.4: cannot open shared object file: No such file or directory
可以运行ldconfig解决问题。
配置crontab,让Clam AntiVirus每小时检测一次新的病毒库:
# crontab �Ce
添加:
37 * * * * /usr/local/bin/freshclam
配置clamav开机自动启动
# cp contrib/init/RedHat/clamd /etc/rc.d/init.d/clamd
# cp contrib/init/RedHat/clamav-milter /etc/rc.d/init.d/clamav-milter
# chkconfig --add clamd
# chkconfig --add clamav-milter
# chkconfig --level 2345 clamd on
# chkconfig --level 2345 clamav-milter on
Step11
、
编辑和安装spamassassin
自动安装
[root@linuxas3 src]# perl -MCPAN -e shell
o conf prerequisites_policy ask
cpan> install Mail::SpamAssassin
提示安装以下包:
REQUIRED module missing: Digest::SHA1
REQUIRED module missing: Net::DNS
optional module missing: Mail::SPF
optional module missing: Mail::SPF::Query
optional module missing: IP::Country
optional module missing: Razor2
optional module missing: Net::Ident
optional module missing: IO::Socket::INET6
optional module missing: IO::Socket::SSL
optional module missing: Mail::DomainKeys
optional module missing: Mail::DKIM
optional module missing: Archive::Tar
optional module missing: IO::Zlib
optional module missing: Encode::Detect
如果安装不上可以用force install 强制进行安装
编辑主配置文件/etc/mail/spamassassin/local.cf
required_score 5.0
rewrite_header Subject *****SPAM*****
# Encapsulate spam in an attachment.
#
要如何处理垃圾邮件。因为邮件还会经过防毒程序的处理,所以必须设定为 0。
# 0:将信息写入邮件表头。
# 1:将垃圾邮件转为附件。
# 2:将垃圾邮件转为纯文字附件。
report_safe 0
# Enable the Bayes system.
使用贝氏学习系统
use_bayes 1
# Enable Bayes auto-learning.
开起贝氏自动学习功能
bayes_auto_learn 1
skip_rbl_checks 1
use_razor2 0
use_pyzor 0
ok_locales all
#
黑白名单
whitelist_from *@domain.com
# ---------------------------------------------------------------------------
#SCORE
score RCVD_IN_CBL 4.0
score RCVD_IN_CDL 3.0
# Disabled scores.
score HEADER_8BITS 0
score HTML_COMMENT_8BITS 0
score SUBJ_FULL_OF_8BITS 0
score UPPERCASE_25_50 0
score UPPERCASE_50_75 0
score UPPERCASE_75_100 0
启动:
#/usr/bin/spamd -d
#echo "/usr/bin/spamd -d" >> /etc/rc.local
#
定期自动更新中文反垃圾邮件规则
crontab
�Ce
#
加入
0 0 1 * * wget -N -P /usr/share/spamassassin [url]www.ccert.edu.cn/spam/sa/Chinese_rules.cf;[/url]
Step12
、
安装MailScanner
下载rpm.tar.gz 版本
# tar -zxvf MailScanner-4.65.3-1.rpm.tar.gz
# cd MailScanner-4.65.3-1
# ./install.sh
建立Mailscanner支持spamassassin所需的目录:
# mkdir /var/spool/MailScanner/spamassassin
# chmod 700 /var/spool/MailScanner/spamassassin
# chown vmail.vmail /var/spool/MailScanner/spamassassin
MailScanner
设定
1
修改MailScanner.conf
# vi /etc/MailScanner/MailScanner.conf
%org-name% = lin.net
%org-long-name% = llk726
%web-site% = mail.lin.net
%report-dir% = /etc/MailScanner/reports/en
Run As User = vmail
Run As Group = vmail
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Virus Scanners = clamav
Always Include SpamAssassin Report = yes
Use SpamAssassin = yes
Required SpamAssassin Score = 4
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
SpamAssassin Install Prefix = /usr/bin
SpamAssassin Local Rules Dir = /etc/MailScanner
Incoming Work User = vmail
Incoming Work Group = vmail
Quarantine User = vmail
Quarantine Group = vmail
2
、修改 postfix支持mailscanner
# vi /etc/postfix/main.cf
变更以下的值
header_checks = regexp:/etc/postfix/header_checks
# vi /etc/postfix/header_checks
/^Received:/ HOLD
注意, 在 / 之前不可以有空白!
3
、变更目录权限
#chown -R vmail.vmail /var/spool/MailScanner/*
停止postfix执行、启动MailScanner
# /usr/sbin/postfix stop
# service MailScanner start
设定MailScanner,当MTA = postfix时,会自己启动postfix,如有设定启动postfix的请先将它停掉
Step13
、
测试clamav
[root@mail MailScanner-4.65.3-1]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.tao.com ESMTP "Version not Available
ehlo tao.com
250-mail.tao.com
250-PIPELINING
250-SIZE 14336000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
250 2.1.0 Ok
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject:Virus test
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
.
250 2.0.0 Ok: queued as D7F3FFA50
quit
221 2.0.0 Bye
Connection closed by foreign host.
测试SpamAssassin
发一封邮件带如下内容,接收后,标题应该带有标记:
Subject:spamassassin test
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
问题解决办法:
tail -n 20 /var/log/messages
Jul 10 08:37:01 mx02 postfix/smtpd[6217]: sql_select option missing
Jul 10 08:37:01 mx02 postfix/smtpd[6217]: auxpropfunc error no mechanism available
# cat /usr/lib/sasl2/smtpd.conf
pwcheck_method:authdaemond
log_level:3
mech_list: PLAIN LOGIN
authdaemond_path
:/usr/local/courier-authlib/var/spool/authdaemon/socket
allow_plaintext: true
auxprop_plugin: mysql
sql_hostnames: localhost
sql_user: extmail
sql_passwd: extmail
sql_database: extmail
sql_select: select password from mailbox where username='%u'
将原有的smtpd.conf配置文件添加以上内容(蓝色字体)后,此日志显示消失。