RedHat el5.0 搭建 Postfix 邮件服务器系统
                      
(postfix+cyrus-sasl2+courier-authlib+courier-imap+extmail+maildrop)
一、系统环境
       操作系统:rhel-5.2
       所需软件(按网上以前的文档,好多版本都找不到,只能找相近的,下面都是在实验后都可以使用的包2010/10/27)
      httpd-2.2.0.tar.bz2          架设web用于extman的后台管理,extmail 的web邮件收发
      php-5.2.14.tar.gz             Php 解释器,extman & extmail 需要使用php 
      mysql-5.1.37.tar.gz           用于存储虚拟域、虚拟账户信息
      postfix-2.4.5.tar.gz          邮件服务器系统的smtp服务器,充当MTA
      cyrus-sasl-2.1.22.tar.gz      用于实现身份验证的 smtp 服务器
      courier-authlib-0.58.tar.bz2  实现带验证的 pop3 服务器
      courier-imap-4.2.0.tar.bz2    用于实现 pop3、imap 收邮件功能
      extmail-1.1.0.tar.gz          用于实现 webmail
      extman-0.2.5.tar.gz           用于邮件服务器的后台管理
      openssl-0.9.8e.tar.gz         提供安全的邮件服务器连接
      DBD-mysql-2.9008.tar.gz       用于解决依赖关系,extmail 将会用到
      Unix-Syslog-1.1.tar.gz        用于解决依赖关系,extmail 将会用到
      BerkeleyDB(db-4.5.20.tar.gz)在编译postfix要使用
      maildrop-2.0.4.tar.bz2        用来代替postfix自带的MDA,是一个带有过滤功能的MDA
       pcre-7.2.tar.bz2             用于安装maildrop

    系统禁用 selinux 
 
二、软件安装
      1、安装apache
      tar zxvf httpd-2.2.0.tar.gz
      cd httpd-2.2.0
      ./configure --prefix=/usr/local/apache --enable-so
      make
      make install
      安装最主要的是mod_so模块httpd –l检测mod_so.c,目的是为了以模块方式加载php
 
     2、安装 mysql
      tar xvf mysql-5.1.37.tar.gz
      cd mysql-5.1.37
      ./configure -prefix=/usr/local/mysql
      make&&make install
      useradd mysql
      cp support-files/my-medium.cnf  /etc/my.cnf
      cd /usr/local/mysql
      /usr/local/mysql/bin/mysql_install_db  --user=mysql //初始化数据库
      chown -R root .
      chown -R mysql var
      chgrp -R mysql .
      echo "/usr/local/mysql/lib/mysql">>/etc/ld.so.conf
      ldconfig
      echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
      source /etc/profile
      上面这几行红色的字,必须要添加,否则在安装过程中会出现很多错误,还在注意在/tmp目录下是否存在 mysql.sock
这个文件,如果没有的话,就要做一个链接了,避免mysql在启动时报错
     复制一个编译目录的脚本,以使 mysql 每次启动时都能自动运行,回到编译的目录mysql-5.1.37
     cp support-files/mysql.server /etc/rc.d/init.d/mysqld
     chkconfig --add mysqld
     chkconfig --level 35 mysqld on
     service mysqld start
 
   3、安装php
    tar –xvf php-5.2.14.tar.gz
   cd php-5.2.14
   ./configure -prefix=/usr/local/php -with-apxs2=/usr/local/apache/bin/apxs
-with-mysql=/usr/local/mysql
   make&&make install
   cp php.ini-dist /usr/local/php/lib/php.ini
    修改apache的配置文件 httpd.conf加上"AddType application/x-httpd-php .php,定位至
DirectoryIndex index.html ,修改为: DirectoryIndex index.php index.html
     在目录/usr/local/apache/htdocs下创建一个最简单的php测试文件,其内容为:
     vi test.php
     <?
      phpinfo();
      ?>  
    检查一下apache配置文件是否正确(/usr/local/apache/bin/apachectl -t),输出"Syntax
OK"后就可以启动apache服务(/usr/local/apache/bin/apachectl start)。
     在浏览器上测试test.php,会看到php的信息
 
    4、安装 openssl
     tar zxvf openssl-0.9.8e.tar.gz
    ./config shared zlib
    make
    make test
    make install
    mv /usr/bin/openssl /usr/bin/openssl.OFF
    mv /usr/include/openssl /usr/include/openssl.OFF
    rm -rf /usr/lib/libssl.so
    ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
    ln -s /usr/local/ssl/include/openssl /usr/include/openssl
    ln -sv /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so
    echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
    ldconfig  
    检查是否安装 openssl
     openssl version
      OpenSSL 0.9.8e 23 Feb 2007

     5、安装 courier-authlib
        tar jxvf courier-authlib-0.58.tar.bz2
        cd courier-authlib-0.58
       . /configure --prefix=/usr/local/authlib --without-authpam
--without-authldap --without-authpwd --without-authpgsql    --with-authmysql
--without-authshadow --without-authvchkpw
--with-mysql-libs=/usr/local/mysql/lib/mysql
--with-mysql-includes=/usr/local/mysql/include/mysql --with-redhat
CFLAGS="-march=i686 -O2 -fexpensive-optimizations" CXXFLAGS="-march=i686 -O2
-fexpensive-optimizations"
         make && make install
        chmod 755 /usr/local/authlib/var/spool/authdaemon
         cp /usr/local/authlib/etc/authlib/authdaemonrc.dist
/usr/local/authlib/etc/authlib/authdaemonrc
         cp /usr/local/authlib/etc/authlib/authmysqlrc.dist
/usr/local/authlib/etc/authlib/authmysqlrc

         vi /usr/local/courier-authlib/etc/authlib/authdaemonrc
         authmodulelist="authmysql"
         authmodulelistorig="authmysql"
         daemons=10

       vi /usr/localcourier-authlib/etc/authlib/authmysqlrc
         MYSQL_SERVER localhost
         MYSQL_PORT 3306
         MYSQL_USERNAME extmail
         MYSQL_PASSWORD extmail
         MYSQL_SOCKET /tmp/mysql.sock
         MYSQL_DATABASE extmail
         MYSQL_USER_TABLE mailbox
         MYSQL_CRYPT_PWFIELD password
         MYSQL_UID_FIELD '2525'
         MYSQL_GID_FIELD '2525'
         MYSQL_LOGIN_FIELD username
         MYSQL_HOME_FIELD concat('/var/mailbox/',homedir)
         MYSQL_NAME_FIELD name
         MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir) 
         注:其中
2525,2525为postfix用户的UID和GID(这里可先设置id号,当建postfix用户时,可指定uid,gid要注意对应即可,这个文件中不能出现空格,或者会出现错误
          设置 courier-authlib 自启动
          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
          echo "/usr/local/authlib/lib/courier-authlib" >> /etc/ld.so.conf
           ldconfig
           service courier-authlib start

       6、安装 courier-sasl
         删除以前的rpm包以及相关目录,系统自带的与authlib配合不好
         rpm –qa | grep sasl 显示出已安装的都要删除
         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 –xvf cyrus-sasl-2.1.22.tar.gz
(使用2.1.21版本,在make时报错,网上查要sasl.patch补丁,也没启作用,最后还是选择了2.1.22版本)
         cd cyrus-sasl-2.1.22
./configure --enable-plain --enable-cram --enable-digest --enable-login
--enable-sql --disable-anon --disable-ntlm --disable-gssapi --disable-krb4
--disable-otp --disable-srp --disable-srp-setpass
--with-authdaemond=/usr/local/authlib/var/spool/authdaemon/socket
--with-mysql=/usr/local/mysql
--with-mysql-includes=/usr/local/mysql/include/mysql
--with-mysql-libs=/usr/local/mysql/lib/mysql
          make
          make install
          ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
          增加"/usr/local/lib"到你的"/etc/ld.so.conf",并执行ldconfig命令。
          vi /usr/local/lib/sasl2/smtpd.conf
          pwcheck_method: authdaemond
          log_level: 3
         mech_list: PLAIN LOGIN
          authdaemond_path:/usr/local/authlib/var/spool/authdaemon/socket
    
    注意,这个文件的编辑不要多写一个空格,否则会出现smtp验证不过的问题

     7、安装 Berkeley-DB
         tar zxvf db-4.5.20.tar.gz
         cd db-4.5.20/build_unix
         ../dist/configure —prefix=/usr/local/BerkeleyDB
         make
         make install
         mv /usr/inculde/db4 /usr/inculde/db4.OFF
         rm -rf /usr/inculde/db_cxx.h
         rm -rf /usr/inculde/db.h
         rm -rf /usr/inculde/db_185.h
         ln -s /usr/local/BerkeleyDB/include /usr/include/db4
         ln -s /usr/local/BerkeleyDB/include/db.h /usr/include/db.h
         ln -s /usr/local/BerkeleyDB/include/db_cxx.h /usr/include/db_cxx.h
         echo "/usr/local/BerkeleyDB/lib" >> /etc/ld.so.conf
         ldconfig

      8、安装 postfix
         groupadd -g 2525 postfix
         useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
         groupadd -g 2526 postdrop
         useradd -g postdrop -u 2526 -s /bin/false -M postdrop
         service sendmail stop
         mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF
         mv /usr/bin/mailq /usr/bin/mailq.OFF
         mv /usr/bin/newaliases /usr/bin/newaliases.OFF
         tar zxvf postfix-2.4.5.tar.gz
         cd postfix-2.4.5
         make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql 
-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl 
-I/usr/local/BerkeleyDB/include -DUSE_TLS -I/usr/local/ssl/include/openssl '
'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz  -lm   
-L/usr/local/sasl2/lib    -lsasl2    -L/usr/local/BerkeleyDB/lib   
-L/usr/local/ssl/lib -lssl -lcrypto'
          make
          make install
 
          tempdir: [/root/ postfix-2.4.5]
          config_directory: [/etc/postfix]
          daemon_directory: [/usr/libexec/postfix]
          command_directory: [/usr/sbin]
          queue_directory: [/var/spool/postfix]
          sendmail_path: [/usr/sbin/sendmail]
          newaliases_path: [/usr/bin/newaliases]
          mailq_path: [/usr/bin/mailq]
          mail_owner: [postfix]
          setgid_group: [postdrop]
          html_directory: [no]
          manpages: [/usr/local/man]
          readme_directory: [no]
          上面的选项全部保持默认,直接回车即可。 
         事先要执行:echo “/usr/local/ssl/lib” >> /etc/ld.so.conf
                 ldconig 避免出现错误
         生成别名二进制文件,这个步骤如果忽略,会造成 postfix 效率极低:
 
         newaliases
         配置 postfix
         vi /etc/postfix/main.cf
         myhostname = mail.wlq.com
         mydomain = wlq.com
         myorigin = $mydomain
         inet_interfaces = all
         mynetworks = 192.168.1.0/24, 127.0.0.0/8
                         #================Virtual Setting ====================
          virtual_mailbox_base = /var/mailbox/
          virtual_mailbox_maps=
mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf
         
virtual_mailbox_domains=mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf
          virtual_alias_domains =
          virtual_alias_maps =
mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf
          virtual_uid_maps = static:2525
          virtual_gid_maps = static:2525
          virtual_transport = virtual
          maildrop_destination_recipient_limit = 1
          maildrop_destination_concurrency_limit = 1
                         #=================Quota Setting ====================
          message_size_limit = 14336000
          virtual_mailbox_limit = 20971520
          virtual_create_maildirsize = yes
          virtual_mailbox_extended = yes
          virtual_mailbox_limit_maps
          mysql:/etc/postfix/mysql/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
                             #===================
Cyrus-sasl=====================
          broken_sasl_auth_clients = yes
           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 = Welcome to our $myhostname ESMTP, Warning:Version not
Available!
            local_recipient_maps =
(也要填加这一条,我也是最后在web界面发邮件时老报local_recipient的错,填加这一条后就好了)
 
           # mkdir -p /etc/postfix/mysql
          cd /etc/postfix/mysql
          vi mysql_virtual_alias_maps.cf
          user = extmail
          password = extmail
          hosts = localhost
         dbname = extmail
         table = alias
         select_field = goto
         where_field = address
 
         vi mysql_virtual_mailbox_limit_maps.cf
         user = extmail
         hosts = localhost
         dbname = extmail
         table = mailbox
        select_field = quota
        where_field = username
    
       vi mysql_virtual_domains_maps.cf
       user = extmail
       password = extmail
       hosts = localhost
       dbname = extmail
        table = domain
        select_field = description
        where_field = domain
       vi mysql_virtual_mailbox_maps.cf
        user = extmail
        password = extmail
        hosts = localhost
        dbname = extmail
        table = mailbox
        select_field = maildir
        where_field = username
 
     9、安装 Courier-IMAP
        tar –xvjf courier-imap-4.2.0.tar.bz2
        cd courier-imap-4.2.0
       ./configure --prefix=/usr/local/imap --with-redhat --enable-unicode
--disable-root-check --with-trashquota
CPPFLAGS='-I/usr/local/ssl/include/openssl -I/usr/local/authlib/include'
LDFLAGS='-L/usr/local/authlib/lib/courier-authlib'
COURIERAUTHCONFIG='/usr/local/authlib/bin/courierauthconfig'
        make
        make install
        cp /usr/local/imap/etc/imapd.dist /usr/local/imap/etc/imapd
        cp /usr/local/imap/etc/imapd-ssl.dist /usr/local/imap/etc/imapd-ssl
        cp /usr/local/imap/etc/pop3d.dist /usr/local/imap/etc/pop3d
        cp /usr/local/imap/etc/pop3d-ssl.dist /usr/local/imap/etc/pop3d-ssl
        vi /usr/local/imap/etc/pop3d
        POP3DSTART=YES
        注:如果你想为用户提供 IMAP
服务,则需在"/usr/local/courier-imap/etc/imapd"文件中设置"IMAPDSTART=yes";其它类同;
        新建虚拟用户邮箱所在的目录,并将其权限赋予 postfix 用户:
         mkdir -p /var/mailbox
         chown -R postfix /var/mailbox
         cp courier-imap.sysvinit /etc/rc.d/init.d/imapd
         chmod 755 /etc/rc.d/init.d/imapd
         chkconfig --add imapd
         chkconfig --level 2345 imapd on
          service imapd start
 
 10、安装 extmail
         tar –xvf extmail-1.1.0.tar.gz
         mkdir -pv /var/www/extsuite
         mv extmail-1.1.0 /var/www/extsuite/extmail
         cp /var/www/extsuite/extmail/webmail.cf.default
/var/www/extsuite/extmail/webmail.cf
          vi /var/www/extsuite/extmail/webmail.cf  (下列选项为修改后的)
         SYS_MESSAGE_SIZE_LIMIT = 5242880 用户可以发送的最大邮件
         SYS_USER_LANG = zh_CN
         SYS_MAILDIR_BASE = /var/mailbox/  用户邮件的存放目录
         SYS_MYSQL_USER = extmail
         SYS_MYSQL_PASS = extmail
         以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库
         SYS_MYSQL_HOST = localhost    指明数据库服务器主机名
         SYS_MYSQL_SOCKET = /tmp/mysql.sock 连接数据库的 sock 文件位置
         SYS_MYSQL_TABLE = mailbox
         SYS_MYSQL_ATTR_USERNAME = username
         SYS_MYSQL_ATTR_DOMAIN = domain
         SYS_MYSQL_ATTR_PASSWD = password
         以上用来指定验正用户登录里所用到的表,以及用户名、域名和用户密码分别对应的表中列的名称
         SYS_AUTHLIB_SOCKET =
/usr/local/courier-authlib/var/spool/authdaemon/socket
         指明 authdaemo socket 文件的位置

          apache 相关配置
          [root @test root] # vi /usr/local/apache/conf/httpd.conf
         将 User daemon
              Group daemon
         改为
               User postfix
               Group postfix
          将 Include conf/extra/httpd-vhosts.conf
          前的注释去掉,打开 apache 的虚拟主机功能。
          # virtual hosts
          Include conf/extra/httpd-vhosts.conf
           vi /usr/local/apache/conf/extra/httpd-vhosts.conf
          <VirtualHost *:80>
         ServerName mail.wlq.com
         DocumentRoot /var/www/extsuite/extmail/html/
         ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
         Alias /extmail /var/www/extsuite/extmail/html
        </VirtualHost>
         <Directory "/var/www/extsuite">
         Options Indexes FollowSymLinks
         AllowOverride None
         Order allow,deny
         Allow from all
       </Directory>
 
     11、安装 Unix-Syslog-1.1.tar.gz和DBD-mysql-2.9008.tar.gz
         extmail 将会用到 perl 的 DBD::Mysql 和 Unix::syslogd 功能,
您可以去
http://search.cpan.org下载
         tar -zxvf Unix-Syslog-1.1.tar.gz
         cd Unix-Syslog-1.1
         perl Makefile.PL
         make
         make install
 
          tar –xvzf DBD-mysql-2.9008.tar.gz
          cd DBD-mysql-2.9008
          perl Makefile.PL
          make && make install
          到此为止,Webmail 已经可以使用了,可以在浏览器中输入指定的虚拟主机的 名称进行访问,
http://mail.wlq.com
(做测试可以事先在机子上解析这个域名,加到hosts,也可以搭个dns)

    
    12、安装extman-0.2.5.tar.gz
       tar –xvzf extman-0.2.5.tar.gz
       mv extman-0.2.5 /var/www/extsuite/extman
       vi /var/www/extsuite/extman/webman.cf (修改后的选项)
      SYS_MAILDIR_BASE = /var/mailbox/
      SYS_MYSQL_SOCKET = /tmp/mysql.sock
      使用 extman 源码目录下 docs 目录中的 extmail.sql 和 init.sql 建立数据库:
      cd /var/www/extsuite/extman/docs
      /usr/local/mysql/bin/mysql -u root    < extmail.sql
      /usr/local/mysql/bin/mysql    -u root -p < init.sql
      Enter password: 输入 mysql root 用户的密码
     修改 cgi 目录的属主:
       chown -R postfix.postfix /var/www/extsuite/extman/cgi/
      如果 extman 访问数据库权限不足的话,可采用以下命令将新生成的数据库赋予 webman
      /usr/local/mysql/bin/mysql
      mysql> use extmail;
      mysql>   GRANT   all   privileges   on   extmail.*   TO   
webman@localhost
  IDENTIFIED   BY  'webman';
      mysql>   GRANT   all   privileges   on   extmail.*   TO   
webman@127.0.0.1
  IDENTIFIED   BY   'webman';
      mysql> quit
      在 apache 的虚拟主机配置文件中 Extmail 的虚拟主机部分,再添加如下两行:
      vi /usr/local/apache/conf/extra/httpd-vhosts.conf
      ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
      Alias /extman /var/www/extsuite/extman/html
      启动所有服务: (已启动的可以重启下)
       service mysqld start
       /usr/local/apache/bin/apachectl start
       service courier-authlib start
       service imapd start
        postfix start
       在 IE 浏览器中输入
http://mail.wlq.com/extman ,进入邮件服务器的后台,添加域与添加
用户邮箱。默认管理帐号为:
root@extmail.org 密码为:extmail*123*。我这里添加了一 个 wlq.com
域和一个用户邮箱:ceshi@wlq.com。至于开通邮件服务器自动注册邮箱服务,只需要编辑该域,将"允许自由注册邮箱"前面打上勾即可。
         第一次登录可能出现如下错误:
  

        这是由于 /tmp/extman 目录的原因,新建之即可,然后将该目录权限设置为 777
       (1) 如果您安装后无法正常显示校验码,安装 perl-GD 模块会解决这个问题。如果想简单您   可   以   到   以   下   地  
址   下   载   适   合   您   的包   ,   安   装平   台   的    rpm即可
http://dries.ulyssis.org/rpm/packages/perl-GD/info.html
(我用的perl-GD-2.35-1.el5.rf.i386.rpmperl-GD-2.35-1.el5.rf.i386.rpm)
       (2) extman-0.2.2 自带了图形化显示日志的功能;此功能需要 rrdtool 的支持,您需要安装
这些模块才可能正常显示图形日志。
         接下来安装图形日志的运行所需要的软件包 Time::HiRes、File::Tail 和 rrdtool,其中前两个
包 您 可 以 去   
http://search.cpan.org   搜 索 并 下 载 获 得 , 后 一 个 包 您 可 以 到
http://oss.oetiker.ch/rrdtool/pub/?M=D 下载获得; 注意安装顺序不能改换。
 
        下面安装 Time::HiRes 、File::Tail 和 rrdtool
         tar zxvf Time-HiRes-1.9721.tar.gz
        cd Time-HiRes-1.9721
        perl Makefile.PL
        make
        make test
        make install
 
          tar zxvf File-Tail-0.99.3.tar.gz
          cd File-Tail-0.99.3
          perl Makefile.PL
          make
          make test
          make install
         在安装 rrdtool 之前,就确定你的系统中是否已经安装 tcl、tcl-devel、libart、libart-devel
         tar zxvf rrdtool-1.2.23.tar.gz
         cd rrdtool-1.2.23
         ./configure --prefix=/usr/local/rrdtool
         make
         make install
         创建必要的符号链接(Extman 会到这些路径下找相关的库文件)
         ln –s
/usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/auto/RRDs/RRDs.so
/usr/lib/perl5/5.8.5/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 /var/www/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
        接下来就可以到 extman里面的全部东西了
         
http://mail.wlq.com/extman
      

           

           

          

       测试:在web界面中收信,发信都正常,用telnet测试下smtp和pop3
       用户名:
ceshi@wlq.com       密码:ceshi
       用下列命令获得BASE64 编码
       [root@mail ~]# perl -e 'use MIME::Base64;print
encode_base64("ceshi\@wlq.com")'
        Y2VzaGlAd2xxLmNvbQ==
       [root@mail ~]# perl -e 'use MIME::Base64;print encode_base64("ceshi")'
        Y2VzaGk=
 
       telnet localhost 25
       Trying 127.0.0.1...
       Connected to wlq.com (127.0.0.1).
       Escape character is '^]'.
       220 Welcome to our mail.wlq.com ESMTP,Warning:Version not Available!
       ehlo mail.wlq.com
       250-mail.wlq.com
       250-PIPELINING
       250-SIZE 14336000
       250-VRFY
       250-ETRN
       250-AUTH PLAIN LOGIN
       250-AUTH=PLAIN LOGIN
       250-ENHANCEDSTATUSCODES
       250-8BITMIME
       250 DSN
       auth login
       334 VXNlcm5hbWU6
       Y2VzaGlAd2xxLmNvbQ==
       334 UGFzc3dvcmQ6
       Y2VzaGk=
       235 2.0.0 Authentication successful
       quit
       221 2.0.0 Bye
       Connection closed by foreign host.
 
       telnet localhost 110
       Trying 127.0.0.1...
       Connected to wlq.com (127.0.0.1).
       Escape character is '^]'.
       +OK Hello there.
       user 
ceshi@wlq.com
       +OK Password required.
       pass ceshi
       +OK logged in.
        quit
       +OK Bye-bye.
       Connection closed by foreign host. (上面红色部分为手动输入)
       测试authlib
        /usr/local/authlib/sbin/authtest -s login 
ceshi@wlq.com ceshi
        Authentication succeeded.
        Authenticated: 
ceshi@wlq.com (uid 2525, gid 2525)
        Home Directory: /var/mailbox/wlq.com/ceshi
        Maildir: (none)
        Quota: (none)
        Encrypted Password: $1$Zv/N0qB1$kMAqtkM2L5CiVt8d05FzU/
        Cleartext Password: ceshi
        Options: (none)
 
     13、安装maildorp-2.0.4.tar.bz2
        首先将courier-authlib的头文件及库文件链接至/usr目录(编译maildrop时会到此目录下找此些相关      的文件):
        ln -sv /usr/local/authlib/bin/courierauthconfig   /usr/bin
        ln -sv /usr/local/authlib/include/*   /usr/include
        maildrop需要pcre的支持,因此,接下来将首先安装pcre
        tar jxvf pcre-7.2.tar.bz2
       cd pcre-7.2
        ./configure
       make 
       make check
       make install
        groupadd -g 1001 vmail
        useradd -g vmail -u 1001 -M -s /sbin/nologin vmail
        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=1001  --enable-maildrop-gid=1001 --with-trashquota
--with-dirsync
        make
        make install
        安装过程中要有这个错误/usr/bin/install: cannot stat `makedat/makedatprog': No such
file or directory时,应检查gbdm和gbdm-devel包,安这两包后就可以了
 
         检查安装结果,请确保有"Courier Authentication Library extension enabled."一句出现:
         # maildrop -v
         maildrop 2.0.4 Copyright 1998-2005 Double Precision, Inc.
         GDBM extensions enabled.
          [color=DarkOrange]Courier Authentication Library extension
enabled.[/color]
          Maildir quota extension enabled.
          This program is distributed under the terms of the GNU General Public
           License. See COPYING for additional information.
         vi /etc/maildroprc (新建)
         logfile "/var/log/maildrop.log"
         touch /var/log/maildrop.log
        chown vmail.vmail /var/log/maildrop.log
         配置 postfix,
         vi /etc/postfix/master.cf
        启用下面这两行,将前面的注释符号去掉
        maildrop    unix    -             n             n              -        
    -            
         pipe  flags=DRhu user=vmail                  
argv=/usr/local/maildrop/bin/maildrop -d ${recipient}
 
         vi /etc/postfix/main.cf
        将 virtual_transport = virtual 修改为  virtual_transport = maildrop
         virtual_uid_maps = static:1001
         virtual_gid_maps = static:1001
         vi /usr/local/ authlib/etc/authlib/authmysqlrc
        下面两个修改为
         MYSQL_UID_FIELD  ‘1001’
         MYSQL_GID_FIELD   ‘1001’
         vi /usr/local/apache/conf/httpd.conf (下面选项修改为如下的值)
         User vmail
         Group vmail
         修改用户邮件所在目录 /var/mailbox 和 extman 的临时目录 /tmp/extman 的属主和属组
         chown -R vmail.vmail /var/mailbox
         chown -R vmail.vmail /tmp/extman
          重新启动 apache 和 postfix,在web界面发送一份邮件测试,tail -f /var/log/maillog中看到的日志,
Oct 27 09:45:05 mail postfix/pipe[21265]: 71D4C3674EE: to=<
ceshi@wlq.com>,
relay=maildrop, delay=486, delays=485/0.08/0/0.25, dsn=4.3.0, status=deferred
(temporary failure. Command output: /usr/local/bin/maildrop: Unable to open
mailbox. )
Oct 27 09:45:35 mail maildrop[21273]: Unable to open mailbox.
           报错,在网上找了找,发现在/etc/maildroprc中少了一行,加了这行,测试就OK
           [root@mail mailbox]# vi /etc/maildroprc
           logfile "/var/log/maildrop.log"
           to "$HOME/Maildir" (新加的一行)
           再测试:tail –f /var/log/maillog
Oct 27 09:47:16 mail postfix/pipe[21306]: 8D2D03674F9: to=<
ceshi@wlq.com>,
relay=maildrop, delay=0.96, delays=0.2/0.05/0/0.7, dsn=2.0.0, status=sent
(delivered via maildrop service)
Oct 27 09:47:16 mail postfix/qmgr[20843]: 8D2D03674F9: removed
          [root@mail mailbox]# tail -f /var/log/maildrop.log
          Date: Wed Oct 27 09:46:33 2010
          From:
          Subj: 
          File: /var/mailbox/wlq.com/ceshi/Maildir    

         测试成功,说明Maildrop安装成功,到此为止,邮件系统的搭建基本完成,接下来安装反病毒和反垃圾邮件的相关组件,下篇接着弄