码迷,mamicode.com
首页 > 数据库 > 详细

基于MySQL认证的邮件系统

时间:2015-05-30 18:31:43      阅读:319      评论:0      收藏:0      [点我收藏+]

标签:邮件系统   数据库   

基于MySQL认证的邮件系统

      经过几天的学习和研究,终于完成了基于MySQL的虚拟账号认证的邮件系统的搭建。发现搭建邮件系统及庞大而又复杂,涉及到多方面的知识:DNS的搭建,服务脚本的编写,证书加密原理,数据库的搭建,垃圾邮件的过滤等等。关于其中涉及到的相关独立知识点,之后会单独写日志。另外,需要说明的是本技术文档,基本上全部是使用的最新版本,核心软件全部使用源码包编译安装。其中,也包括搭建过程中遇到的各种问题的解决方法。

所需源码软件:
    postfix-2.10.0.tar.gz
    cyrus-sasl-2.1.25.tar.gz            
    dovecot-2.2.0.tar.gz                 
    extmail-1.2.tar.gz                   
    extman-1.1.tar.gz                    
    File-Tail-0.99.3.tar.gz              
    GDGraph-1.44_01.tar.gz              
    rrdtool-1.4.7.tar.gz
    libtool-2.4.2.tar.gz                 
    Time-HiRes-1.9725.tar.gz
    mysql-5.5.28-linux2.6-x86_64.tar.gz 
    Unix-Syslog-1.1.tar.gz

概述:
        postfix默认是基于IP地址的本地用户认知,受限于本地网络。而基于虚拟用户的认证,最大的好处是不受地理位置的影响,所以可以查收邮件。同时也便于管理和维护。

原理简述:
        首先, MUA请求于MTA(postfix),而MTA(postfix)本身不具备认证功能,因此MTA需要借助SASL(简单认证安全层)协议来实现认证功能。但SASL要实现基于MySQL的虚拟账号认证,需要借助于Courier-authlib,最后,Courier-authlib再实现与MySQL的通信。

说明:所有的源码包都在/usr/local/src底下

##############################MySQL##########################
     ############环境配置###########
1.  tar xf mysql-5.5.28-linux2.6-x85_64.tar.gz -C /usr/local/
2.  ln -sv mysql-5.5.28-linux2.6-x85_64.tar.gz mysql
3.  ln -sv /usr/local/mysql/include /usr/include/mysql
4.  echo "/usr/local/mysql/lib" >> /etc/ld.so.conf.d/mysql.conf
5.  ldconfig -v 
6.  sed -i ‘45a\/usr/local/mysql/man‘ /etc/man.config
7.  echo "PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh
8.  source /etc/profile
    
 #############建立数据库分区###########
1.  fdisk -cu /dev/sdb ------>/dev/sdb1(分区过程略)
2.  pvcreate /dev/sdb1
3.  vgcreate vg_mysql /dev/sdb1
4.  lvcreate -L 10G -n lv_mdata vg_mysql
5.  mkfs.ext4 /dev/vg_mysql/lv_mdata
6.  mkdir /mdata
7.  echo "/dev/vg_mysql/lv_mdata  /mdata  ext4  defaults,acl  0 0" >> /etc/fstab
8.  mount -a
    
 #############添加用户并初始化#########
1. groupadd mysql
2. useradd -r -g mysql mysql
3. cd mysql
4. chgrp -R mysql .
5. chown -R mysql.mysql /mdata
6. scripts/mysql_install_db --datadir=/mdata --user=mysql
7. cp support-files/my-large.cnf /etc/my.cnf
8. cp support-files/mysql.server /etc/init.d/mysqld
9. service mysqld start  注:此处若启动不成功,就再次将第6步重新执行一遍。
10.chkconfig --add mysqld
11.chkconfig mysqld on
12.pgrep mysqld

#####################Cyrus-SASL#####################################
 #####编译安装#####(如果对源码包安装所涉及到的库文件和头文件等知识不太了解的话,此处建议是使用rpm包安装。否则后面出现的问题会相当难解决。)
1. tar xf cyrus-sasl-2.1.25.tar.gz ; cd cyrus-sasl-2.1.25
2. ./configure \
   --disable-crm \
   --disable-digest \
   --disable-otp \
   --disable-krb4 \
   --disable-gssapi \
   --disable-anon \
   --enable-sql \
   --with-mysql=/usr \
   --with-login \
   --with-plain \
   --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket
3. make (注:1.此处或许遇到找不到des.h文件的情况,只要将./mac/libdes/public/des.h考到当前 目录即可。
       2.此处也或许与到找不到mysql.h的情况,只需将--with-mysql=/usr/local/mysql改为 --with-mysql=/usr即可.
    3.如果报libsql.la错误的话,则将--with-mysql=/usr/local/mysql改为--with-mysql=/usr/local/mysql/lib即可)
4. make install
5. echo "/usr/local/lib" >> /etc/ld.so.conf && ldconfig
6. ln -sv /usr/local/lib/sasl2 /usr/lib4/sasl2 (注:因为默认系统可能已经安装了rpm包的cyrus-sasl,此时,若你的系统是64位的的话,
            那么默认查找路径应该是/usr/lib64/sasl2。为了避免库文件查找错误,需要先把以rpm包安装在/usr/lib64位下的libsasl2.so*文件删除,
            然后运行ldconfig命令即可。)
 #####编写saslauthd服务控制脚本#####
7.  vim /etc/init.d/saslauthd
  #!/bin/bash 
  #
  #chkconfig:2345 70 30
  #
  #Called functions
  . /etc/rc.d/init.d/functions
  #
  #Defined variables
  prog=saslauthd
  path=/usr/local/sbin/saslauthd
  mech=shadow
  retval=0
  #
  #Defined control functions
  start() {
         echo -n $"Starting $prog: "
         daemon $path -a $mech
         echo
         retval=$?
  }
  stop() {
         echo -n $"Stopping $prog: "
         killproc $path
         echo
         retval=$?
  }
  #
  case $1 in 
  start)
         start
         ;;
  stop)
         stop
         ;;
  restart)
         stop
         start
         retval=$?
         ;;
  status)
         status $prog
         ;;
  *)
         echo $"Usage: $prog {start|stop|restart|status|}"
  esac
  exit $retval

8. chkconfig --add saslauthd
9. service saslauthd start

################Postfix################
#####添加使用的用户与组#####
1. groupadd -g 2525 postfix
   useradd -u 2525 -g 2525 -s /sbin/nologin -M postfix
   groupadd -g 2526 postdrop
   useradd -u 2526 -g postdrop -s /sbin/nologin -M postdrop
#####编译安装#####
2. make makefiles CCARGS="-DHAS_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/include/sasl -DUSE_TLS"
      AUXLIBS="-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/local/lib -lsasl2 -lssl -lcrypto"

  注:此处或许遇到找不到db.h文件的情况,只需yum -y install db4-devel就可以。另外因为是rpm包安装的openssl,所以此处不需要指定头文件和库文件的路径,假如是编译安装的话,则需要单独指定路径。
3. make && make install

#####编写postfix服务启动脚本#####
4. vim /etc/init.d/postfix
 #!/bin/bash
 #
 # chkconfig:2345 75 25
 #
 # Called functions
 . /etc/rc.d/init.d/functions
 # Defined variables
 prog=postfix
 smtpd=/usr/libexec/postfix/master
 retval=0
 # Defined control functions
 start() {
             echo -n $"Starting $prog: "
             daemon $prog start
             echo
             retval=$?
 }
 stop() {
             echo -n $"Stopping $prog: "
             killproc $smtpd
             echo
             retval=$?
 }
 reload() {
               echo -n $"Reloading $prog: "
               daemon $prog reload
               echo
               retval=$?
 }
 case $1 in
 start)
             start
             ;;
 stop)
             stop
             ;;
 restart)
             stop
             start
             retval=$?
             ;;
 status)
             status $smtpd
             ;;
 reload)
             reload
             ;;
 *)
             echo $"Usage: $prog {start|stop|restart|status|reload}"
 esac
 exit $retval
5. chkconfig -add postfix 
6. service postfix start
#####postfix基本配置#####
1. 更改/etc/postfix/main.cf
   myhostname = server.example.com
   mydomain = example.com
   myorigin = $mydomain
   mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
   mynetworks = 192.168.1.0/24, 127.0.0.0/8
   inet_interfaces = all 
2. service postfix restart

#####测试postfix#####
3. telnet 192.168.1.102 25
220 server.example.com ESMTP Postfix
helo server
250 server.example.com
mail from:test
250 2.1.0 Ok
rcpt to:yonchin@example.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
test
.
250 2.0.0 Ok: queued as B6678A0AAC
quit
221 2.0.0 Bye


注:如果yonchin收到邮件的话证明postfix运行正常

#####让postfix支持SASL#####
1. postconf -a 
   cyrus
   dovecot    #检测postfix支持哪些认证方式
2. 添加以下参数到main.cf中
 stmpd_sasl_auth_enable = yes
 smtpd_recipient_restrictions = permit_mynetworks
    permit_sasl_authenticated
    reject_unauth_destination
    reject_unauth_pipelining
    reject_invalid_hostname
    reject_non_fqdn_sender
    reject_non_recipient
    reject_unknown_sender_domain
    reject_unknown_recipient_domain
 smtpd_sasl_local_domain = $domain
 smtpd_sasl_path = smtpd
 smtpd_sasl_security_options = noanonymous
 smtpd_sasl_authenticated = yes
 smtpd_sasl_type = cyrus
 broken_sasl_auth_clients = yes
注:要启用postfix的sasl认证功能至少需要配置前两条
3. 在/usr/local/lib/sasl2/下新建smtpd.conf文件,并添加如下内容:
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN

#####测试postfix功能是否生效#####
4. telnet 192.168.1.102 25
220 server.example.com ESMTP Postfix
ehlo server
250-server.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
只要出现如上所示AUTH PLANIN LOGIN 和 AUTH=PLANIN LOGIN,就证明配置成功。
(注:测试postfix是否已经具有了认证功能,也可以使用更简单快捷smtptest命令,来进行测试。)

#####让postfix支持虚拟域和虚拟用户#####

1. 在/etc/postfix/main.cf添加以下配置
 virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
 virtual_mailbox_base = /var/mailbox
 virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
 virtual_uid_maps = static:2525
 virtual_gid_maps = static:2525
 vritual_alias_domains =
 virutal_alias_maps = mysql:/etc/postfix/mysql_virutal_alias_maps.cf
 virutal_transport = virtual

2. mkdir /var/mailbox && chown -R postfix /var/mailbox

3. 编写mysql_virtual_domains_maps.cf,添加如下内容:
 hosts = localhost
 user = extmail
 password = extmail
 dbname = extmail
 table = domain
 select_field = domain
 where_field = domain
 additional_conditions = AND active = ‘1‘

 编写mysql_virtual_mailbox_maps.cf,添加如下内容:
 hosts = localhost
 user = extmail
 password = extmail
 dbname = extmail
 table = mailbox
 select_field = maildir
 where_field = username
 additional_conditions = AND active = ‘1‘

 编写mysql_virtual_mailbox_maps.cf,添加如下内容:
 hosts = localhost
 user = extmail
 password = extmail
 dbname = extmail
 table = alias
 select_field = goto
 where_field = address
 additional_conditions = AND active = ‘1‘

########################Courier-authlib########################
1. 先编译安装libtool-2.4.2.tar.gz
   tar xf /usr/local/src/libtool-2.4.2.tar.gz
2. make && make install
3. 编译安装courier-authlib-0.65.0.20130414.tar.bz2
   tar xf courier-authlib-0.65.0.20130414.tar.bz2
   ./configure --prefix=/usr/local/courier-authlib \
   --sysconfdir=/etc \
   --without-authpam \
   --without-authpwd \
   --without-authshadow \
   --without-authpgsql \
   --without-authldap \
   --without-authuserdb \
   --with-authmysqlrc=/etc/authmysqlrc \
   --with-authdaemonrc=/etc/authdaemonrc \
   --with-mysql-libs=/usr/local/mysql/lib \
   --with-mysql-includes=/usr/local/mysql/include \
   --with-mailuser=postfix \
   --with-mailgroup=postfix 
4. make && make install
5. echo "/usr/local/courier-authlib/lib/courier-authlib" >/etc/ld.so.conf.d/courier-authlib.conf
   cp courier-authlib.sysvinit /etc/init.d/courier-authlib
   chmod +x /etc/init.d/courier-authlib
   cp -a /etc/authmysqlrc.dist /etc/authmysqlrc
   cp -a /etc/authdaemonrc.dist /etc/authdaemonrc
   chkconfig --add courier-authlib
   chkconfig courier-authlib on
6. 修改/etc/authdaemonrc
   authmodulelist="authmysql"
   authmodulelistoring="authmysql"
   daemons=10
7. 修改/etc/authmysqlrc
   MYSQL_SERVER  localhost
   MYSQL_USERNAME extmail
   MYSQL_PASSWORD extmail
   MYSQL_PORT  3306
   MYSQL_BATABASE extmail
   MYSQL_USER_TABLE mailbox
   MYSQL_CRYPT_PWFIELD password
   MYSQL_UID_FIELD 2525
   MYSQL_GID_FILED 2525
   MYSQL_LOGIN_FILED username
   MYSQL_HOME_FILED concat(‘/var/mailbox/‘,homedir)
   MYSQL_NAME_FILED name
   MYSQL_MAILDIR_FIELD concat(‘/var/mailbox/‘,maildir)
8. 重新配置/usr/local/lib/sasl2/smtpd.conf
 pwcheck_method: authdaemond
 mech_list: PLAIN LOGIN
 log_level: 3
 authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
###############Extmail###############
1. mkdir -pv /var/www/extsuite/extmail
2. tar xf /usr/local/src/extmail-1.2.tar.gz
   cp -r /usr/local/src/extmail-1.2/*  /var/www/extsuite/extmail
   cp /var/www/extsuite/extmail/webmail.cf.default /var/www/extsuite/extmail/webmail.cf
3. 修改webmail.cf配置如下:
   SYS_USER_LANG = zh_CN
   SYS_MAILDIR_BASE = /var/mailbox
   SYS_MYSQL_USER = extmail
   SYS_MYSQL_PASS = extmail
   SYS_MYSQL_SOCKET = /tmp/mysql.sock
   SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
4. 添加虚拟主机(注:httpd使用rpm包安装)
   NameVirtualHost *:80
   <VirtualHost *:80>
   ServerName mail.example.com
   DocumentRoot /var/www/extsuite/extmail/html/
   ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
   Alias /extmail /var/www/extsuite/extmail/html
   SuexecUserGroup postfix postfix
   </VirtualHost>
5. chown -R postfix.postfix /var/www/extsuite/extmail/cgi
6. service httpd restart
7. yum -y install perl-CGI (若此处打开浏览器进行测试报找不到CGI.PM的错误,则需要安装此软件包
8. 编译安装extmail依赖包Unix-Syslog
   tar xf Unix-Syslog-1.1.tar.gz
   perl Makefile.PL (注:此处或许会报Can‘t locate ExtUtils/MakeMaker.pm的错误,则安装yum -y install per-ExtUtils-       MakeMaker* 即可)
   make 
   make install 
   
到此打开网页即可正常显示webmail登陆界面

#################Extman########################
1. mkdir /var/www/extsuite/extman
2. tar xf /usr/local/src/extman-1.1.tar.gz
3. cp -r /usr/local/src/extman-1.1/* /var/www/extsuite/extman
4. cd /var/www/extsuite/extman
5. cp webman.cf.default webman.cf
6. 更改webman.cf配置如下:
   SYS_MAILDIR_BASE = /var/mailbox
   SYS_CAPTCHA_ON = 0 
   SYS_MYSQL_SOCKET = /tmp/mysql.sock

7. mkdir /tmp/extman && chown -R postfix.postfix /tmp/extman

8.在http.conf中虚拟主机中添加以下配置选项:
  ScritpAlias /extman/cgi /var/www/extsuite/extman/cgi
  Alias /extman /var/www/extsuite/extman/html
9. chown -R postfix.postfix /var/www/extsuite/extman/cgi
10. service httpd restart
################建立数据库#######################
1. 使用/var/www/extsuite/extman/docs下的extmail.sql和init.sql建立数据库
  sed -i ‘s@TYPE=MyISAM@Engine=MyISAM@g‘ extmail.sql(注:因为mysql版本更新比extmail快,所以在使用extmail.sql建立数据       库前需要先将数据库引擎字段更改一下)

2. mysql -uroot -p < extmail.sql
3. mysql -uroot -p < init.sql
4. 打开网页登陆到邮件后台管理测试,会报Can‘t locate DBD/mysql.pm错误,则需安装perl-DBD-MySQL
   yum -y install perl-DBD-MySQL

5. 为后台数据库管理账号webman授权:
   GRANT all privileges ON extmail.* TO webman@localhost IDENTIFIED BY ‘webman‘
   GRANT all privileges ON extmail.* TO webman@127.0.0.1 IDENTIFIED BY ‘webman‘

6. 到此基于虚拟域和虚拟账号的邮件web系统系统已经配置完毕。extman后台,默认管理账号是:root@extmail.org ,密码是:extmail*123*

#################配置Extman图形日志########################
http://www.cpan.org下载Time-HiRes和File-Tail软件
http://oss.oetiker.ch/rrdtool/pub/?M=D下载rrdtool

1.tar xf Time-HiRes-1.9725.tar.gz
  cd Time-HiRes-1.9725
  perl Makefile.PL
  make 
  make test
  make install
2.tar xf File-Tail-0.99.3.tar.gz
  cd File-Tail-0.99.3
  perl Makefile.PL
  make
  make install
3.tar xf  rrdtool-1.4.7.tar.gz
  cd rrdtool-1.4.7
  ./configure --prefix=/usr/local/rrdtool
  make   (注:此处要是编译时,需要解决依赖关系,需要安装:libxml2-devel,glib2-devel,cairo-devel,pango-devel)
  make install

4. 建立默认rrdtool库文件查找路径的符号链接

   ln -sv /usr/local/rrdtool/lib/perl/5.10.1/RRDp.pm /usr/lib64/perl5/
   ln -sv /usr/local/rrdtool/lib/perl/5.10.1/x86_64-linux-thread-multi/RRDs.pm /usr/lib64/perl5/
   mkdir -pv /usr/lib64/perl5/auto/RRDs
   ln -sv /usr/local/rrdtool/lib/perl/5.10.1/x86_64-linux-thread-multi/auto/RRDs/RRDs.so  /usr/lib64/perl5/auto/RRDs

5. 启动extman图形日志插件服务,并开机自动启动
  cp -r /var/www/extsuite/extman/addon/mailgraph_ext /usr/local
  cd /usr/local
  ./mailgraph-init start
  
  echo "/usr/local/mailgraph_ext/mailgraph-init start" >> /etc/rc.local
  
########################Dovecot############################
1. useradd -M -s /sbin/nologin dovenull
   useradd -M -s /sbin/nologin dovecot
2. ./configure --prefix=/usr/local/dovecot \
> --sysconfdir=/etc \
> --with-sql=yes \
> --with-mysql \
> --with-zlib \
> --with-bzlib \
> --with-ssl=openssl \
> --with-docs
注:此处若遇到“error: Can‘t build with bzlib support: bzlib.h not found”的错误,则需要安装bzip2-devel
3. make && make install
4. echo "/usr/local/dovecto/lib" >> /etc/ld.so.conf.d/dovecot.conf
5. echo "PATH=$PATH:/usr/local/dovecot/bin:/usr/local/dovecot/sbin" > /etc/profile.d/dovecot.sh
6. cp -r /usr/local/dovecot/share/doc/dovecot/example-config/* /etc/dovecot/
7.修改/etc/dovecot/dovecot.conf
   protocols = imap pop3
   
  修改/etc/dovecot/dovecot.d/10-mail.conf
   mail_location = maildir:/var/mailbox/%d/%n/Maildir
   
  修改/etc/dovecot/dovecot.d/10-auth.conf
   disable_plaintext_auth = no
   !include auth-sql.conf.ext(开启,默认是被注释掉的)
   
  修改/etc/dovecot/dovecot-sql.conf.ext
   connect = host=/tmp/mysql.sock dbname=extmail user=extmail password=extmail
   default_pass_scheme = CRYPT
   password_query = SELECT username AS user, password AS password \
     FROM extmail WHERE username = ‘%u‘
   user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid \
    FROM extmail WHERE username = ‘%u‘

8. 启动服务:/usr/local/dovecot/sbin/dovecot 
9. 测试:telnet 192.168.1.102 110
 USER t1@test.com
 PASS test
 -ERR Authentication failed. 
 查看日志:在/var/log/maillog里发现:
 Error: user t1@test.com: Initialization failed: Initializing mail storage from mail_location setting failed: 
 stat(/var/mailbox/test.com/t1/Maildir)failed: Permission denied (euid=1000(<unknown>) egid=1000(<unknown>)
 missing +x perm: /var/mailbox/test.com, euid is not dir owner)
 
 解决方法:1.修改/var/www/extsuite/extman/tools/userctl.pl
     uidnumber => $uidnumber || 1000 (将1000改为2525,即你所指定的postfix的用户uid和gid)
     gidnumber => $gidnumber || 1000 (将1000改为2525,即你所指定的postfix的用户uid和gid)
     2.将数据库中uidnumber和gidnumber的默认值改为2525(即,你所指定的postfix的用户uid和gid)
     ALTER TABLE mailbox ALTER uidnumber SET DEFAULT 2525;
     ALTER TABLE mailbox ALTER gidnumber SET DEFAULT 2525;
     (注:如果在修改默认值之前创建过虚拟域和虚拟账号,则最好将其删除干净,否则在你创建同名的虚拟域和账号时还会报以上的错误)
10. 注释掉/etc/postfix/main.cf中以下几行(否则会报错):
   #myhostname = server.example.com
   #mydomain = example.com
   #myorigin = $mydomain
   #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
   #mynetworks = 192.168.1.0/24, 127.0.0.0/8 
11. service postfix restart
####################让dovecot支持pop3s和imaps###################
 建立自签名证书
1. cd /etc/pki/CA/private/
2.(umask 077; openssl genrsa -out cakey.pem 1024)
3. cd /etc/pki/CA
4. openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 365
5. touch index.txt 
6. echo 01 >serial
7. mkdir /etc/dovecot/.ssl
8. cd /etc/dovecot/.ssl
9. (umask 077; openssl genrsa -out dovecot.key 1024)
10. openssl req -new -key dovecot.key -out dovecot.csr
11. openssl ca -in dovecot.csr -out dovecot.crt
12. 修改/etc/dovecot/dovecot.d/10-auth.conf
  disable_plaintext_auth = yes
13. 修改/etc/dovecot/conf.d/10-ssl.conf
 ssl = yes
 ssl_cert = </etc/dovecot/.ssl/dovecot.crt
 ssl_key = </etc/dovecot/.ssl/dovecot.key
14. service dovecot restart
15. 此时若是使用outlook来收邮件则必须将pop3的端口号改为995
#############################防病毒/垃圾邮件##############################
所需软件:spamassassin-3.3.1-2.el6.x86_64
    clamav-db-0.97.7-1.el6.rf.x86_64.rpm (下载地址:http://pkgs.repoforge.org/clamav/)
    clamav-0.97.7-1.el6.rf.x86_64.rpm    (下载地址:http://pkgs.repoforge.org/clamav/)
    MailScanner-4.84.5-3.rpm.tar.gz    (下载地址:http://www.mailscanner.info/downloads.html)
1. yum -y install spamassassin
2. 修改/etc/mail/spamassassin/local.cf
 required_hits 10
 report_safe 0
 rewrite_header Subject [SPAM]
 use_bayes 1
 ok_locales all
3. cd /usr/local/src
4. yum -y localinstall clamav-0.97.7-1.el6.rf.x86_64.rpm
5. tar xf MailScanner-4.84.5-3.rpm.tar.gz
6. ./install.sh
7. 编辑/etc/MailScanner/MailScanner.conf
 %org-name% = example
 %org-long-name% = example.com
 %web-site$ = mail.example.com
 
 Run As User = postfix
 Run As Group = postfix
 Incoming Queue Dir = /var/spool/postfix/hold
 Outgoing Queue Dir = /var/spool/postfix/incoming
 MTA = postfix
 
 Virus Scanning = yes
 Virus Scanners = clamav
 
 Use SpamAssassin = yes
 Always Include SpamAssassin Report = yes
 SpamAssassin User State Dir = /var/spool/MailSanner/spamassassin
 SpamAssassin Install Dir = /usr/bin
 SpamAssassin Local Rules Dir = /etc/mail/spamassassin
8.  修改/etc/postfix/main.cf
 header_checks = regexp:/etc/postfix/header_checks
9. 修改/etc/postfix/header_checks
 /^Received:/ HOLD
 /^Received:.*\[127\.0\.0\.1/ IGNORE
 /^Received:.*\[192\.168\.1\.[0-255]/ IGNORE
10. postmap /etc/postfix/header_check
11. chown -R postfix:postfix /var/spool/MailSanner
12. service postfix restart 
 service MailSanner restart
到此,webmail 和 outlook 都可以进行接收发送邮件的服务了。整个大框架基本完成。


本文出自 “一切皆有可能” 博客,请务必保留此出处http://noican.blog.51cto.com/4081966/1656572

基于MySQL认证的邮件系统

标签:邮件系统   数据库   

原文地址:http://noican.blog.51cto.com/4081966/1656572

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!