第一步:准备以及部分说明
1、系统:RedHat Enterprise Linux 5.4 2、IP地址:192.168.1.4 3、域名:mail.kk.com 以下是DNS解析:- 正向记录检查
- [root@mail ~]# nslookup mail.kk.com
- Server: 192.168.1.4
- Address: 192.168.1.4#53
- Name: mail.kk.com
- Address: 192.168.1.4
- 反向记录检查
- [root@mail ~]# nslookup 192.168.1.4
- Server: 192.168.1.4
- Address: 192.168.1.4#53
- 4.1.168.192.in-addr.arpa name = mail.kk.com.
hostname:
- [root@mail ~]# hostname
- mail.kk.com
部分说明:
1、文中会用的yum安装软件,由于和本文没有多大联系,所以不会在本文出现详细配置。
2、本文中只有maildrop和extmail部分属于源代码安装,所以以下主要软件我在一切开始之前就安装了。
- yum install -y http* perl* gcc* mysql* dovecot* php*
- service httpd start
- chkconfig httpd on
- service mysqld start
- chkdocnfig mysqld on
- service dovecot start
- chkconfig dovecot on
3、我的源代码包存放路径
- /usr/local/src
4、文中的环境都是我自己的系统环境,请各位在安装过程中根据自己的环境安装。
第二步:安装和配置postfix
由于RHEL5.4自带的postfix的rpm包不支持mysql,所以需要自己编译,我这里的编译方法是使用src.rpm来编译postfix带支持mysql的rpm包。
1、下载postfix-2.8.4-1.src.rpm--这个包目前来看应该是最新的。
2、安装rpm -ivh postfix-2.8.4-1.src.rpm过程中可能会出现类似与没有目录的提示,建立好过后就行了。
3、编辑/usr/src/redhat/SPECS/postfix.spec,我修改过的内容如下(其他的各位根据自己的实际情况更改):
- %define mysql_paths /usr/include/mysql/:/usr/lib/mysql
- %define with_mysql_redhat 1
- %define with_sasl 2
- %define with_dovecot 1
4、安装rpm-build包,用于创建postfix的rpm包,使用如下命令:
- yum install -y rpm*
5、创建postfix的rpm包(在这个过程中可能也会出现没有某些目录,你根据提示创建目录就行了)。
- rpmbuild –ba /usr/src/redhat/SPECS/postfix.spec
6、安装postfix,命令如下:
- [root@mail ~]#rpm -ivh /usr/src/redhat/RPMS/i386/postfix-2.8.4-1.rhel5.i386.rpm
7、检查安装结果(可以看见有支持mysql):
- [root@mail ~]# postconf -m
- btree
- cidr
- environ
- hash
- internal
- ldap
- mysql
- nis
- proxy
- regexp
- static
- tcp
- texthash
- unix
8、配置postfix(修改配置文件之前最好备份):
- cp /etc/postfix/main.cf /etc/postfix/main.cf.back
编辑主配置文件:
以下是主要配置:
- 1 myhostname = mail.kk.com
- #####这个参数大家更改成自己的主机名即可;
- 2 mydomain = kk.com
- ####这个参数就是我们的域名;
- 3 myorigin = $myhostname
- #####这个是设置邮件表头上面的mail from地址的,大家用默认即可,即取消前面的那个;
- 4 inet_interfaces = all
- ####这个就是设置我们的邮件服务器监听所有的端口;
- 5 #mydestination = ####$myhostname, localhost.$mydomain, localhost, $mydomain,
- #####mail.$mydomain, www.$mydomain, ftp.$mydomain
- ###这个可以不用写,由于要配置虚拟域,如果这里配置了的话会导致mail积压在队列里面不能发送;
- 6 mynetworks = 192.168.1.0/24, 127.0.0.0/8,hash:/etc/postfix/access
- ####这个设置是决定你要向哪些网段和主机开放使用本邮件服务;
- 7 #relay_domains = $mydestination
- ###### 这个参数就是说如果我们有多台邮件服务器,我们的这台服务器需要将邮件转发到其他服务时,就像Yahoo的邮箱要转发到QQ邮箱上,那么在yahoo的邮箱中就要设置这个转发咯。这里我不需要转发,就不用配置了。大家根据自己需要自行更改;
以下是虚拟邮箱以及maildrop的设置(我加在配置文件最末尾的):
- virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
- ####设置虚拟邮箱的别名的,后面的mysql:表示是通过mysql数据库来提供验证的,也就是说我们的别名数据是放在mysql数据库中的
- virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
- ####虚拟邮箱可以接受哪些域
- virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
- ####虚拟邮箱的邮箱登陆账户
以上文件都存在于extman的压缩包里,然后我们就复制过来并且进行编辑:
- [root@mail ~]# tar -zxv -f /usr/local/src/extman-1.1.tar.gz
- [root@mail ~]#cp /usr/local/src/extman-1.1/docs/mysql_virtual_alias_maps.cf /etc/postfix/
- [root@mail ~]#cp /usr/local/src/extman-1.1/docs/mysql_virtual_domains_maps.cf /etc/postfix/
- [root@mail ~]#cp /usr/local/src/extman-1.1/docs/mysql_virtual_mailbox_maps.cf /etc/postfix/
9、编辑虚拟邮箱配置文件(也就是在extman下面复制过去的几个文件)
第一个文件的内容如下:
- [root@mail ~]# vim /etc/postfix/mysql_virtual_alias_maps.cf
- user = extmail
- password = extmail
- hosts = localhost
- dbname = extmail
- table = alias
- select_field = goto
- where_field = address
- #additional_conditions = AND active = '1'
第二个文件的内容如下:
- [root@mail ~]# vim /etc/postfix/mysql_virtual_mailbox_maps.cf
- user = extmail
- password = extmail
- hosts = localhost
- dbname = extmail
- table = mailbox
- select_field = maildir
- where_field = username
- #additional_conditions = AND active = '1'
第三个文件的内容如下:
- [root@mail ~]# vim /etc/postfix/mysql_virtual_domains_maps.cf
- user = extmail
- password = extmail
- hosts = localhost
- dbname = extmail
- table = domain
- #select_field = domain
- select_field = description
- where_field = domain
- #additional_conditions = AND active = '1'
三:安装maildrop
1、创建maildrop的用户
- groupadd vmail -g 1001
- useradd vmail -u 1001 -g 1001
2、安装courier-authlib(源代码安装)
首先是一些有依赖的包:
- yum install -y libtool-libs*
- yum install -y openssl097a*
然后开始安装courier-authlib
- [root@mail ~]# tar -jxv -f /usr/local/src/courier-authlib-0.63.0.tar.bz2
- [root@mail ~]# cd /usr/local/src/courier-authlib-0.63.0
- [root@mail courier-authlib-0.63.0]# ./configure --with-redhat --with-authmysql=yes --with-mailuser=vmail --with-mailgroup=vmail --with-mysql-libs=/usr/lib/mysql --with-mysql-includes=/usr/include/mysql --prefix=/usr/local/authlib --without-stdheaderdir
- ####这里说明一下--with-mysql-libs和--with-mysql-includes这两个路径大家根据自己的实际环境来更改
- [root@mail courier-authlib-0.63.0]# make;make install
- [root@mail courier-authlib-0.63.0]# cd /usr/local/authlib/etc/authlib/
- [root@mail authlib]# mv authdaemonrc.dist authdaemonrc
- [root@mail authlib]# mv authmysqlrc.dist authmysqlrc
- [root@mail authlib]#vim authdaemonrc
- ###确保内容如下,你也可以根据自己需求情况更改
- authmodulelist="authmysql"
- authmodulelistorig="authmysql"
- daemons=10
- [root@mail authlib]#vim authmysqlrc
- ###确保内容如下,你也可以根据自己需求情况更改
- MYSQL_SERVER localhost
- MYSQL_USERNAME extmail
- MYSQL_PASSWORD extmail
- MYSQL_SOCKET /var/lib/mysql/mysql.sock
- MYSQL_PORT 3306
- MYSQL_OPT 0
- MYSQL_DATABASE extmail
- MYSQL_USER_TABLE mailbox
- MYSQL_CRYPT_PWFIELD password
- MYSQL_UID_FIELD 1001
- MYSQL_GID_FIELD 1001
- ###上面的UID和GID选项好像也可以为uidnumber,gidnumber
- MYSQL_LOGIN_FIELD username
- MYSQL_HOME_FIELD homedir
- MYSQL_NAME_FIELD name
- MYSQL_MAILDIR_FIELD maildir
- MYSQL_QUOTA_FIELD quota
- MYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber,\
- CONCAT('/home/domains/',homedir), \
- CONCAT('/home/domains/',maildir), \
- quota, \
- name \
- FROM mailbox \
- WHERE username = '$(local_part)@$(domain)'
- ####设置authlib的共享库
- [root@mail authlib]#echo "/usr/local/authlib/lib/courier-authlib" >> /etc/ld.so.conf
- [root@mail authlib]#ldconfig
- #####拷贝安装包内的courier-authlib.sysvinit到/etc/init.d下:
- [root@mail authlib]#cp courier-authlib.sysvinit /etc/init.d/courier-authlib
- [root@mail authlib]#chmod 755 /etc/init.d/courier-authlib
- [root@mail authlib]#chkconfig --add courier-authlib
- [root@mail authlib]#chkconfig --level 2345 courier-authlib on
- [root@mail authlib]#service courier-authlib start
- [root@mail authlib]#ln -s /usr/local/authlib/var/spool/authdaemon /var/spool/authdaemon
- [root@mail authlib]#chmod 755 /var/spool/authdaemon
- [root@mail authlib]#chmod +x /usr/local/authlib/var/spool/authdaemon
- ####下面两个连接文件在安装maildrop时,会去相应目录检查这些文件,这样编译出来的maildrop才会ourier Authentication Library extension enabled.。
- [root@mail authlib]#ln -sv /usr/local/authlib/bin/courierauthconfig /usr/bin
- [root@mail authlib]#ln -sv /usr/local/authlib/include/* /usr/include
安装maildrop
- [root@mail ~]# tar -jxv -f /usr/local/src/maildrop-2.5.4.tar.bz2
- [root@mail ~]# ./configure --enable-sendmail=/usr/sbin/sendmail --enable-trusted-users='root vmail' --enable-syslog=1 --enable-maildirquota --enable-maildrop-uid=1001 --enable-maildrop-uid=1001 --with-trashquota --with-dirsync
- [root@mail ~]# make;make install
- ###测试,如果出现Courier Authentication Library extension enabled.安装maidrop就差不多完成了。
- [root@mail ~]# maildrop -v
- maildrop 2.5.4 Copyright 1998-2005 Double Precision, Inc.
- Courier Authentication Library extension enabled.
- Maildir quota extension are now always enabled.
- This program is distributed under the terms of the GNU General Public
- License. See COPYING for additional information.
编辑/etc/postfix/master.cf和/etc/postfix/main.cf使postfix支持maildrop
- maildrop unix - n n - - pipe
- flags=DRhu user=vmail argv=/usr/local/bin/maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user} ${extension} {nexthop}
- ####第二行前面必须要有两个空格,不然会出错,以上是master.cf
- ####以下是main.cf
- virtual_transport = maildrop:
- maildrop_destination_recipient_limit = 1
maildrop日志
- [root@mail ~]#vim /etc/maildroprc ####输入如下内容:
- logfile "/var/log/maildrop.log"
- [root@mail ~]#touch /var/log/maildrop.log
- [root@mail ~]#chown -R vmal.vmail /var/log/maildrop.log
如果在发送邮件过后的/var/log/maillog里面看见如下内容,maildrop就差不多成功了。
- Nov 11 20:57:50 mail postfix/pipe[5711]: 256142311D1: to=<lj@kk.com>, relay=maildrop, delay=7931234, delays=7931233/0.34/0/0.36, dsn=2.0.0, status=sent (delivered via maildrop service)
安装过程中的一个小问题:
编译安装的时候出现以下报错configure: error: pcre.h not found - install PCRE from
,请安装pcre-devel包
第四步:配置APACHE
- [root@mail ~]# vim /etc/httpd/conf/httpd.conf
- ServerName mail.kk.com:80
- Include conf.d/*.conf
- #AddDefaultCharset UTF-8
- ########然后建立虚拟主机
- [root@mail ~]#touch /etc/httpd/conf.d/vhost_extmail.conf [root@mail ~]#vim /etc/httpd/conf.d/vhost_extmail.conf
- # VirtualHost for ExtMail Solution
- <VirtualHost *:80>
- ServerName mail.extmail.org
- DocumentRoot /var/www/extsuite/extmail/html/
- ScriptAlias /extmail/cgi/ /var/www/extsuite/extmail/cgi/
- Alias /extmail/ /var/www/extsuite/extmail/html/
- ScriptAlias /extman/cgi/ /var/www/extsuite/extman/cgi/
- Alias /extman/ /var/www/extsuite/extman/html/
- # Suexec config
- SuexecUserGroup vmail vmail
- </VirtualHost>
- #####注意这个时候还不能启动apache,启动也会报错,应该设置虚拟主机时候指定的路径里面的那些文件
- #####还没有复制过去
第五步:安装extmail和extman
1、安装extmail和extman需要的perl套件
- yum install -y perl-Unix-Syslog perl-GD
2、解压extmail和extman到apache的路径下面去:
- [root@mail ~]# tar -zxv -f /usr/local/src/extmail-1.2.tar.gz -C /var/www/extsuite/
- [root@mail ~]# tar -zxv -f /usr/local/src/extman-1.1.tar.gz -C /var/www/extsuite/
- [root@mail ~]#cd /var/www/extsuite
- [root@mail extsuite]#mv extmail-1.2 extmail
- [root@mail extsuite]#mv extman-1.1 extman
3、编辑extmail和extman的配置文件
- ###先是extmail
- [root@mail extsuite]# cd extmail/
- [root@mail extmail]# cp webmail.cf.default webmail.cf
- [root@mail extmail]# vim webmail.cf
- ####修改内容如下
- SYS_USER_LANG = zh_CN SYS_USER_CHARSET = gb2312
- SYS_MYSQL_USER = extmail SYS_MYSQL_PASS = extmail SYS_MYSQL_DB = extmail SYS_MYSQL_HOST = localhost SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock ######这里大家根据自己的数据库名称和密码来修改,我直接就用extmail提供的 了。 ######还有最后一行 SYS_G_ABOOK_FILE_CHARSET = gb2312
- 由于SuEXEC的需要,必须将extmail的cgi目录修改成vmail:vmail权限 [root@mail extmail]#chown -R vmail:vmail /var/www/extsuite/extmail/cgi/
- ####再是extman
- [root@mail extmail]# cd ../extman/
- [root@mail extman]# cp webman.cf.default webman.cf
- [root@mail extman]# vim webman.cf
- #### 和配置webextmail差不多 SYS-LANG = zh_CN ####以下和数据库有关的,大家根据自己的情况修改,我这里默认 SYS_MYSQL_USER = webman SYS_MYSQL_PASS = webman SYS_MYSQL_DB = extmail SYS_MYSQL_HOST = localhost SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock[root@mail extman]# chown -R vmail:vmail /var/www/extsuite/extman/cgi/
4、导入extman里面的数据库模板到mysql
- ####先启动mysql
- [root@mail ~]# /etc/rc.d/init.d/mysqld start
- [root@mail ~]#mysql -u root -p < /var/www/extsuite/extman/docs/extmail.sql ###要求密码,直接回车即可
- [root@mail ~]#vim /var/www/extsuite/extman/docs/init.sql
- #####把里面的extmail.org都换成你的域名,我的是
- ####kk.com
- [root@mail ~]#mysql -u root -p < /var/www/extsuite/extman/docs/init.sql
5、数据库建立好了,下面链接基本库到extmail
- [root@mail ~]#mkdir /tmp/extman/
- [root@mail ~]#chown –R vmail:vmail /tmp/extman/
- ####建立刚才导入mysql的postmaster@yourdomain.org帐户的Maildir,运行脚本。
- [root@mail tools]# cd /var/www/extsuite/extman/tools/
- [root@mail tools]# ./maildirmake.pl /home/domains/yourdomain.com/postmaster/Maildir
- [root@mail tools]# chown -R vmail:vmail /home/domains/yourdomain.com
6、测试(如下则为成功)
- [root@mail tools]# authtest -s login postmaster@kk.com
- #####authtest命令如果不行,你用find查找一下,使用绝对路径,例如我的:/usr/sbin/authtest -s login
- #####postmaster@kk.com
- Authentication succeeded.
- Authenticated: postmaster@kk.com (uid 1001, gid 1001)
- Home Directory: /home/domains/kk.com/postmaster
- Maildir: /home/domains/kk.com/postmaster/Maildir/
- Quota: 104857600S
- Encrypted Password: rWWzNCTz2E5ig
- Cleartext Password: (none)
- Options: (none)
第六步:配置dovecot
1、养成良好的习惯,备份配置文件
- [root@mail ~]# cp /etc/dovecot.conf /etc/dovecot.conf.bak
2、编辑配置文件
- [root@mail ~]# vim /etc/dovecot.conf
- base_dir=/var/run/dovecot
- protocols = imap pop3
- listen = *
- disable_plaintext_auth = no
- ssl_disable = yes
- mail_location = maildir:/var/spool/mail/%d/%n
- auth default {
- mechanisms = PLAIN LOGIN CRAM-MD5 DIGEST-MD5
- passdb sql {
- args = /etc/dovecot-mysql.conf
- }
- userdb sql {
- args = /etc/dovecot-mysql.conf
- }
- socket listen {
- client {
- path = /var/run/dovecot/auth-client
- mode = 0660
- user = postfix
- group = postfix
- }
- }
- }
- ####/etc/dovecot-mysql.conf是dovecot和mysql关联的文件,很重要,这个文件在安装的时候已经安装到
- ####系统里面了,路径如下。
- [root@mail examples]# ls /usr/share/doc/dovecot-1.0.7/examples/dovecot-sql-example.conf
3、编辑/etc/dovecot-mysql.conf
- [root@mail ~]# cp /usr/share/doc/dovecot-1.0.7/examples/dovecot-sql-example.conf /etc/dovecot-mysql.conf
- [root@mail ~]# vim /etc/dovecot-mysql.conf
- ####主要编辑如下内容
- driver = mysql
- connect = host=/var/lib/mysql/mysql.sock dbname=extmail user=extmail password=extmail
- default_pass_scheme = MD5
- user_query = SELECT password FROM mailbox WHERE username = '%u'
- password_query = SELECT password FROM mailbox WHERE username = '%u'
第八步:安装Mailscanner+clamav+spamassass
1、安装相关软件
- yum install -y patch rpm-build
- yum install -y perl-MIME-tools
- yum install -y gcc perl-Archive-Zip
- yum install -y spamassassin
- yum install -y perl-Razor-Agent
- yum install -y pyzor
- yum install -y unrar
- yum install -y clamav-db clamav clamd
- service spamassassin start
- chkconfig spamassassin on
- ####其中有个dcc需要源代码安装
- [root@mail ~]# tar -zxv -f /usr/local/src/dcc-dccd.tar.Z
- [root@mail ~]# cd /usr/local/src/dcc-dccd-1.3.140/
- [root@mail dcc-dccd-1.3.140]# ./configure
- [root@mail dcc-dccd-1.3.140]# make
- [root@mail dcc-dccd-1.3.140]# make install
2、安装
- [root@mail ~]# cd /usr/local/src/
- [root@mail src]# tar -zxv -f MailScanner-4.84.3-1.rpm.tar.gz
- [root@mail src]# cd MailScanner-4.84.3-1
- [root@mail MailScanner-4.84.3-1]# vim yum.sh
- ###在里面有很多prel套件,但是我安装过程中有问题所以我把里面的套件重新安装了一遍;下面是我写的脚本,可
- ###能有些套件不能安装,但是影响不是很大,下面是我yum.sh脚本里面的内容
- #!/bin/bash
- yum install -y perl-Archive-Zip
- yum install -y perl-Net-CIDR
- yum install -y perl-bignum
- yum install -y perl-Net-DNS
- yum install -y perl-Compress-Raw-Zlib
- yum install -y perl-Net-IP
- yum install -y perl-Compress-Zlib
- yum install -y perl-OLE-Storage_Lite
- yum install -y perl-Convert-BinHex
- yum install -y perl-Pod-Escapes
- yum install -y perl-Convert-TNEF
- yum install -y perl-Pod-Simple
- yum install -y perl-DBD-SQLite
- yum install -y perl-Scalar-List-Utils
- yum install -y perl-DBI
- yum install -y perl-Storable
- yum install -y perl-Digest-HMAC
- yum install -y perl-Sys-Hostname-Long
- yum install -y perl-Digest-MD5
- yum install -y perl-Sys-SigAction
- yum install -y perl-Digest-SHA1
- yum install -y perl-Sys-Syslog
- yum install -y perl-ExtUtils-MakeMaker
- yum install -y perl-Test-Harness
- yum install -y perl-File-Spec
- yum install -y perl-Test-Pod
- yum install -y perl-Filesys-Df
- yum install -y perl-Test-Simple
- yum install -y perl-File-Temp
- yum install -y perl-TimeDate
- yum install -y perl-Getopt-Long
- yum install -y perl-Time-HiRes
- yum install -y perl-HTML-Parser
- yum install -y perl-HTML-Tagset
- yum install -y perl-IO
- yum install -y perl-IO-stringy
- yum install -y perl-MailTools
- yum install -y perl-Math-BigInt
- yum install -y perl-Math-BigRat
- yum install -y perl-MIME-Base64
- yum install -y perl-MIME-tools
- ###我执行这个脚本过后才运行的Mailscanner安装脚本。
- [root@mail MailScanner-4.84.3-1]# ./install.sh
3、设置MailScanner配置文件
- [root@mail ~]# vim /etc/MailScanner/MailScanner.conf
- Run As User = postfix ( 启动者)
- Run As Group = postfix (启动用户组)
- Incoming Queue Dir = /var/spool/postfix/hold/ (收信队列)
- Outgoing Queue Dir = /var/spool/postfix/incoming/ (寄信队列)
- MTA = postfix (使用的MTA为postfix)
- Max Children = 5 (产生子程序的上限)
- Virus Scanning = yes (启动病毒扫描)
- Virus Scanners = clamav (指定病毒扫描使用clamav,如果有多个,用空格分隔)
- Spam Checks = yes (启动spam扫描)
- Use SpamAssassin = yes (使用Spamassassin扫描spam)
- SpamAssassin Site Rules Dir = /etc/mail/spamassassin (SpamAssassin规则路径)
- Deliver Unparsable TNEF = yes (增加使用outlook的兼容)
- High Scoring Spam Actions = deliver header “X-Spam-Status: Yes” (积分高时在header标记X-Spam)
4、队列属性配置
- [root@mail ~]# chown postfix.postfix /var/spool/MailScanner/incoming
- [root@mail ~]# chown postfix.postfix /var/spool/MailScanner/quarantine
5、将postfix拖给MailScanner
- [root@mail ~]# vim /etc/postfix/main.cf
- header_checks = regexp:/etc/postfix/header_checks
- [root@mail ~]# vim /etc/postfix/header_checks
- /^Received:/ HOLD
6、停掉postfix,启动MailScanner
- service postfix stop
- chkconfig postfix off
- service MailScanner start
- chkconfig MailScanner on
7、设定clamav更新
- [root@mail ~]# vim /etc/crontab
- 0 0,12 * * * root /usr/bin/freshclam
8、spamassassin设定
- [root@mail ~]# ls /etc/mail/spamassassin/local.cf ###预设规则文件:可以去官网设定http://www.yrex.com
- #####/spam/spamconfig.php
- #####中文规则如下:
- [root@mail ~]# wget -N -P /etc/mail/spamassassin/ www.ccert.edu.cn/spam/sa/Chinese_rules.cf
- --2011-11-12 06:06:53-- http://www.ccert.edu.cn/spam/sa/Chinese_rules.cf
- Connecting to 192.168.1.9:3128... 已连接。
- 已发出 Proxy 请求,正在等待回应... 200 OK
- 长度:55342 (54K) [text/plain]
- Saving to: `/etc/mail/spamassassin/Chinese_rules.cf'
- 100%[======================================>] 55,342 48.6K/s in 1.1s
- 2011-11-12 06:06:59 (48.6 KB/s) - `/etc/mail/spamassassin/Chinese_rules.cf' saved [55342/55342]
- [root@mail ~]#
9、启动spamassassin自动学习
- [root@mail ~]# spamassassin --lint --config-file=/etc/MailScanner/spam.assassin.prefs.conf
- ####无资料库时出现debug: bayes: no dbs present, cannot tie DB R/O: /var/spool/MailScanner/spamassassin
- ####/bayes_toks
- ####执行sa-learn --sync在/var/spool/MailScanner/spamassassin/里建立bayes_seen/bayes_toks等资料库档案
10、建立黑白名单账户
- [root@mail ~]# useradd spam
- [root@mail ~]# useradd nospam
11、学习黑名单
- [root@mail ~]# sa-learn --prefs-file=/etc/MailScanner/spam.assassin.prefs.conf --showdots --spam --mbox /var/mail/spam
12、学习白名单
- [root@mail ~]#sa-learn --prefs-file=/etc/MailScanner/spam.assassin.prefs.conf --showdots --ham --mbox /var/mail/nospam
13、建立自动学习黑白名单脚本
- [root@mail ~]# vim /etc/cron.daily/spam-learn
- #!/bin/sh
- SPAM=/var/mail/spam
- NOSPAM=/var/mail/nospam
- LOGFILE=/var/log/spamlearn.log
- CONF=/etc/MailScanner/spam.assassin.prefs.conf
- LEARN=/usr/bin/sa-learn
- date >> $LOGFILE
- if [ -f $SPAM ]; then
- BOX=${SPAM}.processing
- mv $SPAM $BOX
- sleep 5
- $LEARN –prefs-file=$CONF –spam –mbox $BOX >> $LOGFILE 2>&1
- rm -f $BOX
- fi
- if [ -f $NOSPAM ]; then
- BOX=${NOSPAM}.processing
- mv $NOSPAM $BOX
- sleep 5
- $LEARN –prefs-file=$CONF –ham –mbox $BOX >> $LOGFILE 2>&1
- rm -f $BOX
- fi
- ####然后重启crond
- [root@mail ~]# /etc/rc.d/init.d/crond restart
第九步:安装Mailscanner-mrtg
1、安装SNMP
- [root@mail ~]# yum install -y net-snmp net-snmp-utils
2、设置snmp
- [root@mail ~]# vim /etc/snmp/snmpd.conf
- com2sec local localhost public
- com2sec mynetwork 192.168.1.0/24 public
- group MyRWGroup v1 local
- group MyROGroup v1 mynetwork
- group MyRWGroup v2c local
- view systemview included .1.3.6.1.2.1.1
- view systemview included .1.3.6.1.2.1.25.1.1
- view all included .1 80
- access MyROGroup "" any noauth prefix all none none
- access MyRWGroup "" any noauth prefix all all all
- syslocation Unknown (edit /etc/snmp/snmpd.conf)
- pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
- [root@mail ~]# /etc/rc.d/init.d/snmpd restart
- 停止 snmpd: [失败]
- 启动 snmpd: [确定]
3、安装MRTG
- [root@mail ~]# yum install -y mrtg
4、安裝Mailscanner-MRTG(下载:
)
- [root@mail ~]# rpm -ivh /mnt/postfix/mailscanner-mrtg-0.10.00-1.noarch.rpm
5、设置MailScanner-MRTG
- ####第一个文件
- [root@mail ~]# vim /etc/MailScanner/mailscanner-mrtg.conf
- MTA = postfix
- Incoming Queue Dir = /var/spool/postfix/hold
- Outgoing Queue Dir = /var/spool/postfix/incoming
- MailScanner Work Directory = /var/spool/MailScanner/incoming
- Spool Directory = /var
- Use SNMP = yes
- SNMP Community = public
- ####第二个文件
- [root@mail ~]# vim /etc/mrtg/mailscanner-mrtg.cfg
- Workdir: /var/www/html/mailscanner-mrtg/
- IconDir: /mrtg/
- WriteExpires: Yes
- Interval: 5
- Refresh: 300
- Language: big5
6、生成MailScanner-MRTG的index.html
- [root@mail ~]# indexmaker --output=/var/www/html/mailscanner-mrtg/index.html /etc/mrtg/mailscanner-mrtg.cfg
7、安装好过后可以输入http://XXXX/mailscanner-mrtg进行浏览,如果不行运行如下命令。再检查配置文件
- [root@mail ~]# mrtg /etc/mrtg/mailscanner-mrtg.cfg
8、下面是我访问的图片
第十步:安装Mailwatch
1、下载并安装(下载地址:
)
- [root@mail ~]# tar -zxv -f /usr/local/src/mailwatch-1.0.5.tar.gz
2、建立数据库
- [root@mail ~]# cd /usr/local/src/mailwatch-1.0.5
- [root@mail mailwatch-1.0.5]# mysql -p < create.sql
3、修改MailWatch设定
- [root@mail mailwatch-1.0.5]# vim MailWatch.pm
- my($db_name) = 'mailscanner'; ###数据库名称
- my($db_host) = 'localhost'; ###数据库位置
- my($db_user) = 'root'; ###数据库使用者
- my($db_pass) = '19901218'; ###使用者密码
4、复制给MailScanner
- [root@mail mailwatch-1.0.5]# cp MailWatch.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/
5、在数据库中添加网页使用者
- [root@mail mailwatch-1.0.5]# mysql mailscanner -u root -p
- Enter password:
- mysql> insert into users values ('root',md5('19901218'),'root','A','0','0','0','0','0');
6、设置网页
- [root@mail mailwatch-1.0.5]# mv mailscanenr /var/www/html
- [root@mail mailwatch-1.0.5]# cd /var/www/html/mailscanner
- [root@mail mailscanner]# chown root:apache p_w_picpaths
- [root@mail mailscanner]# chmod ug+rwx p_w_picpaths/
- [root@mail mailscanner]# chown root:apache p_w_picpaths/cache/
- [root@mail mailscanner]# chmod ug+rwx p_w_picpaths/cache/
7、修改mailwatch网页配置文件
- [root@mail mailscanner]# cp conf.php.example conf.php
- [root@mail mailscanner]# vim conf.php
- define('DB_TYPE', 'mysql');
- define('DB_USER', 'root');
- define('DB_PASS', '19901218');
- define('DB_HOST', 'localhost');
- define('DB_NAME', 'mailscanner');
8、修改MailScanner配置文件
- [root@mail mailscanner]# vim /etc/MailScanner/MailScanner.conf
- Quarantine User = root
- Quarantine Group = apache
- Quarantine Permissions = 0600
- Quarantine Whole Message = yes
- Quarantine Whole Messages As Queue Files = no
- Detailed Spam Report = yes
- Include Scores In SpamAssassin Report = yes
- Always Looked Up Last = &MailWatchLogging
9、设置黑白名单
- [root@mail mailscanner]# vim /usr/local/src/mailwatch-1.0.5/SQLBlackWhiteList.pm
- my($db_name) = 'mailscanner';
- my($db_host) = 'localhost';
- my($db_user) = 'root';
- my($db_pass) = 'f6a3f1a424fd6ce5aedf893158e71c1';
- [root@mail mailscanner]# cp /usr/local/src/mailwatch-1.0.5/SQLBlackWhiteList.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/
- [root@mail mailscanner]# vim /etc/MailScanner/MailScanner.conf
- Is Definitely Not Spam = &SQLWhitelist
- Is Definitely Spam = &SQLBlacklist
10、设置spamassassin
- [root@mail mailscanner]# vim /etc/MailScanner/spam.assassin.prefs.conf
- bayes_path /etc/MailScanner/bayes/bayes
- bayes_file_mode 0660
11、复制bayes资料库到MailScanner下面
- cp /root/.spamassassin/bayes_* /etc/MailScanner/bayes
- chown root:apache /etc/MailScanner/bayes/bayes_*
- chmod g+rw /etc/MailScanner/bayes/bayes_*
- ####测试spamassassin;
- [root@mail .spamassassin]# spamassassin -D -p /etc/MailScanner/spam.assassin.prefs.conf --lint
12、mailscanner网页汉化网址:
我这里就不详细说明了。
13、登录mailwatch检测页面,地址为:http://xxxx/mailscanner首先要输入用户名和密码,如下对话框图,进入过后就是mailwatch for mailscanner 的界面。
最后一步:邮件测试
1、启动各项服务(我写了一个脚本):
#!/bin/bash service httpd restart /etc/init.d/courier-authlib restart service dovecot restart service spamassassin restart service MailScanner restart service named restart
2、extmail登录以及邮件发送测试
原文网址:http://276660374.wp5.dvbbs.net/forum.php?mod=viewthread&tid=604&page=1&extra=#pid5155
参照的网址
#####主要的安装
#####
courier-authlib安装 #####maildrop安装 ####mailscanner+clamav+spamassassin ####mailscanner-mrtg+mailwatch安装