CentOS7下搭建postfix邮箱服务器并实现extmail的web访问

闲来无事想着尝试使用postfix搭建一个邮箱服务器,我是边搭建边写这个笔记,搭建过程中遇到坑也会一并记录,使用的系统版本如下:

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

本示例基于LNMP环境。

1. 准备工作

关闭selinux

[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce 
Permissive
[root@localhost ~]#

关闭firewalld防火墙,并清空iptables规则:

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -X
[root@localhost ~]# iptables -nvL
Chain INPUT (policy ACCEPT 38 packets, 7291 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 12 packets, 1208 bytes)
 pkts bytes target     prot opt in     out     source               destination         
[root@localhost ~]#

由于CentOS7默认安装的是MariaDB,所以要添加MySQL的yum源,有些编译需要的devel包只有epel扩展源有,所以我们需要把epel源也一并添加。因为是通过wget命令从下载地址中下载,但是最小化安装的CentOS7不自带wget命令,还需要先安装这个命令:

yum install -y wget
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm

2. 安装postfix

首先需要安装编译环境及其他所需要的包,免得一会编译过程中老报缺少包的错误,因为需要安装的包有点多,所以这个过程有点慢:

yum install nginx vim gcc gcc-c++ openssl openssl-devel db4-devel ntpdate mysql mysql-devel mysql-server bzip2 php-mysql cyrus-sasl-md5 perl-GD perl-DBD-MySQL perl-GD perl-CPAN perl-CGI perl-CGI-Session cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel libtool-ltdl-devel telnet mail libicu-devel  -y

安装完以上所需的包后,开始编译安装postfix:

1)首先卸载系统自带的postfix,并删除postfix用户,重新指定uid、gid创建新用户postfix,postdrop,嫌一条条命令去执行有点麻烦就写成脚本文件去执行:

yum remove postfix -y
userdel postfix
groupdel postdrop
groupadd -g 2525 postfix
useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
groupadd -g 2526 postdrop
useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop

2)下载源码包并解压编译(如果下载地址失效就到官网去找下载连接):

cd /usr/local/src/
wget http://cdn.postfix.johnriley.me/mirrors/postfix-release/official/postfix-3.0.11.tar.gz
tar -zxvf postfix-3.0.11.tar.gz
cd postfix-3.0.11
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lrt -lm -L/usr/lib64/sasl2 -lsasl2   -lssl -lcrypto'
make && make install
echo $?

在make install环节的时候会有个交互式的界面,可以自定义一些目录,我这里只更改了第二项临时文件目录,其他的都选择了默认目录:

Please specify the prefix for installed file names. Specify this ONLY
if you are building ready-to-install packages for distribution to OTHER
machines. See PACKAGE_README for instructions.
install_root: [/] 

Please specify a directory for scratch files while installing Postfix. You
must have write permission in this directory.
tempdir: [/usr/local/src/postfix-3.0.11] /tmp/extmail     // 就只更改这一项为tmp目录,其他的全部默认

Please specify the final destination directory for installed Postfix
configuration files.
config_directory: [/etc/postfix] 

Please specify the final destination directory for installed Postfix
administrative commands. This directory should be in the command search
path of adminstrative users.
command_directory: [/usr/sbin] 

Please specify the final destination directory for installed Postfix
daemon programs. This directory should not be in the command search path
of any users.
daemon_directory: [/usr/libexec/postfix] 

Please specify the final destination directory for Postfix-writable
data files such as caches or random numbers. This directory should not
be shared with non-Postfix software.
data_directory: [/var/lib/postfix] 

Please specify the final destination directory for the Postfix HTML
files. Specify "no" if you do not want to install these files.
html_directory: [no] 

Please specify the owner of the Postfix queue. Specify an account with
numerical user ID and group ID values that are not used by any other
accounts on the system.
mail_owner: [postfix] 

Please specify the final destination pathname for the installed Postfix
mailq command. This is the Sendmail-compatible mail queue listing command.
mailq_path: [/usr/bin/mailq] 

Please specify the final destination directory for the Postfix on-line
manual pages. You can no longer specify "no" here.
manpage_directory: [/usr/local/man] 

Please specify the final destination pathname for the installed Postfix
newaliases command. This is the Sendmail-compatible command to build
alias databases for the Postfix local delivery agent.
newaliases_path: [/usr/bin/newaliases] 

Please specify the final destination directory for Postfix queues.
queue_directory: [/var/spool/postfix] 

Please specify the final destination directory for the Postfix README
files. Specify "no" if you do not want to install these files.
readme_directory: [no]

Please specify the final destination pathname for the installed Postfix
sendmail command. This is the Sendmail-compatible mail posting interface.
sendmail_path: [/usr/sbin/sendmail] 

Please specify the group for mail submission and for queue management
commands. Specify a group name with a numerical group ID that is
not shared with other accounts, not even with the Postfix mail_owner
account. You can no longer specify "no" here.
setgid_group: [postdrop] 

Please specify the final destination directory for Postfix shared-library
files.
shlib_directory: [no]

3)更改目录的属主和属组:

chown -R postfix:postdrop /var/spool/postfix
chown -R postfix:postdrop /var/lib/postfix/
chown root /var/spool/postfix
chown -R root /var/spool/postfix/pid

4)修改postfix的配置文件:

[root@localhost ~]# vim /etc/postfix/main.cf
myhostname = mail.everyoo.com        //设置主机名
mydomain = everyoo.com        //指定域名
myorigin = $mydomain        //指明发件人所在的域名
inet_interfaces =         //all指定postfix系统监听的网络接口
mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain        //指定postfix接收邮件时收件人的域名 [使用虚拟域需要禁用]
mynetworks_style = host        //指定信任网段类型
mynetworks = 192.168.77.1/24, 127.0.0.0/8        //指定信任的客户端
relay_domains = $mydestination        //指定允许中转邮件的域名
alias_maps = hash:/etc/aliases        //设置邮件的别名

5)然后需要在/etc/init.d/目录下提供一个脚本来管理postfix的启动与停止:

[root@localhost /var/www/extsuite/extman]# vim /etc/init.d/postfix

把下面的内容放在/etc/init.d/postfix里面:

#!/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 $?

为脚本添加执行权限,并将服务添加到开机启动项中:

[root@localhost /var/www/extsuite/extman]# chmod +x /etc/init.d/postfix
[root@localhost /var/www/extsuite/extman]# chkconfig --add postfix
[root@localhost /var/www/extsuite/extman]# chkconfig postfix on
[root@localhost /var/www/extsuite/extman]# chown postfix.postfix -R /var/lib/postfix/
[root@localhost /var/www/extsuite/extman]# chown postfix.postfix /var/spool/ -R

3. 安装dovecot

yum安装:

[root@localhost ~]# yum install -y dovecot dovecot-mysql

配置dovecot:

[root@localhost ~]# cd /etc/dovecot/
[root@localhost dovecot]# vim dovecot.conf     //直接在配置文件最后添加即可
protocols = imap pop3
!include conf.d/*.conf
listen = *
base_dir = /var/run/dovecot/
[root@localhost dovecot]# cd conf.d/
[root@localhost conf.d]# vim 10-auth.conf
disable_plaintext_auth = no
[root@localhost conf.d]# vim 10-mail.conf
mail_location = maildir:~/Maildir
mail_location = maildir:/var/mailbox/%d/%n/Maildir
mail_privileged_group = mail
[root@localhost conf.d]# vim 10-ssl.conf
ssl = no
[root@localhost conf.d]# vim 10-logging.conf 
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot.info
log_timestamp = "%Y-%m-%d %H:%M:%S "
[root@localhost conf.d]# cp auth-sql.conf.ext auth-sql.conf
[root@localhost conf.d]# vim auth-sql.conf
passdb {  
    driver = sql        

    # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext  
    args = /etc/dovecot/dovecot-sql.conf.ext
}

userdb {  
    driver = sql  
    args = /etc/dovecot/dovecot-sql.conf.ext
}

编辑dovecot通过mysql认证的配置文件:

[root@localhost conf.d]# vim /etc/dovecot-mysql.conf
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = '%u'

4. 安装courier-authlib

下载解压并编译:

[root@localhost ~]# cd /usr/local/src/
[root@localhost /usr/local/src]#  wget https://sourceforge.net/projects/courier/files/authlib/0.66.2/courier-authlib-0.66.2.tar.bz2
[root@localhost /usr/local/src]# tar -jxvf courier-authlib-0.66.2.tar.bz2
[root@localhost /usr/local/src]# cd courier-authlib-0.66.2
[root@localhost /usr/local/src/courier-authlib-0.66.2]# ./configure --prefix=/usr/local/courier-authlib     --sysconfdir=/etc     --without-authpam     --without-authshadow     --without-authvchkpw     --without-authpgsql     --with-authmysql     --with-mysql-libs=/usr/lib64/mysql     --with-mysql-includes=/usr/include/mysql     --with-redhat     --with-authmysqlrc=/etc/authmysqlrc     --with-authdaemonrc=/etc/authdaemonrc     --with-mailuser=postfix
[root@localhost /usr/local/src/courier-authlib-0.66.2]# make && makeinstall

编译过程中发生了一个错误:

configure: error: The Courier Unicode Library 1.2 appears not to be installed. You may need to install a separate development subpackage, in addition to the main package

这是因为Courier Unicode Library没有安装,我们下载courier-unicode-1.2并编译安装:

[root@localhost ~]# wget https://sourceforge.net/projects/courier/files/courier-unicode/1.2/courier-unicode-1.2.tar.bz2
[root@localhost ~]# tar jxvf courier-unicode-1.2.tar.bz2 
[root@localhost ~]# cd courier-unicode-1.2
[root@localhost courier-unicode-1.2]# ./configure
[root@localhost courier-unicode-1.2]# make && make install

完成Courier Unicode Library的安装后,倒回去再次编译courier-authlib就没问题了

配置courier-authlib:

[root@localhost  courier-authlib-0.66.2]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
[root@localhost  courier-authlib-0.66.2]# cp /etc/authdaemonrc.dist  /etc/authdaemonrc
[root@localhost  courier-authlib-0.66.2]# cp /etc/authmysqlrc.dist  /etc/authmysqlrc
[root@localhost  courier-authlib-0.66.2]# vim /etc/authdaemonrc      //配置文件里的验证方法比较多,我们这里只使用authmysql
authmodulelist="authmysql"
authmodulelistorig="authmysql"
[root@localhost  courier-authlib-0.66.2]# vim /etc/authmysqlrc     //直接添加到配置文件尾部,然后去上面将响应系统默认的注视掉,或者删除即可
MYSQL_SERVER            localhost
MYSQL_USERNAME          extmail
MYSQL_PASSWORD          extmail
MYSQL_SOCKET            /var/lib/mysql/mysql.sock
MYSQL_PORT               3306
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password
DEFAULT_DOMAIN          test.com
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)

courier-authlib添加服务启动脚本及其他:

[root@localhost  courier-authlib-0.66.2]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
[root@localhost  courier-authlib-0.66.2]# chmod +x /etc/init.d/courier-authlib
[root@localhost  courier-authlib-0.66.2]# chkconfig --add courier-authlib
[root@localhost  courier-authlib-0.66.2]# chkconfig courier-authlib on
[root@localhost  courier-authlib-0.66.2]# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
[root@localhost  courier-authlib-0.66.1]# ldconfig
[root@localhost  courier-authlib-0.66.1]# service courier-authlib start
Starting Courier authentication services: authdaemond

smtp以及虚拟用户相关的设置:

[root@localhost ~]# vim /usr/lib64/sasl2/smtpd.conf    //文件不存在,要自己创建
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
[root@localhost ~]# vim /etc/postfix/main.cf
##postfix支持SMTP##
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = ''
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
broken_sasl_auth_clients=yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
##postfix支持虚拟用户##
virtual_mailbox_base = /var/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf   //这里的配置文件需在后面extman
里复制过来
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

5. 安装extmail

下载extmail和extman:

[root@localhost ~]# cd /usr/local/src/
[root@localhost /usr/local/src]# wget http://7xivyw.com1.z0.glb.clouddn.com/extmail-1.2.tar.gz
[root@localhost /usr/local/src]# wget http://7xivyw.com1.z0.glb.clouddn.com/extman-1.1.tar.gz

创建站点目录并解压、重命名extmail包:

[root@localhost /usr/local/src]# mkdir -p /var/www/extsuite
[root@localhost /usr/local/src]# tar -zxvf extmail-1.2.tar.gz -C /var/www/extsuite/
[root@localhost /usr/local/src]# mv /var/www/extsuite/extmail-1.2/ /var/www/extsuite/extmail

更改extmail的配置文件:

[root@localhost ~]# cd /var/www/extsuite/extmail
[root@localhost extmail]# cp webmail.cf.default webmail.cf
[root@localhost extmail]# vim webmail.cf
SYS_SESS_DIR = /tmp/extmail
SYS_UPLOAD_TMPDIR = /tmp/extmail/upload
SYS_USER_LANG = zh_CN
SYS_MIN_PASS_LEN = 8
SYS_MAILDIR_BASE = /var/mailbox
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.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

建立临时文件目录与session目录,并更改权限:

[root@localhost extmail]# mkdir -p /tmp/extmail/upload
[root@localhost extmail]# chown -R postfix.postfix /tmp/extmail/

6. 安装extman

回到extman的下载目录下,解压extman包:

[root@localhost ~]# cd /usr/local/src/
[root@localhost /usr/local/src]# tar -zxvf extman-1.1.tar.gz -C /var/www/extsuite/
[root@localhost /usr/local/src]# cd /var/www/extsuite/
[root@localhost /var/www/extsuite]# mv extman-1.1/ extman

拷贝extman的配置文件:

[root@localhost /var/www/extsuite]# cd extman/
[root@localhost /var/www/extsuite/extman]# cp webman.cf.default webman.cf

更改cgi目录的属主属组:

[root@localhost /var/www/extsuite/extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi/
[root@localhost /var/www/extsuite/extman]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/

导入数据库:

由于数据库不能识别TYPE=MyISAM,所以这里直接导入会出错,需要先编辑extmail.sql数据库文件,将文件中的TYPE=MyISAM更改为ENGINE=MyISAM,共有五处修改:

[root@localhost /var/www/extsuite/extman]# vim docs/extmail.sql
:% s/TYPE/ENGINE/g

我这里导入数据的时候发生了一个错误,提示找不到mysql.sock文件:

[root@localhost /var/www/extsuite/extman]# mysql -uroot < docs/extmail.sql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@localhost /var/www/extsuite/extman]# ls /var/lib/mysql/mysql.sock
ls: 无法访问/var/lib/mysql/mysql.sock: 没有那个文件或目录

解决:然后我去查看了一下/etc/my.cnf文件,发现没问题,socket参数指向的也是 /var/lib/mysql/mysql.sock 这个路径,于是我就重启了mysql服务,然后再尝试就没有报找不到mysql.sock文件的错误了,但是报了另一个错误:

[root@localhost /var/www/extsuite/extman]# mysql -uroot < docs/extmail.sql
ERROR 1364 (HY000) at line 31: Field 'ssl_cipher' doesn't have a default value
[root@localhost /var/www/extsuite/extman]# 

这错误的意思是:字段 ‘ssl密码’ 没有默认值

于是又得去查看一下/etc/my.cnf文件,然后把sql_mode参数给注释掉:

未分类

接着重启mysql服务后,继续导入数据,这次就没问题了:

[root@localhost /var/www/extsuite/extman]# !service
service mysqld restart
Redirecting to /bin/systemctl restart  mysqld.service
[root@localhost /var/www/extsuite/extman]# mysql -uroot < docs/extmail.sql
[root@localhost /var/www/extsuite/extman]# mysql -uroot < docs/init.sql

导入数据成功后再次修改/etc/my.cnf文件,把刚刚注释的那行给去掉注释,不去掉的话,mysql服务可能会出现不能启动的问题:

未分类

数据导入成功后,登录mysql,创建一个mysql数据库用户extmail并授予权限:

[root@localhost /var/www/extsuite/extman]# mysql -uroot
mysql> GRANT ALL ON extmail.* to extmail@'%' identified by 'extmail';      //我这里是直接授予全部权限在任意的IP地址上了,实际情况根据需求而定
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql>

复制之前提到的配置文件:

[root@localhost ~]# cd /var/www/extsuite/extman/docs/
[root@localhost /var/www/extsuite/extman/docs]# cp mysql_virtual_* /etc/postfix/

为extman创建临时目录:

[root@localhost /var/www/extsuite/extman/docs]# mkdir /tmp/extman
[root@localhost /var/www/extsuite/extman/docs]# chown -R postfix.postfix /tmp/extman/

启动postfix、dovecot、saslauthd服务,并查看进程是否正常:

[root@localhost /var/www/extsuite/extman]# service postfix start
Starting postfix (via systemctl):                          [  确定  ]
[root@localhost /var/www/extsuite/extman]# ps aux |grep postfix
root      63586  0.0  0.1  95392  2160 ?        Ss   01:29   0:00 /usr/libexec/postfix/master -w
postfix   63587  0.0  0.2  95448  3808 ?        S    01:29   0:00 pickup -l -t unix -u
postfix   63588  0.0  0.2  95496  3816 ?        S    01:29   0:00 qmgr -l -t unix -u
root      63592  0.0  0.0 112680   976 pts/0    S+   01:33   0:00 grep --color=auto postfix
[root@localhost /var/www/extsuite/extman]#  ss -tnluo | grep :25
tcp    LISTEN     0      100       *:25                    *:*             
[root@localhost /var/www/extsuite/extman]# service dovecot start
Redirecting to /bin/systemctl start  dovecot.service
[root@localhost /var/www/extsuite/extman]# ps aux |grep dovecot
root      63834  0.3  0.0  15652  1484 ?        Ss   02:15   0:00 /usr/sbin/dovecot -F
dovecot   63837  0.0  0.0   9320  1012 ?        S    02:15   0:00 dovecot/anvil
root      63838  0.0  0.0   9448  1164 ?        S    02:15   0:00 dovecot/log
root      63840  0.0  0.1  12464  2196 ?        S    02:15   0:00 dovecot/config
root      63842  0.0  0.0 112680   972 pts/0    S+   02:15   0:00 grep --color=auto dovecot    
[root@localhost /var/www/extsuite/extman]# systemctl start saslauthd
[root@localhost /var/www/extsuite/extman]# ps aux |grep saslauthd
root      63131  0.0  0.0  69648   916 ?        Ss   01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63132  0.0  0.0  69648   676 ?        S    01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63133  0.0  0.0  69648   676 ?        S    01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63134  0.0  0.0  69648   676 ?        S    01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63135  0.0  0.0  69648   676 ?        S    01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63144  0.0  0.0 112680   972 pts/0    S+   01:20   0:00 grep --color=auto saslauthd
[root@localhost /var/www/extsuite/extman]# ps aux |grep courier-authlib
root      61661  0.0  0.0   4316   444 ?        S    00:07   0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/usr/local/courier-authlib/var/spool/authdaemon/pid -start /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61662  0.0  0.0  35512  1796 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61663  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61664  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61665  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61666  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61667  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      63660  0.0  0.0 112680   980 pts/0    S+   02:00   0:00 grep --color=auto courier-authlib

7. 测试

测试虚拟用户:

[root@localhost courier-authlib-0.66.2]# /usr/local/courier-authlib/sbin/authtest -s login [email protected] extmail
Authentication succeeded.                //显示这个表示成功,测试时使用的是[email protected],因为我们导入的数据库init.sql里面自带了这个。
Authenticated: [email protected]  (uid 2525, gid 2525)
Home Directory: /var/mailbox/extmail.org/postmaster  //这里需要注意/var/mailbox这个目录现在我们还没有创建,后面web访问的时候如果没有会报错,所以提前创建。
                    Maildir: /var/mailbox/extmail.org/postmaster/Maildir/
                    Quota: (none)
            Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
                Cleartext Password: extmail
                    Options: (none)
[root@localhost courier-authlib-0.66.2]# mkdir /var/mailbox
[root@localhost courier-authlib-0.66.2]# chown -R postfix.postfix /var/mailbox/

测试smtp发信:

[root@localhost ~]# printf   "[email protected]" | openssl base64
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
[root@localhost ~]#  printf   "extmail" | openssl base64
ZXh0bWFpbA==
[root@localhost ~]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.daen.com ESMTP Postfix
auth login
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334 UGFzc3dvcmQ6
ZXh0bWFpbA==
235 2.7.0 Authentication successful     //成功
quit
221 2.0.0 Bye
Connection closed by foreign host.

8. 启动nginx实现web访问

nginx本身并不能解析cgi,extmail自带了解析cgi的程序,但是有些地方需要修改下:

[root@localhost ~]# vim /var/www/extsuite/extmail/dispatch-init
SU_UID=postfix
SU_GID=postfix

启动dispatch-init:

[root@localhost ~]# /var/www/extsuite/extmail/dispatch-init start
Starting extmail FCGI server...
[root@localhost ~]# /var/www/extsuite/extman/daemon/cmdserver -v -d 
loaded ok

添加nginx虚拟主机:

vim /etc/nginx/conf.d/extmail.conf

文件内容如下:

server {
   listen       8080;
   server_name  mail.everyoo.com;
   index index.html index.htm index.php index.cgi;
   root  /var/www/extsuite/extmail/html/;
   location /extmail/cgi/ {
             fastcgi_pass          127.0.0.1:8888;
             fastcgi_index         index.cgi;
             fastcgi_param  SCRIPT_FILENAME   /var/www/extsuite/extmail/cgi/$fastcgi_script_name;
             include               fcgi.conf;
        }
        location  /extmail/  {
             alias  /var/www/extsuite/extmail/html/;
        }
        location /extman/cgi/ {
             fastcgi_pass          127.0.0.1:8888;
             fastcgi_index         index.cgi;
             fastcgi_param  SCRIPT_FILENAME   /var/www/extsuite/extman/cgi/$fastcgi_script_name;
             include            fcgi.conf;
        }
        location /extman/ {
             alias  /var/www/extsuite/extman/html/;
        }
      access_log  /var/log/extmail_access.log;
}

创建fcgi.conf文件:

vim /etc/nginx/fcgi.conf

文件内容如下:

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

安装Unix::Syslog:

[root@localhost ~]# cd /usr/local/src/
[root@localhost /usr/local/src]# wget http://www.cpan.org/authors/id/M/MH/MHARNISCH/Unix-Syslog-1.1.tar.gz
[root@localhost /usr/local/src]# tar zxvf Unix-Syslog-1.1.tar.gz 
[root@localhost /usr/local/src]# cd Unix-Syslog-1.1
[root@localhost /usr/local/src/Unix-Syslog-1.1]# perl Makefile.PL
[root@localhost /usr/local/src/Unix-Syslog-1.1]# make && make install

启动nginx,并检查进程和监听端口是否正常:

[root@localhost ~]# service nginx start
Redirecting to /bin/systemctl start  nginx.service
[root@localhost ~]# ps aux |grep nginx
root      72338  0.0  0.1 122892  2296 ?        Ss   03:22   0:00 nginx: master process /usr/sbin/nginx
nginx     72339  0.0  0.1 123336  3192 ?        S    03:22   0:00 nginx: worker process
nginx     72340  0.0  0.1 123336  3192 ?        S    03:22   0:00 nginx: worker process
nginx     72341  0.0  0.1 123336  3192 ?        S    03:22   0:00 nginx: worker process
nginx     72342  0.0  0.1 123336  3192 ?        S    03:22   0:00 nginx: worker process
root      72344  0.0  0.0 112680   976 pts/0    S+   03:22   0:00 grep --color=auto nginx
[root@localhost ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      63834/dovecot       
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      63834/dovecot       
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      72338/nginx: master 
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      72338/nginx: master 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1482/sshd           
tcp        0      0 127.0.0.1:8888          0.0.0.0:*               LISTEN      64100/dispatch.fcgi 
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      64328/master        
tcp6       0      0 :::3306                 :::*                    LISTEN      62442/mysqld        
tcp6       0      0 :::80                   :::*                    LISTEN      72338/nginx: master 
tcp6       0      0 :::22                   :::*                    LISTEN      1482/sshd           
[root@localhost ~]# 

然后到windows上访问你服务器IP的8080端口:

未分类

extman的登录账户为[email protected]密码为extmail123,首次使用需要先添加域,添加之后再修改域,改为可自由注册,再注册用户就可以登录发邮件了:

未分类

CentOS-5安装配置ExtMail Web邮件收发系统

本文参考http://wiki.extmail.org/extmail_solution_for_linux_centos-5,内容和病毒过滤不在本文之内,如需配置请参考官方文档。下面是在CentOS-5 32位系统的安装实录。

制作_yum_仓库

编译CentOS-Base.repo文件

  1. vi /etc/yum.repos.d/CentOS-Base.repo

加入如下内容:

  1. # EMOS-Base.repo
  2. #
  3. # Created by ExtMail Dev Team: http://www.extmail.org/
  4. #
  5. # $Id$
  6.  
  7. [EMOS-base]
  8. name=EMOS-Base
  9. baseurl=http://mirror.extmail.org/yum/emos/1.5/os/$basearch/
  10. gpgcheck=0
  11. priority=0
  12. protect=0
  13.  
  14. [EMOS-update]
  15. name=EMOS-Updates
  16. baseurl=http://mirror.extmail.org/yum/emos/1.5/updates/$basearch/
  17. gpgcheck=0
  18. priority=0
  19. protect=0

保存后,然后尝试执行一下yum list 等操作,看看是否已经成功;

配置mta-postfix

1、安装postfix

  1. # yum -y install postfix
  2. # yum remove sendmail

2、配置postfix

  1. # postconf -n > /etc/postfix/main2.cf
  2. # mv /etc/postfix/main.cf /etc/postfix/main.cf.old
  3. # mv /etc/postfix/main2.cf /etc/postfix/main.cf

编辑main.cf:

  1. # vi /etc/postfix/main.cf

增加如下内容:

  1. # hostname
  2. mynetworks = 127.0.0.1
  3. myhostname = mail.webres.wang
  4. mydestination = $mynetworks $myhostname
  5.  
  6. # banner
  7. mail_name = Postfix – by extmail.org
  8. smtpd_banner = $myhostname ESMTP $mail_name
  9.  
  10. # response immediately
  11. smtpd_error_sleep_time = 0s
  12.  
  13. # Message and return coolcode control
  14. message_size_limit = 5242880
  15. mailbox_size_limit = 5242880
  16. show_user_unknown_table_name = no
  17.  
  18. # Queue lifetime control
  19. bounce_queue_lifetime = 1d
  20. maximal_queue_lifetime = 1d

注:myhostname改为自己的。
设置postfix开机自启:

  1. # chkconfig postfix on

配置courier-authlib

1、安装Courier-Authlib

安装以下软件包:

  1. # yum -y install courier-authlib
  2. # yum -y install courier-authlib-mysql

删除并编辑/etc/authlib/authmysqlrc文件:

  1. # cat /dev/null >/etc/authlib/authmysqlrc
  2. # vi /etc/authlib/authmysqlrc

增加如下内容:

  1. MYSQL_SERVER            localhost
  2. MYSQL_USERNAME          extmail
  3. MYSQL_PASSWORD          extmail
  4. MYSQL_SOCKET            /var/lib/mysql/mysql.sock
  5. MYSQL_PORT              3306
  6. MYSQL_OPT               0
  7. MYSQL_DATABASE          extmail
  8. MYSQL_USER_TABLE        mailbox
  9. MYSQL_CRYPT_PWFIELD     password
  10. MYSQL_UID_FIELD         uidnumber
  11. MYSQL_GID_FIELD         gidnumber
  12. MYSQL_LOGIN_FIELD       username
  13. MYSQL_HOME_FIELD        homedir
  14. MYSQL_NAME_FIELD        name
  15. MYSQL_MAILDIR_FIELD     maildir
  16. MYSQL_QUOTA_FIELD       quota
  17. MYSQL_SELECT_CLAUSE     SELECT username,password,"",uidnumber,gidnumber,
  18.                         CONCAT(‘/home/domains/’,homedir),               
  19.                         CONCAT(‘/home/domains/’,maildir),               
  20.                         quota,                                         
  21.                         name                                           
  22.                         FROM mailbox                                   
  23.                         WHERE username = ‘$(local_part)@$(domain)’

修改authdaemonrc文件

  1. # vi /etc/authlib/authdaemonrc

修改如下内容:

  1. authmodulelist="authmysql"
  2. authmodulelistorig="authmysql"

或者使用如下命令直接修改:

  1. sed -i ‘s/authmodulelist=.*/authmodulelist="authmysql"/g’ /etc/authlib/authdaemonrc
  2. sed -i ‘s/authmodulelistorig=.*/authmodulelistorig="authmysql"/g’ /etc/authlib/authdaemonrc

2、启动courier-authlib:

  1. # service courier-authlib start

修改authdaemon socket目录权限

  1. # chmod 755 /var/spool/authdaemon/

配置maildrop

1、安装maildrop

  1. # yum -y install maildrop

配置master.cf 为了使Postfix支持Maildrop,必须修改/etc/postfix/master.cf文件,注释掉原来的maildrop的配置内容,并改为:

  1. maildrop   unix        –       n        n        –        –        pipe
  2.   flags=DRhu user=vuser argv=maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user} ${extension} {nexthop}

注意:flags前面有“两个空格”

配置main.cf 由于maildrop不支持一次接收多个收件人,因此必须在main.cf里增加如下参数:

  1. # vi /etc/postfix/main.cf
  1. maildrop_destination_recipient_limit = 1

2、测试maildrop对authlib支持

  1. # maildrop -v

看是否出现以下内容:

  1. maildrop 2.1.0 Copyright 1998-2005 Double Precision, Inc.
  2. GDBM/DB extensions enabled.
  3. Courier Authentication Library extension enabled.
  4. Maildir quota extension enabled.
  5. This program is distributed under the terms of the GNU General Public
  6. License. See COPYING for additional information.

配置apache

1、安装httpd

  1. # yum -y install httpd

2、虚拟主机设置

编辑httpd.conf文件:

  1. # vi /etc/httpd/conf/httpd.conf

在最后一行加上:

  1. NameVirtualHost *:80
  2. Include conf/vhost_*.conf

编辑 vhost_extmail.conf

  1. # vi /etc/httpd/conf/vhost_extmail.conf

里面定义虚拟主机的相关内容:

  1. # VirtualHost for ExtMail Solution
  2. <VirtualHost *:80>
  3. ServerName mail.webres.wang
  4. DocumentRoot /var/www/extsuite/extmail/html/
  5.  
  6. ScriptAlias /extmail/cgi/ /var/www/extsuite/extmail/cgi/
  7. Alias /extmail /var/www/extsuite/extmail/html/
  8.  
  9. ScriptAlias /extman/cgi/ /var/www/extsuite/extman/cgi/
  10. Alias /extman /var/www/extsuite/extman/html/
  11.  
  12. # Suexec config
  13. SuexecUserGroup vuser vgroup
  14. </VirtualHost>

注意:把ServerName修改成自己的。
设置apache开机启动并重启apache

  1. # chkconfig httpd on
  2. # service httpd restart

配置webmail-extmail

1、安装ExtMail

  1. # yum -y install extsuite-webmail

2、编辑webmail.cf

  1. # cd /var/www/extsuite/extmail
  2. # cp webmail.cf.default webmail.cf
  3. # vi webmail.cf

主要变动的内容见下:

  1. SYS_MYSQL_USER = extmail
  2. SYS_MYSQL_PASS = extmail
  3. SYS_MYSQL_DB = extmail

更新cgi目录权限 由于SuEXEC的需要,必须将extmail的cgi目录修改成vuser:vgroup权限:

  1. # chown -R vuser:vgroup /var/www/extsuite/extmail/cgi/

配置管理后台-extman

1、yum安装ExtMan

  1. # yum -y install extsuite-webman

更新cgi目录权限 由于SuEXEC的需要,必须将extman的cgi目录修改成vuser:vgroup权限:

  1. # chown -R vuser:vgroup /var/www/extsuite/extman/cgi/

链接基本库到Extmail

  1. # mkdir /tmp/extman
  2. # chown -R vuser:vgroup /tmp/extman

注意事项:
由于RedHat发行版中包含了一个叫tmpwatch的工具,该工具会定期扫描/tmp/下的文件,如果这些文件很久都没被使用,将被删除,因此如果后台长期不使用,/tmp/extman目录有可能被tmpwatch删除,所以要么定期登陆后台,要么修改 webman.cf将临时目录修改到另一个地方。此处暂以/tmp/extman默认值为例。

2、安装mysql数据库

  1. # yum -y install mysql mysql-server

3、数据库初始化

启动Mysql

  1. # service mysqld start
  2. # chkconfig mysqld on

导入mysql数据库结构及初始化数据,root密码默认为空

  1. # mysql -u root -p < /var/www/extsuite/extman/docs/extmail.sql
  2. # mysql -u root -p < /var/www/extsuite/extman/docs/init.sql

注意事项:
上述导入初始化SQL时,默认的uidnumber/gidnumber都是1000,这和vuser:vgroup 的uid/gid一致,是因为maildrop投递时会从数据库里取uidnumber/gidnumber,而在master.cf里已经定义好了投递时的运行身份(vuser:vgroup),所以这两个字段的内容必须为1000,否则将出现投递错误,例如报0×06等错误。

4、设置虚拟域和虚拟用户的配置文件

  1. # cd /var/www/extsuite/extman/docs
  2. # cp mysql_virtual_alias_maps.cf /etc/postfix/
  3. # cp mysql_virtual_domains_maps.cf /etc/postfix/
  4. # cp mysql_virtual_mailbox_maps.cf /etc/postfix/
  5. # cp mysql_virtual_sender_maps.cf /etc/postfix/

配置main.cf:

  1. # vi /etc/postfix/main.cf

增加以下内容:

  1. # extmail config here
  2. virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
  3. virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
  4. virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
  5. virtual_transport = maildrop:

重启postfix :

  1. # service postfix restart

5、测试authlib

  1. # /usr/sbin/authtest -s login [email protected] extmail

结果如下:
Authentication succeeded.

Authenticated: [email protected] (uid 1000, gid 1000)
Home Directory: /home/domains/extmail.org/postmaster
Maildir: /home/domains/extmail.org/postmaster/Maildir/
Quota: 104857600S
Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
Cleartext Password: extmail
Options: (none)

这样表明ExtMan的正确安装,数据库也正确导入,courier-authlib能正确连接到mysql数据库

最后访问http://mail.webres.wang/extmail/,如无意外,将看到webmail的登陆页,不过此时还没有加正式的用户,所以不能登陆,包括[email protected]也不行。必须要登陆到http://mail.webres.wang/extman/ 里增加一个新帐户才能登陆。

ExtMan的默认超级管理员帐户:[email protected],初始密码:extmail*123*,登陆成功后,建议将密码修改,以确保安全。

6、配置图形化日志

启动mailgraph_ext

  1. # /usr/local/mailgraph_ext/mailgraph-init start

启动cmdserver(在后台显示系统信息)

  1. # /var/www/extsuite/extman/daemon/cmdserver –daemon

加入开机自启动:

  1. # echo "/usr/local/mailgraph_ext/mailgraph-init start" >> /etc/rc.d/rc.local
  2. # echo "/var/www/extsuite/extman/daemon/cmdserver -v -d" >> /etc/rc.d/rc.local

使用方法: 等待大约15分钟左右,如果邮件系统有一定的流量,即可登陆到extman里,点“图形日志”即可看到图形化的日志。具体每天,周,月,年的则点击相应的图片进入即可。

配置cyrus-sasl

1、安装cyrus-sasl

删除系统的cyrus-sasl:

  1. # rpm -e cyrus-sasl –nodeps

安装新的支持authdaemon的软件包

  1. # yum -y install cyrus-sasl cyrus-sasl-plain

2、配置main.cf文件

Postfix的SMTP认证需要透过Cyrus-SASL,连接到authdaemon获取认证信息。
编辑main.cf

  1. # vi /etc/postfix/main.cf

增加如下内容:

  1. # smtpd related config
  2. smtpd_recipient_restrictions =
  3.         permit_mynetworks,
  4.         permit_sasl_authenticated,
  5.         reject_non_fqdn_hostname,
  6.         reject_non_fqdn_sender,
  7.         reject_non_fqdn_recipient,
  8.         reject_unauth_destination,
  9.         reject_unauth_pipelining,
  10.         reject_invalid_hostname,
  11.  
  12. # SMTP sender login matching config
  13. smtpd_sender_restrictions =
  14.         permit_mynetworks,
  15.         reject_sender_login_mismatch,
  16.         reject_authenticated_sender_login_mismatch,
  17.         reject_unauthenticated_sender_login_mismatch
  18.  
  19. smtpd_sender_login_maps =
  20.         mysql:/etc/postfix/mysql_virtual_sender_maps.cf,
  21.         mysql:/etc/postfix/mysql_virtual_alias_maps.cf
  22.  
  23. # SMTP AUTH config here
  24. broken_sasl_auth_clients = yes
  25. smtpd_sasl_auth_enable = yes
  26. smtpd_sasl_local_domain = $myhostname
  27. smtpd_sasl_security_options = noanonymous

3、编辑smtpd.conf文件

  1. # vi /usr/lib/sasl2/smtpd.conf

确保其内容为:

  1. pwcheck_method: authdaemond
  2. log_level: 3
  3. mech_list: PLAIN LOGIN
  4. authdaemond_path:/var/spool/authdaemon/socket

重新启动postfix:

  1. # service postfix restart

4、测试SMTP认证

通过以下命令获得[email protected]的用户名及密码的BASE64编码:

  1. # perl -e ‘use MIME::Base64; print encoolcode_base64("[email protected]")’

内容如下:
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==

  1. # perl -e ‘use MIME::Base64; print encoolcode_base64("extmail")’

内容如下:
ZXh0bWFpbA==
然后本机测试:

  1. # telnet localhost 25

其过程如下:
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
220 mail.extmail.org ESMTP Postfix – by extmail.org
ehlo demo.domain.tld << 输入内容
250-mail.extmail.org
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUScoolcodeS
250-8BITMIME
250 DSN
auth login << 输入内容
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw== << 输入内容
334 UGFzc3dvcmQ6
ZXh0bWFpbA== << 输入内容
235 2.0.0 Authentication successful
quit << 输入内容
221 2.0.0 Bye
最后出现235 Authentication Successful 表明认证成功了。

配置courier-imap

1、安装Courier-imap

默认的courier-authlib及courier-imap都会增加系统自启动设置,因此下一次服务器启动将自动启动相应的authlib及POP3服务

  1. # yum -y install courier-imap

配置courier-imap
由于Courier-imap的IMAP目录是按UTF-7编码的,ExtMail目前还没有正式支持IMAP目录,因此需要屏蔽IMAP,只提供pop3服务。而就目前的使用情况来看,IMAP使用的非常少,绝大部分OutLook/Foxmail用户都习惯使用POP3而非IMAP。

  1. # vi /usr/lib/courier-imap/etc/imapd

修改内容如下:

  1. IMAPDSTART=NO
  1. # vi /usr/lib/courier-imap/etc/imapd-ssl

修改内容如下:

  1. IMAPDSSLSTART=NO

然后重新启动courier-imap:

  1. # service courier-imap start

测试POP3 请按如下步骤输入pop3命令测试其是否正常工作,注意蓝色的信息是我们输入到POP3服务器的(请首先登录extman自行建立[email protected]用户,密码:extmail)

  1. # telnet localhost 110

其过程如下:
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
+OK Hello there.
user [email protected] << 输入内容
+OK Password required.
pass extmail << 输入内容
+OK logged in.
list << 输入内容
+OK POP3 clients that break here, they violate STD53.
.
quit << 输入内容
+OK Bye-bye.
Connection closed by foreign host.

最后说明

至此,ExtMail的安装配置基本完成,如想配置内容,病毒过滤请到官方网站学习配置。登录extmail系统后台后,请及时修改密码或者用户名。最后需要确认的是,是否已经设置好邮件域名的MX记录或者A记录,这样才能正常收取邮件。

FAQ

1、64位系统可能安装不上courier-imap。请参考http://hahayong.blog.51cto.com/231965/530016