安装基于虚拟用户的虚拟域邮件服务器系统


一、安装postfix(由于邮件服务依赖于DNS服务, 首先需要确保已经配置好了DNS服务服务器)
1、关闭sendmail,并将它的随系统自动启动功能关闭:
shell> service sendmail stop
shell> chkconfig sendmail off

2、安装postfix依赖的软件mysql(此处的版本为mysql-5.5.39,下载网站http://www.mysql.com/)
# 增加mysql用户和mysql组
shell> groupadd mysql
shell> useradd -r -g mysql -M -s /sbin/nologin mysql
# 解压mysql安装包并创建链接文件
shell> tar -xf mysql-5.5.39-linux2.6-i686.tar.gz -C /usr/local/
shell> ln -s /usr/local/mysql-5.5.39-linux2.6-i686 /usr/local/mysql
# 修改mysql目录中所有的文件的宿主和属组为mysql
shell> cd /usr/local/mysql
shell> chown -R mysql:mysql .
# 初始化mysql数据库
shell> scripts/mysql_install_db --user=mysql
# 修改mysql目录中所有的文件的宿主为root
shell> chown -R root .
# 修改mysql目录中data文件的宿主为mysql
shell> chown -R mysql data
# 复制mysql的主配置文件
shell> cp support-files/my-medium.cnf /etc/my.cnf
# 复制mysql的服务脚本
shell> cp support-files/mysql.server /etc/init.d/mysqld
# 将mysql的服务脚本加到服务列表中并在默认级别开启服务
shell> chkconfig --add mysqld
shell> chkconfig mysqld on
# 将mysql的二进制文件增加到系统环境变量中
shell> vim /etc/profile.d/mysql.sh
  增加 export PATH=$PATH:/usr/local/mysql/bin
# 将mysql的库文件增加到系统库中
shell> vim /etc/ld.so.conf.d/mysql.conf
  增加 /usr/local/mysql/lib
shell> idconfig -v
# 将mysql的头文件增加到系统库中
shell> ln -s /usr/local/mysql/include/ /usr/include/mysql
# 启动mysql服务
shell> service mysqld start

3、安装postfix依赖的软件sasl服务(此处的使用cyrus-sasl,使用系统提供的yum源安装)
# 安装cyrus-sasl
shell> yum incyrus-sasl cyrus-sasl-devel cyrus-sasl-libstall cyrus-sasl-plain
# 启动saslauthd服务,并将其加入到自动启动队列
shell> service saslauthd start
shell> chkconfig saslauthd on

4、安装配置postfix (此处使用的版本是postfix-2.11.1,下载网站http://www.postfix.org/)
# 增加postfix和postdrop用户和组
shell> groupadd -g 2525 postfix
shell> groupadd -g 2526 postdrop
shell> useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
shell> useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
# 解压postfix安装包
shell> tar -xf postfix-2.11.1.tar.gz
shell> cd postfix-2.11.1
# 配置postfix选项 (可参看
http://www.linuxfromscratch.org/blfs/view/svn/server/postfix.html)
shell>
  make  CCARGS='-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl  \
  -DHAS_MYSQL -I/usr/include/mysql  \
  -DUSE_TLS -I/usr/include/openssl' \
 AUXLIBS='-L/usr/lib/sasl2 -lsasl2  \
   -L/usr/local/mysql/lib -lmysqlclient -lz -lm  \
   -lssl -lcrypto'  \
 makefiles
# 编译postfix
shell> make 
# 安装postfix
shell> make install
  按照以下的提示输入相关的路径([]号中的是缺省值,”]”后的是输入值,省略的表示采用默认值)
  --------------------------------------------

  install_root: [/]
  tempdir: [/root/postfix-2.9.3] /tmp/postfix
  config_directory: [/etc/postfix] /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]/var/www/html/postfix 
   manpages: [/usr/local/man]
   readme_directory: [no]

  --------------------------------------------
# postfix 安装成功后可以进行阶段测试
shell> postfix start
       postfix/postfix-script: starting the Postfix mail system
shell> netstat -tnpl | grep "master"
       tcp 0 0 0.0.0.0:25 0.0.0.0:*    LISTEN 13058/master
# 生成别名二进制文件,此命令会在etc下生成aliaess和aliases.db文件,aliaess是postfix的默认别名表
shell> newaliases 
# 修改postfix配置文件
shell> vim /etc/postfix/main.cf
  配置文件详解:
    /etc/postfix/master.cf  由于Postfix是模块化设计.所有master用于定义加载哪些模块并且主进程的参数
    /etc/postfix/main.cf  用于定义每个模块的参数信息的配置文件
    postconf命令:
      -d: 显示默认的配置
      -n:显示修改过的配置
      -m:显示支持查找表的类型
      -A: 客户端支持的SASL插件类型
      -a: 服务器端支持的SASL插件类型
      -e PARA=VALUE:  更改某参数配置信息,并保存至main.cf文件中
  修改以下几项为您需要的配置:
    myhostname = mail.spook.com
    myorigin = spook.com
    mydomain = spook.com
    mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
    mynetworks = 192.168.246.0/24, 127.0.0.0/8
  说明:
    myhostname 参数指定运行postfix邮件系统的主机的主机名,默认情况下,其值被设定为本地机器名;
    myorigin   参数用来指明发件人所在的域名,即做发件地址伪装;
    mydomain   参数指定您的域名,默认情况下,postfix将myhostname的第一部分删除而作为mydomain的值;
    mydestination 参数指定postfix接收邮件时收件人的域名,即您的postfix系统要接收到哪个域名的邮件;
    mynetworks    参数指定你所在的网络的网络地址,postfix系统根据其值来区别用户是本地的还是远程的,

    inet_interfaces 参数指定postfix系统监听的网络接口
  注意:
    1、在postfix的配置文件中,参数行和注释行是不能处在同一行中的;
    2、任何一个参数的值都不需要加引号,否则,引号将会被当作参数值的一部分来使用;        
    3、每修改参数及其值后执行 postfix reload 即可令其生效;但若修改了inet_interfaces,则需重新启动  

      postfix
    4、如果一个参数的值有多个,可以将它们放在不同的行中,只需要在其后的每个行前多置一个空格即可;postfix会把第一

      个字符为空格或tab的文本行视为上一行的延续;
# 为postfix提供SysV服务脚本/etc/rc.d/init.d/postfix,内容如下(#END 之前)
shell>
    #!/bin/bash
    # 
    # postfix      Postfix Mail Transfer Agent
    #
    # chkconfig: 2345 80 30
    # description: Postfix is a Mail Transport Agent, which is the program \
    #              that moves mail from one machine to another.
    # processname: master
    # pidfile: /var/spool/postfix/pid/master.pid
    # config: /etc/postfix/main.cf
    # config: /etc/postfix/master.cf

    # Source function library.
    . /etc/rc.d/init.d/functions

    # Source networking configuration.
    . /etc/sysconfig/network

    # Check that networking is up.
    [ $NETWORKING = "no" ] && exit 3

    [ -x /usr/sbin/postfix ] || exit 4
    [ -d /etc/postfix ] || exit 5
    [ -d /var/spool/postfix ] || exit 6

    RETVAL=0
    prog="postfix"

    start() {
        # Start daemons.
        echo -n $"Starting postfix: "
        /usr/bin/newaliases >/dev/null 2>&1
        /usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
        echo
        return $RETVAL
    }

    stop() {
      # Stop daemons.
        echo -n $"Shutting down postfix: "
        /usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
        echo
        return $RETVAL
    }

    reload() {
        echo -n $"Reloading postfix: "
        /usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
        RETVAL=$?
        echo
        return $RETVAL
    }

    abort() {
        /usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
        return $?
    }

    flush() {
        /usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
        return $?
    }

    check() {
        /usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
        return $?
    }

    restart() {
        stop
        start
    }

    # See how we were called.
    case "$1" in
      start)
        start
        ;;
      stop)
        stop
        ;;
      restart)
        stop
        start
        ;;
      reload)
        reload
        ;;
      abort)
        abort
        ;;
      flush)
        flush
        ;;
      check)
        check
        ;;
      status)
        status master
        ;;
      condrestart)
        [ -f /var/lock/subsys/postfix ] && restart || :
        ;;
      *)
        echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
        exit 1
    esac

    exit $?

    # END

# 为此脚本赋予执行权限:
shell> chmod +x /etc/rc.d/init.d/postfix
# 将postfix服务添加至服务列表:
shell> chkconfig --add postfix
# 设置其开机自动启动:
shell> chkconfig postfix on
# 使用此脚本重新启动服务,以测试其能否正常执行:
shell> service postfix restart

# 测试是否可以正常发送邮件,测试代码如下:
    #telnet mail.spook.com 25
    #ehlo hello
    #mail from:eric@spook.com
    #rcpt to:tom@spook.com
    #data
    #subject:title
    #content
    #.
    #quit
  查看/var/log/maillog 确定postfix邮件是否已经发出.
  注意:1. eric和spook都必须是系统用户.
        2. /etc/resolv.conf中配置的DNS服务器必须mail.spook.com所在的域.
        3. postfix默认把本机的IP地址所在的网段识别为本地网络,并且为之中继邮件

二、配置测试cyrus-sasl
# cyrus-sasl已经安装,这里只需要启动即可
shell> service saslauthd start
# 使用saslauthd -v 可以查看cyrus-sasl支持的验证方式,默认为pam,这里我们使用shadow
shell> vim /etc/sysconfig/saslauthd
  修改MECH=pam为MECH=shadow
# selinux如果开启会影响显示验证失败,使用下面的命令可以解决
shell> setsebool -P allow_saslauthd_read_shadow 1
# 单独测试sasl验证功能
shell> service saslauthd restart
shell> testsaslauthd -u tom -p tom
  显示 0: OK "Success."

三、为postfix开启基于cyrus-sasl的认证功能(postfix + SASL 用户认证)
# 确定postfix是否支持cyrus风格的sasl认证
shell> postconf -a
  显示中cyrus选项表示支持
# 修改postfix配置文件,让postfix支持sasl
shell> vim /etc/postfix/main.cf
  添加以下内容:
    ############################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
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain = $myhostname
    smtpd_sasl_security_options = noanonymous
    smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
    smtpd_sasl_path = smtpd
# 增加smtpd.conf配置文件,让cyrus-sasl支持postfix
shell> vim /usr/lib/sasl2/smtpd.conf
  添加以下内容:
    log_level: 3
    pwcheck_method: saslauthd
    mech_list: PLAIN LOGIN
# 让postfix重新加载配置文件
shell> service postfix reload
# 测试基于sasl验证是否可以正常发送邮件
shell> telnet 192.168.246.130 25
    Trying 192.168.246.130...
    Connected to mail.spook.com (192.168.246.130).
    Escape character is '^]'.
    220 Welcome to our mail.spook.com ESMTP,Warning: Version not Available!
    ehlo hello
    250-mail.spook.com
    250-PIPELINING
    250-SIZE 10240000
    250-VRFY
    250-ETRN
    250-AUTH LOGIN PLAIN
    250-AUTH=LOGIN PLAIN             (请确保您的输出以类似两行)
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250 DSN
    auth login                       (基于用户的验证需要登录)
    334 VXNlcm5hbWU6
    dG9t                             (用户名使用base64编码)
    334 UGFzc3dvcmQ6
    dG9t                             (密码使用base64编码)
    235 2.7.0 Authentication successful
    mail from:tom@spook.com
    250 2.1.0 Ok
    rcpt to:eric@spook.com
    250 2.1.5 Ok
    data
    354 End data with <CR><LF>.<CR><LF>
    subject:title
    content
    .
    250 2.0.0 Ok: queued as CC51A57011B
    quit
    221 2.0.0 Bye
    Connection closed by foreign host.
# 查看eric是否收到tom的邮件
shell> cat /var/mail/eric

四、安装配置courier-authlib
# 安装Courier authentication library依赖的库
shell> yum install libtool-ltdl libtool-ltdl-devel
# 解压courier-authlib的安装包
shell> tar jxvf courier-authlib-0.64.0.tar.bz2
shell> cd courier-authlib-0.64.0
# 配置courier-authlib选项
shell> ./configure \
    --prefix=/usr/local/courier-authlib \
    --sysconfdir=/etc \
    --without-authpam \
    --without-authshadow \
    --without-authvchkpw \
    --without-authpgsql \
    --with-authmysql=/usr/locl/mysql/lib \
    --with-mysql-libs=/usr/local/mysql/lib \
    --with-mysql-includes=/usr/local/mysql/include \
    --with-redhat \
    --with-authmysqlrc=/etc/authmysqlrc \
    --with-authdaemonrc=/etc/authdaemonrc \
    --with-mailuser=postfix \
    --with-mailgroup=postfix \
    --with-ltdl-lib=/usr/lib \
    --with-ltdl-include=/usr/include \
    --with-authdaemonvar=/var/spool/authdaemon
备注:--with-authdaemonvar=/var/spool/authdaemon选项来指定进程套按字目录路径
# 编译安装
shell> make && make install
# 修改 authdaemon文件的权限
shell> chmod 755 /var/spool/authdaemon
# 复制主配置文件
shell> cp ./authdaemonrc  /etc/authdaemonrc
# 修改主配置文件
shell> vim /etc/authdaemonrc
  修改以下的内容为:
    authmodulelist="authmysql"
    authmodulelistorig="authmysql"
    daemons=10
# 复制与mysql连接的配置文件
shell> cp ./authmysqlrc  /etc/authmysqlrc
# 通过配置authmysqlrc配置文件对mysql进行邮件帐号认证
shell> vim /etc/authmysqlrc
  修改以下的内容为:  和GID。
    MYSQL_SERVER localhost               (数据库的所在位置)
    MYSQL_USERNAME  extmail              (数据库的所有者的用户名)
    MYSQL_PASSWORD extmail               (数据库的所有者的密码)
    MYSQL_PORT 3306                      (指定你的mysql监听的端口,这里使用默认的3306)
    MYSQL_SOCKET  /tmp/mysql.sock        (mysql套接字文件, 自定义安装的mysql默认安装在/tmp/mysql.sock, 默认安装在/var/lib/mysql/mysql.sock目录下)
    MYSQL_DATABASE  extmail
    MYSQL_USER_TABLE  mailbox
    MYSQL_CRYPT_PWFIELD  password
    MYSQL_UID_FIELD  2525              (用户的UID)
    MYSQL_GID_FIELD  2525              (用户的GID)
    MYSQL_LOGIN_FIELD  username
    MYSQL_HOME_FIELD  concat('/var/mailbox/',homedir)
    MYSQL_NAME_FIELD  name
    MYSQL_MAILDIR_FIELD  concat('/var/mailbox/',maildir)
# 提供SysV服务脚本
shell> cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
shell> chmod 755 /etc/init.d/courier-authlib
shell> chkconfig --add courier-authlib
shell> chkconfig --level 2345 courier-authlib on
shell> echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
shell> ldconfig -v
shell> service courier-authlib start

五、配置postfix结合courier-authlibshix实现数据库用户验证
# 新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户
shell> mkdir –pv /var/mailbox
shell> chown -R postfix /var/mailbox
# 让postfix支持虚拟域和虚拟用户
shell> vim /etc/postfix/main.cf
  添加如下内容:其中mysql_virtual_*文件后面在安装extman时会提供
    ########################Virtual Mailbox Settings########################
    virtual_mailbox_base = /var/mailbox
    virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
    virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
    virtual_alias_domains =
    virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
    virtual_uid_maps = static:2525
    virtual_gid_maps = static:2525
    virtual_transport = virtual
    ##########################QUOTA Settings########################
    message_size_limit = 14336000
    virtual_mailbox_limit = 20971520
# 配置cyrus-sasl基于courier-authlib进行用户验证
shell> vim /usr/lib/sasl2/smtpd.conf
  修改内容为:
    pwcheck_method: authdaemond
    log_level: 3
    mech_list:PLAIN LOGIN
    authdaemond_path:/var/spool/authdaemon/socket
注意:启用虚拟域以后,需要取消中心域,即注释掉myhostname, mydestination, mydomain, myorigin几个指令.
    你也可以把mydestionation的值改为你自己需要的

六、配置安装extman和extmail
1、安装配置extman
# 解压
shell> tar -zvxf  extman-1.1.tar.gz
shell> cd extman-1.1/docs
# 如果是mysql5.1以上版本需要执行以下内容
shell> sed -i
's@TYPE=MyISAM@ENGINE=InnoDB@g' extmail.sql
# 导入数据库
shell> mysql -u root -p < extmail.sql
# 导入数据
shell> mysql -u root -p <init.sql
# 服务为postfix连接数据库需要的文件
shell> cp mysql_*  /etc/postfix/
# 授予用户extmail访问extmail数据库的权限(同时也创建用户)
shell> mysql
mysql> GRANT all privileges on extmail.* TO
extmail@localhost IDENTIFIED BY 'extmail';
mysql> GRANT all privileges on extmail.* TO
extmail@127.0.0.1 IDENTIFIED BY 'extmail';
# 复制extman的核心代码
shell> cd ../..
shell> mkdir -pv /var/www/extsuite
shell> tar -zvxf  extman-1.1.tar.gz -C /var/www/extsuite/
shell> mv /var/www/extsuite/extman-1.1/ /var/www/extsuite/extman
# 修改配置文件以符合本例的需要
shell> cp /var/www/extsuite/extman/webman.cf.default  /var/www/extsuite/extman/webman.cf
shell> vim /var/www/extsuite/extman/webman.cf
    SYS_MAILDIR_BASE = /home/domains
    此处即为您在前文所设置的用户邮件的存放目录,可改作:
    SYS_MAILDIR_BASE = /var/mailbox

    SYS_DEFAULT_UID = 1000
    SYS_DEFAULT_GID = 1000
    此两处后面设定的ID号需更改为前而创建的postfix用户和postfix组的id号,本文使用的是2525,因此,上述两项需要修改为:
    SYS_DEFAULT_UID = 2525
    SYS_DEFAULT_GID = 2525

    SYS_MYSQL_USER = webman
    SYS_MYSQL_PASS = webman
    修改为:
    SYS_MYSQL_USER = extmail
    SYS_MYSQL_PASS = extmail
   
    SYS_MYSQL_SOCKET = /tmp/mysql.sock
    指明数据库sock文件的位置

    SYS_CAPTCHA_ON = 1
    修改为不使用验证码
    SYS_CAPTCHA_ON = 0
# 而后修改cgi目录的属主:
shell> chown -R postfix.postfix /var/www/extsuite/extman/cgi/
# 创建其运行时所需的临时目录,并修改其相应的权限:
shell> mkdir  -pv  /tmp/extman
shell> chown postfix.postfix  /tmp/extman

2、安装配置extmail
# 解压复制
shell> tar -zvxf extmail-1.2.tar.gz
shell> mv extmail-1.2 /var/www/extsuite/extmail
shell> cp /var/www/extsuite/extmail/webmail.cf.default  /var/www/extsuite/extmail/webmail.cf
# 修改主配置文件
shell> vim /var/www/extsuite/extmail/webmail.cf
  部分修改选项的说明:
    SYS_MESSAGE_SIZE_LIMIT = 5242880
    用户可以发送的最大邮件

    SYS_USER_LANG = en_US
    语言选项,可改作:
    SYS_USER_LANG = zh_CN

    SYS_MAILDIR_BASE = /home/domains
    此处即为您在前文所设置的用户邮件的存放目录,可改作:
    SYS_MAILDIR_BASE = /var/mailbox

    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 = /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 = /var/spool/authdaemon/socket
    此句用来指明authdaemo socket文件的位置
# 修改 cgi执行文件属主为apache运行身份用户:
shell> chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
3、安装依赖的httpd和perl服务
# httpd和perl服务服务redhat5.8已经安装好了我们直接启动就可以,
# 安装extmail用到perl的Unix-syslogd功能,这里我们需要安装它(
http://search.cpan.org搜索下载原码包进行安装).
shell> tar zxvf Unix-Syslog-0.100.tar.gz
shell> cd Unix-Syslog-0.100
shell> perl Makefile.PL
shell> make && make install
# 安装extman依赖的perl模块
shell> yum install perl-DBD-MySQL perl-DBI
# 注销中心主机
shell> vim /etc/httpd/conf/httpd.conf
  将DocumentRoot "/var/www/html"注释掉
# 使用虚拟主机配置extmail和extman
shell> vim /etc/httpd/conf.d/vhost.conf
    <VirtualHost *:80>
        ServerName mail.magedu.com
        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
        SuexecUserGroup postfix postfix                         (虚拟主机运行身份的指定)
    </VirtualHost>
# 启动httpd服务
shell> chkconfig --add httpd
shell> chkconfig httpd on
shell> service httpd start

到目前文为止基于postfix+cyrus-sasl+courier-authlib+mysql的WEBMAIL的发送邮件(SMTP)服务已经完成, 需要以下进行测试
1.进行WEBMAIL测试
    后台:
http://mail.spook.com/extman    默认管理帐号为:root@extmail.org  密码为:extmail*123*
    前台:
http://mail.spook.com/extmail
2.进行基于WINDOWS的OE测试
3.由于没有安装收邮件的服务,故可以去查看/var/mailbox是否投递成功

下面进行安装接收邮件的服务(pop3/imap)

七、安装测试dovecot(参看http://wiki2.dovecot.org/CompilingSource)
# 添加用户和组
shell> groupadd -g 1110 dovecot
shell> groupadd -g 2110 dovenull
shell> useradd -u 1110 -g 1110 -M -s /sbin/nologin dovecot
shell> useradd -u 2110 -g 2110 -M -s /sbin/nologin dovenull
# 解压编译安装
shell> tar -xf dovecot-2.2.13.tar.gz
shell> cd dovecot-2.2.13.tar
shell> CPPFLAGS='-I/usr/local/mysql/include' \
        LDFLAGS='-L/usr/local/mysql/lib' \
        ./configure --prefix=/usr/local/dovecot --sysconfdir=/etc --with-ssl=openssl --with-mysql
shell> make && make install
# 复制配置文件
shell> cp -r /usr/local/dovecot/share/doc/dovecot/example-config/* /etc/dovecot/
# 修改配置文件
shell> vim /etc/dovecot/dovecot.conf
  启用protocols = imap pop3
  启用base_dir = /var/mailbox/
  启用login_trusted_networks = 0.0.0.0/0
shell> vim /etc/dovecot/conf.d/10-mail.conf
  添加mail_location = maildir:/var/mailbox/%d/%n/Maildir
shell> vim 10-auth.conf
  注释!include auth-system.conf.ext
  启用!include auth-sql.conf.ext
shell> vim /etc/dovecot/conf.d/auth-sql.conf.ext
  此文件内容如下:
    passdb {
      driver = sql
      args = /etc/dovecot/dovecot-sql.conf.ext
    }

    userdb {
      driver = sql
      args = /etc/dovecot/dovecot-sql.conf.ext
    }
shell> vim /etc/dovecot/dovecot-sql.conf.ext
  添加以下内容:
    driver = mysql
    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 mailbox WHERE name = '%u'
    user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username  = '%u'
shell> vim 10-ssl.conf
  修改 ssl = yes 为 ssl = no
  注释 #ssl_cert = </etc/ssl/certs/dovecot.pem
       #ssl_key = </etc/ssl/private/dovecot.pem
shell> /etc/dovecot/conf.d/10-logging.conf
  启用里面的log信息
# 提供服务脚本
shell> cp ./doc/dovecot-initd.sh /etc/rc.d/init.d/dovecot
shell> vim /etc/rc.d/init.d/dovecot
  修改DAEMON=/usr/local/sbin/dovecot为DAEMON=/usr/local/dovecot/sbin/dovecot
shell> chmod +x /etc/rc.d/init.d/dovecot
shell> chkconfig --add dovecot
shell> chkconfig --list dovecot
shell> service dovecot start
# 测试
shell> telnet mail.spook.com 110
    Trying 192.168.246.130...
    Connected to mail.spook.com (192.168.246.130).
    Escape character is '^]'.
    +OK Dovecot ready.
    USER eric
    +OK
    PASS eric
    +OK Logged in.
    LIST
    +OK 5 messages:
    1 673
    2 695
    3 3548
    4 3482
    5 1491
    .
    quit
    +OK Logging out.
    Connection closed by foreign host.
需测试OE和webmail直间通信是否正常.
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值