centos7.2下搭建postfix++dovecot+courier-authlib+extmail邮件收发系统

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管理

#################################

主要就是安装几个大块的软件:

一.数据库

二.postfix

三.courier-authlib

四.dovecot

五.extmai+extman

系统版本:

#cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

#uname -a

Linux VM_12_107_centos3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64GNU/Linux

准备工作:

[root@VM_12_107_centos ~]# getenforce

Disabled

这里如果不是Disabled,可以用setenfore=0命令把它设置为Disabled

centos 7.2默认是不直接用iptables的,我这里开了firewalld服务,所以直接把端口给开了

[root@VM_12_107_centos~]# firewall-cmd --add-port=110/tcp

[root@VM_12_107_centos ~]# firewall-cmd--add-port=110/tcp --permanent

[root@VM_12_107_centos~]# firewall-cmd --add-port=25/tcp

[root@VM_12_107_centos ~]# firewall-cmd--add-port=25/tcp --permanent

--permanent参数是为了使firewalld重启之后,这两条规则依然生效,如果不执行带--permanent参数的命令,重启firewalld之后,这两条命令就无效了

一.安装数据库:

#yum -y install mariadb.x86_64 mariadb-server.x86_64mariadb-devel.x86_64

由于CentOS7.2的系统没有mysql数据库了,安装mariadb,不行后面再换(到最后发现mariadb也是可以用的,没什么影响)

启动数据库:

[root@VM_12_107_centos mailbox]# servicemariadb start

Redirecting to /bin/systemctl startmariadb.service

[root@VM_12_107_centos mailbox]#

ps命令检查数据库是否启动成功,发现OK了

[root@VM_12_107_centos mailbox]# ps aux |grep mysql

mysql227910.00.095121500 ?Ss14:480:00 /bin/sh/usr/bin/mysqld_safe --basedir=/usrmysql229472.11.1 920572 95864 ?Sl14:480: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

root229840.00.0 112660960 pts/0R+14:480:00 grep --color mysql

登录数据库:

[root@VM_12_107_centos mailbox]# mysql -uroot

Welcome to the MariaDB monitor.Commands end with ; or \g.

Your MariaDB connection id is 2

Server version: 5.5.52-MariaDB MariaDBServer

MariaDB [mysql]> delete from user wherehost like 'vm%';

Query OK, 2 rows affected (0.00 sec)

MariaDB [mysql]> delete from user wherehost='localhost' and user='root';

Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> delete from user wherehost='::1' and user='root';

Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> delete from user wherehost='localhost' and password='';

Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> update user setpassword=password('ppppp902') whereuser='root';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1Changed: 1Warnings: 0

MariaDB [mysql]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

上面的操作删除了一些无用的账号,给剩下的root账号设置密码,改了之后只能这样# mysql -u root-p -h127.0.0.1用密码登录

安装一些必须的插件和库:

# yum install gcc gcc-c++ opensslopenssl-devel db4-devel ntpdatebzip2php-mysql cyrus-sasl-md5 perl-GD perl-DBD-MySQL perl-GD perl-CPAN perl-CGIperl-CGI-Session cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devellibtool-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@VM_12_107_centospostfix-3.2-20160327]# ls /usr/include/mysql/

auth_dialog_client.hma_dyncol.hmy_config_x86_64.hmy_net.hmysql_time.hplugin_auth.hservice_logger.hsql_common.h

client_plugin.hm_ctype.hmy_dbug.hmy_pthread.hmysql_version.hplugin_ftparser.hservice_my_snprintf.hsql_state.h

decimal.hm_string.hmy_decimal_limits.hmysql_com.hmy_sys.hplugin.hservice_progress_report.hsslopt-case.h

errmsg.hmy_alloc.hmy_dir.hmysqld_ername.hmy_valgrind.hprivateservices.hsslopt-longopts.h

handler_ername.hmy_attribute.hmy_getopt.hmysqld_error.hmy_xml.hpsiservice_thd_alloc.hsslopt-vars.h

handler_state.hmy_compiler.hmy_global.hmysql_embed.hplugin_audit.hservice_debug_sync.hservice_thd_wait.htypelib.h

keycache.hmy_config.hmy_list.hmysql.hplugin_auth_common.hservice_kill_statement.hservice_thread_scheduler.h

[root@VM_12_107_centospostfix-3.2-20160327]#

[root@VM_12_107_centospostfix-3.2-20160327]# ls /usr/include/sasl/

hmac-md5.hmd5global.hmd5.hprop.hsasl.hsaslplug.hsaslutil.h

[root@VM_12_107_centospostfix-3.2-20160327]#

[root@VM_12_107_centospostfix-3.2-20160327]# ls /usr/lib64/mysql/

INFO_BININFO_SRClibmysqlclient_r.solibmysqlclient.solibmysqlclient.so.18libmysqlclient.so.18.0.0mysqlbugmysql_configplugin

[root@VM_12_107_centos postfix-3.2-20160327]#

[root@VM_12_107_centospostfix-3.2-20160327]# ls /usr/lib64/sasl2/

libanonymous.solibanonymous.so.3.0.0libcrammd5.so.3libdigestmd5.solibdigestmd5.so.3.0.0liblogin.so.3libplain.solibplain.so.3.0.0libsasldb.so.3

libanonymous.so.3libcrammd5.solibcrammd5.so.3.0.0libdigestmd5.so.3liblogin.soliblogin.so.3.0.0libplain.so.3libsasldb.solibsasldb.so.3.0.0

[root@VM_12_107_centospostfix-3.2-20160327]#

postfix编译和安装(这里-I指定的头文件和库,就是上面ls查看的那些,像mysql这些如果手动安装指定了不同的目录,这里要用-I指定对应的目录才行)

[root@VM_12_107_centospostfix-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@VM_12_107_centospostfix-3.2-20160327]#make –j 4

[root@VM_12_107_centospostfix-3.2-20160327]#make install

-j 4是指定编译的时候用4个核,多核的系统可以指定多个核,编译会快一点

安装过程要设置一些目录:安装的时候,就修改postfix的临时目录,别的全部回车用默认设置

Please specifythe prefix for installed file names. Specify this ONLY

if you are building ready-to-installpackages for distribution to OTHER

machines. See PACKAGE_README forinstructions.

install_root: [/]

Please specifya directory for scratch files while installing Postfix. You

must have write permission in thisdirectory.

tempdir:[/data/mailbox/software/postfix-3.2-20160327] /tmp/mailbox

Please specifythe final destination directory for installed Postfix

configuration files.

config_directory: [/etc/postfix]

Please specifythe final destination directory for installed Postfix

pppppistrative commands. This directoryshould be in the command search

path of pppppstrative users.

command_directory: [/usr/sbin]

Please specifythe final destination directory for installed Postfix

daemon programs. This directory should notbe in the command search path

of any users.

daemon_directory: [/usr/libexec/postfix]

Please specifythe final destination directory for Postfix-writable

data files such as caches or randomnumbers. This directory should not

be shared with non-Postfix software.

data_directory: [/var/lib/postfix]

Please specifythe final destination directory for the Postfix HTML

files. Specify "no" if you do notwant to install these files.

html_directory: [no]

Please specifythe owner of the Postfix queue. Specify an account with

numerical user ID and group ID values thatare not used by any other

accounts on the system.

mail_owner: [postfix]

Please specifythe final destination pathname for the installed Postfix

mailq command. This is theSendmail-compatible mail queue listing command.

mailq_path: [/usr/bin/mailq]

Please specifythe final destination directory for the Postfix on-line

manual pages. You can no longer specify"no" here.

manpage_directory: [/usr/local/man]

Please specifythe final destination pathname for the installed Postfix

newaliases command. This is theSendmail-compatible command to build

alias databases for the Postfix localdelivery agent.

newaliases_path: [/usr/bin/newaliases]

Please specify the final destinationdirectory for Postfix queues.

queue_directory: [/var/spool/postfix]

Please specifythe final destination directory for the Postfix README

files. Specify "no" if you do notwant to install these files.

readme_directory: [no]

Please specifythe final destination pathname for the installed Postfix

sendmail command. This is theSendmail-compatible mail posting interface.

sendmail_path: [/usr/sbin/sendmail]

Please specifythe group for mail submission and for queue management

commands. Specify a group name with anumerical group ID that is

not shared with other accounts, not evenwith the Postfix mail_owner

account. You can no longer specify"no" here.

setgid_group: [postdrop]

Please specifythe final destination directory for Postfix shared-library

files.

shlib_directory: [no]

Please specifythe final destination directory for non-executable files

that are shared among multiple Postfixinstances, such as postfix-files,

dynamicmaps.cf, as well as the multi-instancetemplate files main.cf.proto

and master.cf.proto.

meta_directory: [/etc/postfix]

修改postfix相关的目录的属性:

[root@VM_12_107_centosmailbox]## chown postfix.postdrop /tmp/mailbox

[root@VM_12_107_centos mailbox]## chownpostfix.postdrop /tmp/mailbox -R

[root@VM_12_107_centosmailbox]# chown postfix.postfix /var/lib/postfix/

[root@VM_12_107_centos mailbox]# chownpostfix.postfix /var/lib/postfix/-R

[root@VM_12_107_centosmailbox]#

[root@VM_12_107_centos mailbox]# chownpostfix.postfix /var/spool/postfix/private/

[root@VM_12_107_centos mailbox]# chownpostfix.postfix /var/spool/postfix/private/-R

[root@VM_12_107_centosmailbox]#

[root@VM_12_107_centos mailbox]# chownpostfix.postdrop /var/spool/postfix/public/

[root@VM_12_107_centos mailbox]# chownpostfix.postdrop /var/spool/postfix/public/ -R

[root@VM_12_107_centosmailbox]#

注意public目录的postdrop的,如果搞错了,启动postfix的时候会有报警

启动postfix:

[root@VM_12_107_centos mailbox]# postfixstart

postfix/postfix-script: starting thePostfix mail system

启用sasl认证:

[root@VM_12_107_centossoftware]# service saslauthd start

Redirecting to /bin/systemctl startsaslauthd.service

生成二进制的库:(干嘛用的???)

[root@VM_12_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_clientmulti.uribl.com,reject_rbl_client dsn.rfc-ignorant.org,reject_rbl_clientdul.dnsbl.sorbs.net,reject_rbl_client list.dsbl.org,reject_rbl_clientsbl-xbl.spamhaus.org,reject_rbl_client bl.spamcop.net,reject_rbl_clientdnsbl.sorbs.net,reject_rbl_client cbl.abuseat.org,reject_rbl_clientix.dnsbl.manitu.net,reject_rbl_client combined.rbl.msrbl.net,reject_rbl_clientrabl.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 $myhostnameSMTP

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.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-ENHANCEDSTATUSCODES

250-8BITMIME

250-DSN

250 SMTPUTF8

mail from:root@localhost

250 2.1.0 Ok

rcpt to:qiuyang@localhost

550 5.1.1 :Recipient address rejected: User unknown in local recipient table

rcpt to:qiuyang@pxxxd.cn.cn

454 4.7.1 :Relay access denied

测试失败,可以tail –f /var/log/maillog去调试,这里先不管

查看postfix是否则支持支持cyrus风格的sasl认证:

[root@VM_12_107_centos ~]# postconf -a

cyrus

dovecot

这里显示支持

添加sasl的认证方式:

一般情况下这个文件是没有的,创建文件vim /usr/lib64/sasl2/smtpd.conf,并添加两行:

pwcheck_method:saslauthd

mech_list:PLAIN LOGIN

保存之后,重新加载postfix的配置:

[root@VM_12_107_centos ~]# postfix reload

postfix/postfix-script: refreshing thePostfix 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@VM_12_107_centos courier-authlib-0.66.4]#mkdir /usr/local/courier-authlib/

[root@VM_12_107_centoscourier-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@VM_12_107_centos courier-authlib-0.66.4]make–j4 && make install

添加courier启动脚本,并设置开机启动

[root@VM_12_107_centos courier-authlib-0.66.4]cpcourier-authlib.sysvinit /etc/init.d/courier-authlib

[root@VM_12_107_centoscourier-authlib-0.66.4] chmod +x /etc/init.d/courier-authlib

[root@VM_12_107_centoscourier-authlib-0.66.4] chkconfig --add courier-authlib

[root@VM_12_107_centoscourier-authlib-0.66.4] chkconfig courier-authlib on

[root@VM_12_107_centoscourier-authlib-0.66.4] echo"/usr/local/courier-authlib/lib/courier-authlib" >>/etc/ld.so.conf.d/courier-authlib.conf

[root@VM_12_107_centoscourier-authlib-0.66.4] ldconfig –v | grep couri

[root@VM_12_107_centoscourier-authlib-0.66.4] service courier-authlib start

[root@VM_12_107_centos ~]cp/etc/authdaemonrc.dist/etc/authdaemonrc

[root@VM_12_107_centos~]cp /etc/authmysqlrc.dist/etc/authmysqlrc

[root@VM_12_107_centos conf.d]# cat/etc/authmysqlrc | grep -v ^#

MYSQL_SERVERlocalhost

MYSQL_USERNAMEextmail

MYSQL_PASSWORDextmail

MYSQL_SOCKET/var/lib/mysql/mysql.sock

MYSQL_PORT3306

MYSQL_OPT0

MYSQL_DATABASEextmail

MYSQL_USER_TABLEmailbox

MYSQL_CRYPT_PWFIELDcrypt

MYSQL_CLEAR_PWFIELDpassword

MYSQL_UID_FIELD2525

MYSQL_GID_FIELD2526

MYSQL_LOGIN_FIELDusername

MYSQL_HOME_FIELDconcat('/var/mailbox',homedir)

MYSQL_NAME_FIELDname

MYSQL_MAILDIR_FIELDconcat('/var/mailbox',homedir)

认证用mysql的:

[root@VM_12_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@VM_12_107_centos~]#yum install -ydovecot dovecot-mysql

[root@VM_12_107_centos dovecot]#cd/etc/dovecot

[root@VM_12_107_centosdovecot]#cat dovecot.conf | grep -v ^#

protocols = imap pop3 lmtp

disable_plaintext_auth = no

ssl_disable = no

listen = *

!include conf.d/*.conf

[root@VM_12_107_centos dovecot]# cd conf.d/

[root@VM_12_107_centosconf.d]# cat 10-auth.conf | grep -v ^#

auth_mechanisms = plain

!include auth-system.conf.ext

[root@VM_12_107_centos conf.d]# cat10-mail.conf | grep -v ^#

mail_location =maildir:/var/mailbox/%d/%n/Maildir

mbox_write_locks = fcntl

[root@VM_12_107_centos conf.d]# cat10-logging.conf| grep -v ^#

debug_log_path = /var/log/dovecot.log

auth_debug = yes

auth_debug_passwords = yes

mail_debug = yes

root@VM_12_107_centos conf.d]# cpauth-sql.conf.ext auth-sql.conf

[root@VM_12_107_centosconf.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@VM_12_107_centos conf.d]# cat/etc/dovecot/dovecot-mysql.conf | grep -v ^#

driver = mysql

connect = host=localhost dbname=extmailuser=root password=ppppp@XXX902.

default_pass_scheme = CRYPT

password_query = SELECT username ASuser,password AS password FROM mailbox WHERE username = '%u'

user_query = SELECT maildir, uidnumber ASuid, gidnumber AS gid FROM mailbox WHERE username = '%u'

extmail and extman安装:

root@VM_12_107_centos software]# tar -xfextmail-1.2.tar.gz

root@VM_12_107_centos software]# tar xfextman-1.1.tar.gz

root@VM_12_107_centos software]# mkdir/var/www/extsuite/extmail/ -p

root@VM_12_107_centos software]# mkdir/var/www/extsuite/extman/ -p

root@VM_12_107_centos software]# rsync -alextmail-1.2/* /var/www/extsuite/extmail/

root@VM_12_107_centos software]# rsync -alextman-1.1/* /var/www/extsuite/extman/

[root@VM_12_107_centos software]# cd/var/www/extsuite/extmail/

root@VM_12_107_centos extmail]# cpwebmail.cf.default webmail.cf

[root@VM_12_107_centosextmail]# 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@VM_12_107_centos extmail]# cd../extman/

[root@VM_12_107_centos extman]#

[root@VM_12_107_centos extman]#

[root@VM_12_107_centos extman]# cpwebman.cf.default webman.cf

[root@VM_12_107_centos extman]# catwebman.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@VM_12_107_centos extman]#chown -Rpostfix.postfix /var/www/extsuite/extman/cgi/

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

[root@localhost extman]# vimdocs/extmail.sql

:% s/TYPE/ENGINE/g

[root@VM_12_107_centos extman]# mysql-uroot -p < docs/extmail.sql

[root@VM_12_107_centos extman]# mysql-uroot -p < docs/init.sql

这里导入之后,记得给extmail授权:grant all on *.* to extmail@localhost ;

root@VM_12_107_centos extman]# cpdocs/mysql_virtual_* /etc/postfix/

写个超级简单的脚本启动和关闭mail服务器:

[root@VM_12_107_centos mailbox]# catmail.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@VM_12_107_centos~]# cat /data/local/nginx-1.8.0/conf/mail.conf

server {

listen80;

server_namemail.pxxxd.cn;

index index.html index.htm index.php index.cgi;

root/var/www/extsuite/extmail/html/;

location /extmail/cgi/ {

fastcgi_pass127.0.0.1:8888;

fastcgi_indexindex.cgi;

fastcgi_paramSCRIPT_FILENAME/var/www/extsuite/extmail/cgi/$fastcgi_script_name;

includefastcgi.conf;

}

location/extmail/{

alias/var/www/extsuite/extmail/html/;

}

location /extman/cgi/ {

fastcgi_pass127.0.0.1:8888;

fastcgi_indexindex.cgi;

fastcgi_paramSCRIPT_FILENAME/var/www/extsuite/extman/cgi/$fastcgi_script_name;

includefastcgi.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登录收发邮件。

参考链接:

http://www.thinksaas.cn/topics/0/506/506622.html

extman后台登录,图形日志页面报错:

Can't locate RRDs.pm in @INC (@INCcontains: /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. BEGINfailed--compilation aborted at /var/www/extsuite/extman/libs/Ext/GraphLog.pmline 23. Compilation failed in require at/var/www/extsuite/extman/libs/Ext/MgrApp/ViewLog.pm line 22. BEGIN failed--compilationaborted at /var/www/extsuite/extman/libs/Ext/MgrApp/ViewLog.pm line 22.Compilation failed in require at /var/www/extsuite/extman/cgi/viewlog.cgi line18.

yum provides "*/RRDS.pam"

解决:

yum -y install perl-Time-HiResperl-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有,不贴了,第一次自己搭建应该会有不少问题的,重要的是慢慢尝试

不知道什么原因一定要打印日志,查看日志,拿错误日志搜索,是解决问题的最佳方法


有问题欢迎留言

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,293评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,604评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,958评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,729评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,719评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,630评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,000评论 3 397
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,665评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,909评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,646评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,726评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,400评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,986评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,959评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,197评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,996评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,481评论 2 342

推荐阅读更多精彩内容