centos7.2下搭建postfix++dovecot+courier-authlib+extmail邮件收发系统
以前搭建过一次,由于不熟悉,断断续续折腾了半个月
在此记录一下,搭建全过程使用root账号,中间有一些错误调试的,都给忽略了,这里只给出最的配置
在文章最后面会有一些错误调试的记录
#########################################
整个 extmail邮件系统,是由多个软件构成的:
ExtMan Web帐户管理后台(含mailgraph_ext 图形日志分析) ,web管理
ExtMail WebMail(perl 程序) ,web支持
Postfix SMTP服务器,邮件传输代理(MTA) ,收发邮件
Maildrop 邮件投递代理(MDA)
Courier-imap IMAP和POP3 服务器
Cyrus-sasl2 标准的SASL实现库,可以支持Courier Cyrus SMTP认证库
Courier-authlib 负责courier-imap,maildrop的认证 Courier 数据认证库(mysql)
MySQL 数据库,储存虚拟(域|用户|别名)等信息.
################################
postfix: 收发邮件
dovecot: 投递邮件
courier-authlib: 身份验证
mysql 存储账号信息
extmail: web支持
extman: web管理
#################################
主要就是安装几个大块的软件:
系统版本:
#cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
#uname -a
Linux HOST_107_centos 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
准备工作:
[root@HOST_107_centos ~]# getenforce
Disabled
这里如果不是 Disabled , 可以用setenfore=0命令把它设置为Disabled
centos 7.2 默认是不直接用iptables的,我这里开了firewalld 服务,所以直接把端口给开了
[root@HOST_107_centos ~]# firewall-cmd --add-port=110/tcp
[root@HOST_107_centos ~]# firewall-cmd --add-port=110/tcp --permanent
[root@HOST_107_centos ~]# firewall-cmd --add-port=25/tcp
[root@HOST_107_centos ~]# firewall-cmd --add-port=25/tcp --permanent
--permanent 参数是为了使firewalld重启之后,这两条规则依然生效,如果不执行带--permanent参数的命令,重启firewalld 之后,这两条命令就无效了
一.安装数据库:
#yum -y install mariadb.x86_64 mariadb-server.x86_64 mariadb-devel.x86_64
由于CentOS7.2的系统没有mysql数据库了,安装mariadb,不行后面再换(到最后发现mariadb也是可以用的,没什么影响)
启动数据库:
[root@HOST_107_centos mailbox]# service mariadb start
Redirecting to /bin/systemctl start mariadb.service
[root@HOST_107_centos mailbox]#
检查数据库是否启动成功,发现OK了,进程如下:
[root@HOST_107_centos mailbox]# ps aux | grep mysql
mysql 22791 0.0 0.0 9512 1500 ? Ss 14:48 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql 22947 2.1 1.1 920572 95864 ? Sl 14:48 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root 22984 0.0 0.0 112660 960 pts/0 R+ 14:48 0:00 grep --color mysql
登录数据库:
[root@HOST_107_centos mailbox]# mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.52-MariaDB MariaDB Server
MariaDB [mysql]> delete from user where host like 'vm%';
Query OK, 2 rows affected (0.00 sec)
MariaDB [mysql]> delete from user where host='localhost' and user='root';
Query OK, 1 row affected (0.00 sec)
MariaDB [mysql]> delete from user where host='::1' and user='root';
Query OK, 1 row affected (0.00 sec)
MariaDB [mysql]> delete from user where host='localhost' and password='';
Query OK, 1 row affected (0.00 sec)
MariaDB [mysql]> update user set password=password('ppppp902') where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
上面的操作删除了一些无用的账号,给剩下的root账号设置密码,改了之后只能这样# mysql -u root -p -h 127.0.0.1 用密码登录
安装一些必须的插件和库:
# yum install gcc gcc-c++ openssl openssl-devel db4-devel ntpdate 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:yum remove 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 /sbin/nologin -M postdrop
这里把用户id和组id设置为2525和2526是因为后面的extman/webman.cf, postfix/main.cf这两个文件默认都用了这两个数字,不用改来改去那么麻烦
二.解压安装postfix:
tar xf postfix-3.2-20160327.tar.gz
cd postfix-3.2-20160327
安装之前先看一下目录下面有没有对应的头文件和库文件, makefile的时候要用到,如果没有这些文件,编译安装会出错的:
[root@HOST_107_centos postfix-3.2-20160327]# ls /usr/include/mysql/
auth_dialog_client.h ma_dyncol.h my_config_x86_64.h my_net.h mysql_time.h plugin_auth.h service_logger.h sql_common.h
client_plugin.h m_ctype.h my_dbug.h my_pthread.h mysql_version.h plugin_ftparser.h service_my_snprintf.h sql_state.h
decimal.h m_string.h my_decimal_limits.h mysql_com.h my_sys.h plugin.h service_progress_report.h sslopt-case.h
errmsg.h my_alloc.h my_dir.h mysqld_ername.h my_valgrind.h private services.h sslopt-longopts.h
handler_ername.h my_attribute.h my_getopt.h mysqld_error.h my_xml.h psi service_thd_alloc.h sslopt-vars.h
handler_state.h my_compiler.h my_global.h mysql_embed.h plugin_audit.h service_debug_sync.h service_thd_wait.h typelib.h
keycache.h my_config.h my_list.h mysql.h plugin_auth_common.h service_kill_statement.h service_thread_scheduler.h
[root@HOST_107_centos postfix-3.2-20160327]#
[root@HOST_107_centos postfix-3.2-20160327]# ls /usr/include/sasl/
hmac-md5.h md5global.h md5.h prop.h sasl.h saslplug.h saslutil.h
[root@HOST_107_centos postfix-3.2-20160327]#
[root@HOST_107_centos postfix-3.2-20160327]# ls /usr/lib64/mysql/
INFO_BIN INFO_SRC libmysqlclient_r.so libmysqlclient.so libmysqlclient.so.18 libmysqlclient.so.18.0.0 mysqlbug mysql_config plugin
[root@HOST_107_centos postfix-3.2-20160327]#
[root@HOST_107_centos postfix-3.2-20160327]# ls /usr/lib64/sasl2/
libanonymous.so libanonymous.so.3.0.0 libcrammd5.so.3 libdigestmd5.so libdigestmd5.so.3.0.0 liblogin.so.3 libplain.so libplain.so.3.0.0 libsasldb.so.3
libanonymous.so.3 libcrammd5.so libcrammd5.so.3.0.0 libdigestmd5.so.3 liblogin.so liblogin.so.3.0.0 libplain.so.3 libsasldb.so libsasldb.so.3.0.0
[root@HOST_107_centos postfix-3.2-20160327]#
postfix编译和安装(这里-I指定的头文件和库,就是上面ls查看的那些,像mysql这些如果手动安装指定了不同的目录,这里要用-I指定对应的目录才行):
[root@HOST_107_centos postfix-3.2-20160327]#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'
[root@HOST_107_centos postfix-3.2-20160327]#make –j 4
[root@HOST_107_centos postfix-3.2-20160327]#make install
-j 4 是指定编译的时候用4个核,多核的系统可以指定多个核,编译会快一点
安装过程要设置一些目录:安装的时候,就修改postfix的临时目录,别的全部回车用默认设置
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: [/data/mailbox/software/postfix-3.2-20160327] /tmp/mailbox
Please specify the final destination directory for installed Postfix
configuration files.
config_directory: [/etc/postfix]
Please specify the final destination directory for installed Postfix
pppppistrative commands. This directory should be in the command search
path of pppppstrative 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]
Please specify the final destination directory for non-executable files
that are shared among multiple Postfix instances, such as postfix-files,
dynamicmaps.cf, as well as the multi-instance template files main.cf.proto
and master.cf.proto.
meta_directory: [/etc/postfix]
修改postfix相关的目录的属性:
[root@HOST_107_centos mailbox]## chown postfix.postdrop /tmp/mailbox
[root@HOST_107_centos mailbox]## chown postfix.postdrop /tmp/mailbox -R
[root@HOST_107_centos mailbox]# chown postfix.postfix /var/lib/postfix/
[root@HOST_107_centos mailbox]# chown postfix.postfix /var/lib/postfix/ -R
[root@HOST_107_centos mailbox]#
[root@HOST_107_centos mailbox]# chown postfix.postfix /var/spool/postfix/private/
[root@HOST_107_centos mailbox]# chown postfix.postfix /var/spool/postfix/private/ -R
[root@HOST_107_centos mailbox]#
[root@HOST_107_centos mailbox]# chown postfix.postdrop /var/spool/postfix/public/
[root@HOST_107_centos mailbox]# chown postfix.postdrop /var/spool/postfix/public/ -R
[root@HOST_107_centos mailbox]#
注意public目录的postdrop的,如果搞错了,启动postfix的时候会有报警
启动postfix:
[root@HOST_107_centos mailbox]# postfix start
postfix/postfix-script: starting the Postfix mail system
启用sasl认证:
[root@HOST_107_centos software]# service saslauthd start
Redirecting to /bin/systemctl start saslauthd.service
生成二进制的库:(干嘛用的???)
[root@HOST_107_centos mailbox]# newaliases
修改/etc/postfix/main.cf:
前面我们设置的一些目录,有些就在这里,如mailq_path = /usr/bin/mailq 等
完整的main.cf的文件如下:
compatibility_level = 2
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
#这里是域名
myhostname = mail.pxxxd.cn
mydomain = pxxxd.cn
myorigin = pxxxd.cn
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
#网络用内网这个段和本机,本机的段注意是127.0.0.0,不是127.0.0.1
mynetworks = 127.0.0.0/8,172.28.12.0/24
alias_maps = hash:/etc/aliases, nis:mail.aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
mail_spool_directory = /var/spool/mail
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = /var/www/postfix_html
manpage_directory = /usr/local/man
sample_directory = /etc/postfix
readme_directory = no
inet_protocols = ipv4
meta_directory = /etc/postfix
shlib_directory = no
smtputf8_enable = no
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,reject_rbl_client multi.uribl.com,reject_rbl_client dsn.rfc-ignorant.org,reject_rbl_client dul.dnsbl.sorbs.net,reject_rbl_client list.dsbl.org,reject_rbl_client sbl-xbl.spamhaus.org,reject_rbl_client bl.spamcop.net,reject_rbl_client dnsbl.sorbs.net,reject_rbl_client cbl.abuseat.org,reject_rbl_client ix.dnsbl.manitu.net,reject_rbl_client combined.rbl.msrbl.net,reject_rbl_client rabl.nuclearelephant.com,reject_rbl_client cblless.anti-spam.org.cn
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
smtpd_banner = Welcome to our $myhostname SMTP
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
smtpd_helo_required = yes
disable_vrfy_command = yes
strict_rfc821_envelopes = yes
invalid_hostname_reject_code = 554
multi_recipient_bounce_reject_code = 554
non_fqdn_reject_code = 554
relay_domains_reject_code = 554
unknown_address_reject_code = 554
unknown_client_reject_code = 554
unknown_hostname_reject_code = 554
unknown_local_recipient_reject_code = 554
unknown_relay_recipient_reject_code = 554
unknown_virtual_alias_reject_code = 554
unknown_virtual_mailbox_reject_code = 554
unverified_recipient_reject_code = 554
unverified_sender_reject_code = 554
添加DNS解析:
这里用的是阿里云的DNS,到对应的域名下去添加解析
A mail 12x.13x.14x.63
A pop 12x.13x.14x.63
A pop3 12x.13x.14x.63
A smtp 12x.13x.14x.63
MX @ mail.pxxxd.cn
postfix测试:
sh-3.2# telnet mail.xxxxd.cn 25
Trying 12x.13x.14x.63...
Connected to mail.pxxxd.cn.
Escape character is '^]'.
220 mail.pxxxd.cn ESMTP Postfix
ehlo localhost
250-mail.pxxxd.cn
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
mail from:root@localhost
250 2.1.0 Ok
rcpt to:qing@localhost
550 5.1.1 <xxxxang@localhost>: Recipient address rejected: User unknown in local recipient table
rcpt to:xxxxang@pxxxd.cn.cn
454 4.7.1 <xxxxang@pxxxd.cn.cn>: Relay access denied
测试失败,可以tail –f /var/log/maillog 去调试,这里先不管
查看postfix是否则支持支持cyrus风格的sasl认证:
[root@HOST_107_centos ~]# postconf -a
cyrus
dovecot
这里显示支持
添加sasl的认证方式:
一般情况下这个文件是没有的,创建文件vim /usr/lib64/sasl2/smtpd.conf,并添加两行:
pwcheck_method:saslauthd
mech_list:PLAIN LOGIN
保存之后,重新加载postfix的配置:
[root@HOST_107_centos ~]# postfix reload
postfix/postfix-script: refreshing the Postfix mail system
再次telnet,发现比刚才多了两行(红色字体),说明配置成功:
sh-3.2# telnet mail.pxxxd.cn 25
Trying 12x.13x.14x.63...
Connected to mail.pxxxd.cn.
Escape character is '^]'.
220 mail.pxxxd.cn ESMTP Postfix
ehlo localhost
250-mail.pxxxd.cn
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
安装courier-unicode:
tar xf courier-unicode-1.2.tar.bz2
cd courier-unicode-1.2
./configure
make –j4 && make install
安装courier-authlib:
tar xf courier-authlib-0.66.4.tar.bz2
cd courier-authlib-0.66.4/
[root@HOST_107_centos courier-authlib-0.66.4]# mkdir /usr/local/courier-authlib/
[root@HOST_107_centos courier-authlib-0.66.4]#./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 --with-mailgroup=postfix
[root@HOST_107_centos courier-authlib-0.66.4]make –j4 && make install
添加courier启动脚本,并设置开机启动
[root@HOST_107_centos courier-authlib-0.66.4]cp courier-authlib.sysvinit /etc/init.d/courier-authlib
[root@HOST_107_centos courier-authlib-0.66.4] chmod +x /etc/init.d/courier-authlib
[root@HOST_107_centos courier-authlib-0.66.4] chkconfig --add courier-authlib
[root@HOST_107_centos courier-authlib-0.66.4] chkconfig courier-authlib on
[root@HOST_107_centos courier-authlib-0.66.4] echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
[root@HOST_107_centos courier-authlib-0.66.4] ldconfig –v | grep couri
[root@HOST_107_centos courier-authlib-0.66.4] service courier-authlib start
[root@HOST_107_centos ~]cp /etc/authdaemonrc.dist /etc/authdaemonrc
[root@HOST_107_centos ~]cp /etc/authmysqlrc.dist /etc/authmysqlrc
[root@HOST_107_centos conf.d]# cat /etc/authmysqlrc | grep -v ^#
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_PORT 3306
MYSQL_OPT 0
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD crypt
MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD 2525
MYSQL_GID_FIELD 2526
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat('/var/mailbox',homedir)
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD concat('/var/mailbox',homedir)
认证用mysql的:
[root@HOST_107_centos conf.d]# cat /etc/authdaemonrc | grep -v ^#
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10
authdaemonvar=/usr/local/courier-authlib/var/spool/authdaemon
DEBUG_LOGIN=0
DEFAULTOPTIONS=""
LOGGEROPTS=""
安装dovecot:
[root@HOST_107_centos ~]#yum install -y dovecot dovecot-mysql
[root@HOST_107_centos dovecot]#cd /etc/dovecot
[root@HOST_107_centos dovecot]#cat dovecot.conf | grep -v ^#
protocols = imap pop3 lmtp
disable_plaintext_auth = no
ssl_disable = no
listen = *
!include conf.d/*.conf
[root@HOST_107_centos dovecot]# cd conf.d/
[root@HOST_107_centos conf.d]# cat 10-auth.conf | grep -v ^#
auth_mechanisms = plain
!include auth-system.conf.ext
[root@HOST_107_centos conf.d]# cat 10-mail.conf | grep -v ^#
mail_location = maildir:/var/mailbox/%d/%n/Maildir
mbox_write_locks = fcntl
[root@HOST_107_centos conf.d]# cat 10-logging.conf | grep -v ^#
debug_log_path = /var/log/dovecot.log
auth_debug = yes
auth_debug_passwords = yes
mail_debug = yes
root@HOST_107_centos conf.d]# cp auth-sql.conf.ext auth-sql.conf
[root@HOST_107_centos conf.d]# cat auth-sql.conf | grep -v ^#
passdb {
driver = sql
args = /etc/dovecot/dovecot-mysql.conf
}
userdb {
driver = sql
args = /etc/dovecot/dovecot-mysql.conf
}
root@HOST_107_centos conf.d]# cat /etc/dovecot/dovecot-mysql.conf | grep -v ^#
driver = mysql
connect = host=localhost dbname=extmail user=root password=ppppp@XXX902.
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'
extmail and extman 安装:
root@HOST_107_centos software]# tar -xf extmail-1.2.tar.gz
root@HOST_107_centos software]# tar xf extman-1.1.tar.gz
root@HOST_107_centos software]# mkdir /var/www/extsuite/extmail/ -p
root@HOST_107_centos software]# mkdir /var/www/extsuite/extman/ -p
root@HOST_107_centos software]# rsync -al extmail-1.2/* /var/www/extsuite/extmail/
root@HOST_107_centos software]# rsync -al extman-1.1/* /var/www/extsuite/extman/
[root@HOST_107_centos software]# cd /var/www/extsuite/extmail/
root@HOST_107_centos extmail]# cp webmail.cf.default webmail.cf
[root@HOST_107_centos extmail]# cat webmail.cf | grep -v ^#
SYS_CONFIG = /var/www/extsuite/extmail/
SYS_LANGDIR = /var/www/extsuite/extmail/lang
SYS_TEMPLDIR = /var/www/extsuite/extmail/html
SYS_HTTP_CACHE = 0
SYS_SMTP_HOST = 127.0.0.1
SYS_SMTP_PORT = 25
SYS_SMTP_TIMEOUT = 5
SYS_SPAM_REPORT_ON = 0
SYS_SPAM_REPORT_TYPE = dspam
SYS_SHOW_WARN = 0
SYS_IP_SECURITY_ON = 1
SYS_PERMIT_NOQUOTA = 1
SYS_SESS_DIR = /tmp
SYS_UPLOAD_TMPDIR = /tmp
SYS_LOG_ON = 1
SYS_LOG_TYPE = syslog
SYS_LOG_FILE = /var/log/extmail.log
SYS_SESS_TIMEOUT = 0
SYS_SESS_COOKIE_ONLY = 1
SYS_USER_PSIZE = 10
SYS_USER_SCREEN = auto
SYS_USER_LANG = zh_CN
SYS_APP_TYPE = WebMail
SYS_USER_TEMPLATE = default
SYS_USER_CHARSET = utf-8
SYS_USER_TRYLOCAL = 1
SYS_USER_TIMEZONE = +0800
SYS_USER_CCSENT = 1
SYS_USER_SHOW_HTML = 1
SYS_USER_COMPOSE_HTML = 1
SYS_USER_CONV_LINK =1
SYS_USER_ADDR2ABOOK = 1
SYS_MESSAGE_SIZE_LIMIT = 5242880
SYS_MIN_PASS_LEN = 2
SYS_MFILTER_ON = 1
SYS_NETDISK_ON = 1
SYS_SHOW_SIGNUP = 1
SYS_DEBUG_ON = 1
SYS_AUTH_TYPE = mysql
SYS_MAILDIR_BASE = /var/mailbox
SYS_AUTH_SCHEMA = virtual
SYS_CRYPT_TYPE = md5crypt
SYS_MYSQL_USER = root
SYS_MYSQL_PASS = ppppp@XXX902.
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_MYSQL_ATTR_CLEARPW = clearpwd
SYS_MYSQL_ATTR_QUOTA = quota
SYS_MYSQL_ATTR_NDQUOTA = netdiskquota
SYS_MYSQL_ATTR_HOME = homedir
SYS_MYSQL_ATTR_MAILDIR = maildir
SYS_MYSQL_ATTR_DISABLEWEBMAIL = disablewebmail
SYS_MYSQL_ATTR_DISABLENETDISK = disablenetdisk
SYS_MYSQL_ATTR_DISABLEPWDCHANGE = disablepwdchange
SYS_MYSQL_ATTR_ACTIVE = active
SYS_MYSQL_ATTR_PWD_QUESTION = question
SYS_MYSQL_ATTR_PWD_ANSWER = answer
SYS_LDAP_BASE = o=extmailAccount,dc=example.com
SYS_LDAP_RDN = cn=Manager,dc=example.com
SYS_LDAP_PASS = secret
SYS_LDAP_HOST = localhost
SYS_LDAP_ATTR_USERNAME = mail
SYS_LDAP_ATTR_DOMAIN = virtualDomain
SYS_LDAP_ATTR_PASSWD = userPassword
SYS_LDAP_ATTR_CLEARPW = clearPassword
SYS_LDAP_ATTR_QUOTA = mailQuota
SYS_LDAP_ATTR_NDQUOTA = netdiskQuota
SYS_LDAP_ATTR_HOME = homeDirectory
SYS_LDAP_ATTR_MAILDIR = mailMessageStore
SYS_LDAP_ATTR_DISABLEWEBMAIL = disablewebmail
SYS_LDAP_ATTR_DISABLENETDISK = disablenetdisk
SYS_LDAP_ATTR_DISABLEPWDCHANGE = disablePasswdChange
SYS_LDAP_ATTR_ACTIVE = active
SYS_LDAP_ATTR_PWD_QUESTION = question
SYS_LDAP_ATTR_PWD_ANSWER = answer
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
SYS_G_ABOOK_TYPE = file
SYS_G_ABOOK_LDAP_HOST = localhost
SYS_G_ABOOK_LDAP_BASE = ou=AddressBook,dc=example.com
SYS_G_ABOOK_LDAP_ROOTDN = cn=Manager,dc=example.com
SYS_G_ABOOK_LDAP_ROOTPW = secret
SYS_G_ABOOK_LDAP_FILTER = objectClass=OfficePerson
SYS_G_ABOOK_FILE_PATH = /var/www/extsuite/extmail/globabook.cf
SYS_G_ABOOK_FILE_LOCK = 1
SYS_G_ABOOK_FILE_CONVERT = 0
SYS_G_ABOOK_FILE_CHARSET = utf-8
[root@HOST_107_centos extmail]# cd ../extman/
[root@HOST_107_centos extman]#
[root@HOST_107_centos extman]#
[root@HOST_107_centos extman]# cp webman.cf.default webman.cf
[root@HOST_107_centos extman]# cat webman.cf | grep -v ^#
SYS_CONFIG = /var/www/extsuite/extman/
SYS_LANGDIR = /var/www/extsuite/extman/lang
SYS_TEMPLDIR = /var/www/extsuite/extman/html
SYS_MAILDIR_BASE = /var/mailbox
SYS_SHOW_WARN = 0
SYS_SESS_DIR = /tmp/
SYS_CAPTCHA_ON = 0
SYS_CAPTCHA_KEY = r3s9b6a7
SYS_CAPTCHA_LEN = 8
SYS_PURGE_DATA = 0
SYS_PSIZE = 20
SYS_APP_TYPE = ExtMan
SYS_TEMPLATE_NAME = default
SYS_DEFAULT_EXPIRE = 1y
SYS_GROUPMAIL_SENDER = postmaster@extmail.org
SYS_DEFAULT_SERVICES = webmail,smtpd,smtp,pop3,netdisk
SYS_ISP_MODE = no
SYS_DOMAIN_HASHDIR = yes
SYS_DOMAIN_HASHDIR_DEPTH = 2x2
SYS_USER_HASHDIR = yes
SYS_USER_HASHDIR_DEPTH = 2x2
SYS_MIN_UID = 500
SYS_MIN_GID = 100
SYS_DEFAULT_UID = 2525
SYS_DEFAULT_GID = 2525
SYS_QUOTA_MULTIPLIER = 1048576
SYS_QUOTA_TYPE = courier
SYS_DEFAULT_MAXQUOTA = 500
SYS_DEFAULT_MAXALIAS = 100
SYS_DEFAULT_MAXUSERS = 100
SYS_DEFAULT_MAXNDQUOTA = 500
SYS_USER_DEFAULT_QUOTA = 5
SYS_USER_DEFAULT_NDQUOTA = 5
SYS_USER_DEFAULT_EXPIRE = 1y
SYS_BACKEND_TYPE = mysql
SYS_CRYPT_TYPE = md5crypt
SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
SYS_MYSQL_TABLE = manager
SYS_MYSQL_ATTR_USERNAME = username
SYS_MYSQL_ATTR_PASSWD = password
SYS_LDAP_BASE = dc=extmail.org
SYS_LDAP_RDN = cn=Manager,dc=extmail.org
SYS_LDAP_PASS = secret
SYS_LDAP_HOST = localhost
SYS_LDAP_ATTR_USERNAME = mail
SYS_LDAP_ATTR_PASSWD = userPassword
SYS_RRD_DATADIR = /var/lib
SYS_RRD_TMPDIR = /tmp/viewlog
SYS_RRD_QUEUE_ON = yes
SYS_CMDSERVER_SOCK = /tmp/cmdserver.sock
SYS_CMDSERVER_MAXCONN = 5
SYS_CMDSERVER_PID = /var/run/cmdserver.pid
SYS_CMDSERVER_LOG = /var/log/cmdserver.log
SYS_CMDSERVER_AUTHCODE = your_auth_code_here
SYS_IGNORE_SERVER_LIST = web
[root@HOST_107_centos extman]#chown -R postfix.postfix /var/www/extsuite/extman/cgi/
[root@HOST_107_centos extman]#chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
[root@localhost extman]# vim docs/extmail.sql
:% s/TYPE/ENGINE/g
[root@HOST_107_centos extman]# mysql -uroot -p < docs/extmail.sql
[root@HOST_107_centos extman]# mysql -uroot -p < docs/init.sql
这里导入之后,记得给extmail授权:grant all on *.* to extmail@localhost ;
root@HOST_107_centos extman]# cp docs/mysql_virtual_* /etc/postfix/
写个超级简单的脚本启动和关闭mail服务器:
[root@HOST_107_centos mailbox]# cat mail.sh
#!/bin/bash
case $1 in
stop)
postfix stop
service saslauthd stop
/etc/init.d/courier-authlib stop
service dovecot stop
#apachectl stop
/var/www/extsuite/extmail/dispatch-init stop
;;
start)
postfix start
service saslauthd start
/etc/init.d/courier-authlib start
service dovecot start
#apachectl start
/var/www/extsuite/extmail/dispatch-init start
;;
esac
/var/www/extsuite/extman/daemon/cmdserver –daemon
nginx配置:
[root@HOST_107_centos ~]# cat /data/local/nginx-1.8.0/conf/mail.conf
server {
listen 80;
server_name mail.pxxxd.cn;
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 fastcgi.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 fastcgi.conf;
}
location /extman/ {
alias /var/www/extsuite/extman/html/;
}
access_log /data/local/nginx-1.8.0/logs/mail.log;
}
执行上面的脚本mail.sh,启动nginx就可以了
先到extman去添加用户,然后到Extmail登录收发邮件。
extman 后台登录,图形日志页面报错:
Can't locate RRDs.pm in @INC (@INC contains: /var/www/extsuite/extman/libs /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /var/www/extsuite/extman/libs/Ext/GraphLog.pm line 23. BEGIN failed--compilation aborted at /var/www/extsuite/extman/libs/Ext/GraphLog.pm line 23. Compilation failed in require at /var/www/extsuite/extman/libs/Ext/MgrApp/ViewLog.pm line 22. BEGIN failed--compilation aborted at /var/www/extsuite/extman/libs/Ext/MgrApp/ViewLog.pm line 22. Compilation failed in require at /var/www/extsuite/extman/cgi/viewlog.cgi line 18.
yum provides "*/RRDS.pam"
解决:
yum -y install perl-Time-HiRes perl-Time-HiRes-Value perl-File-Tail rrdtool rrdtool-perl
还是不行,没了上面的错误提示,但是图形日志的图片不正常
yum -y install perl-CPAN
重启mail服务,不行
cp /var/www/extsuite/extman/addon/mailgraph_ext/ /usr/local/mailgraph_ext
cd /usr/local/mailgraph_ext
./mailgraph-init start
Starting mail statistics grapher: mailgraph_ext
Can't locate File/Tail.pm in @INC (@INC contains: /root/perl5/lib/perl5/5.16.3/x86_64-linux-thread-multi /root/perl5/lib/perl5/5.16.3 /root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/mailgraph_ext/mailgraph_ext.pl line 296.
BEGIN failed--compilation aborted at /usr/local/mailgraph_ext/mailgraph_ext.pl line 296.
Starting queue statistics grapher: qmonitor
报错,但是“邮件队列分析图”有出来了,不是之前那种裂开的无图片图标了。别的图好像还不行
下载File-Tail-1.3.tar.gz , 安装
[root@bjdc-pytbackup mailgraph_ext]# ./mailgraph-init start
Starting mail statistics grapher: mailgraph_ext
Starting queue statistics grapher: qmonitor
再次登录,OK 了 !!!!所有图形正常
上面用到了ehlo等命令,这里给个说明:
smtp状态码:
1XX:
2XX:正确信息
3XX:当前信息没有结束
4XX:暂时性错误
5XX:永久性错误
smtp:协议命令
helo (smtp协议)
ehlo (esmtp协议)
mail from: 邮件发送人
rcpt to: 邮件接收人
date 邮件内容
Subject: 邮件标题
. 邮件结束符
alias:邮件别名
abc@abc.com:efg@efg.com 法网abc的其实会发到efg
使用newaliases来生成/etc/aliases.db
验证postfix是否安装OK
其他常见错误google有,不贴了,第一次自己搭建应该会有不少问题的,重要的是慢慢尝试
不知道什么原因一定要打印日志,查看日志,拿错误日志搜索,是解决问题的最佳方法