centos7.2下搭建postfix++dovecot+courier-authlib+extmail郵件收發(fā)系統(tǒng)

centos7.2下搭建postfix++dovecot+courier-authlib+extmail郵件收發(fā)系統(tǒng)

以前搭建過一次瘦穆,由于不熟悉,斷斷續(xù)續(xù)折騰了大半個月

在此記錄一下熙兔,搭建全過程使用root賬號,中間有一些錯誤調(diào)試的住涉,都給忽略了,這里只給出最的配置

在文章最后面會有一些錯誤調(diào)試的記錄

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

整個extmail郵件系統(tǒng)五慈,是由多個軟件構(gòu)成的:

ExtMan???????????Web帳戶管理后臺(含mailgraph_ext圖形日志分析)毙芜,web管理

ExtMail??????????WebMail(perl程序)晦雨,web支持

Postfix??????????SMTP服務(wù)器闹瞧,郵件傳輸代理(MTA),收發(fā)郵件

Maildrop郵件投遞代理(MDA)

Courier-imap?????IMAP和POP3服務(wù)器

Cyrus-sasl2標準的SASL實現(xiàn)庫洽腺,可以支持Courier?Cyrus?SMTP認證庫

Courier-authlib負責(zé)courier-imap,maildrop的認證Courier數(shù)據(jù)認證庫(mysql)

MySQL數(shù)據(jù)庫,儲存虛擬(域|用戶|別名)等信息.

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

postfix:收發(fā)郵件

dovecot:投遞郵件

courier-authlib:身份驗證

mysql存儲賬號信息

extmail:web支持

extman:web管理

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

主要就是安裝幾個大塊的軟件:

一.?dāng)?shù)據(jù)庫

二.postfix

三.courier-authlib

四.dovecot

五.extmai+extman

系統(tǒng)版本:

#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命令把它設(shè)置為Disabled

centos 7.2默認是不直接用iptables的,我這里開了firewalld服務(wù),所以直接把端口給開了

[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參數(shù)是為了使firewalld重啟之后朋腋,這兩條規(guī)則依然生效旭咽,如果不執(zhí)行帶--permanent參數(shù)的命令,重啟firewalld之后仲墨,這兩條命令就無效了

一.安裝數(shù)據(jù)庫:

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

由于CentOS7.2的系統(tǒng)沒有mysql數(shù)據(jù)庫了俩由,安裝mariadb幻梯,不行后面再換(到最后發(fā)現(xiàn)mariadb也是可以用的,沒什么影響)

啟動數(shù)據(jù)庫:

[root@VM_12_107_centos mailbox]# servicemariadb start

Redirecting to /bin/systemctl startmariadb.service

[root@VM_12_107_centos mailbox]#

ps命令檢查數(shù)據(jù)庫是否啟動成功煞躬,發(fā)現(xiàn)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

登錄數(shù)據(jù)庫:

[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賬號設(shè)置密碼,改了之后只能這樣# 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

卸載系統(tǒng)自帶的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設(shè)置為2525和2526是因為后面的extman/webman.cf, postfix/main.cf這兩個文件默認都用了這兩個數(shù)字复唤,不用改來改去那么麻煩

二.解壓安裝postfix:

tar xf postfix-3.2-20160327.tar.gz

cd postfix-3.2-20160327

安裝之前先看一下目錄下面有沒有對應(yīng)的頭文件和庫文件, 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指定對應(yīng)的目錄才行)

[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個核有额,多核的系統(tǒng)可以指定多個核茴迁,編譯會快一點

安裝過程要設(shè)置一些目錄:安裝的時候笋熬,就修改postfix的臨時目錄胳螟,別的全部回車用默認設(shè)置

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相關(guān)的目錄的屬性:

[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:

前面我們設(shè)置的一些目錄,有些就在這里贡珊,如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

#網(wǎng)絡(luò)用內(nèi)網(wǎng)這個段和本機烂叔,本機的段注意是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,到對應(yīng)的域名下去添加解析

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去調(diào)試,這里先不管

查看postfix是否則支持支持cyrus風(fēng)格的sasl認證:

[root@VM_12_107_centos ~]# postconf -a

cyrus

dovecot

這里顯示支持

添加sasl的認證方式:

一般情況下這個文件是沒有的晦墙,創(chuàng)建文件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,發(fā)現(xiàn)比剛才多了兩行(紅色字體),說明配置成功:

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啟動腳本,并設(shè)置開機啟動

[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

這里導(dǎo)入之后讳侨,記得給extmail授權(quán):grant all on *.* to extmail@localhost ;

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

寫個超級簡單的腳本啟動和關(guān)閉mail服務(wù)器:

[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;

}

執(zhí)行上面的腳本mail.sh潮峦,啟動nginx就可以了

先到extman去添加用戶嘱腥,然后到Extmail登錄收發(fā)郵件齿兔。

參考鏈接:

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服務(wù),不行

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了P病A榍伞0!所有圖形正常

上面用到了ehlo等命令权她,這里給個說明:

smtp狀態(tài)碼:

1XX:

2XX:正確信息

3XX:當(dāng)前信息沒有結(jié)束

4XX:暫時性錯誤

5XX:永久性錯誤

smtp:協(xié)議命令

helo (smtp協(xié)議)

ehlo (esmtp協(xié)議)

mail from:郵件發(fā)送人

rcpt to:郵件接收人

date郵件內(nèi)容

Subject:郵件標題

.郵件結(jié)束符

alias:郵件別名

abc@abc.com:efg@efg.com法網(wǎng)abc的其實會發(fā)到efg

使用newaliases來生成/etc/aliases.db

驗證postfix是否安裝OK

其他常見錯誤google有虹茶,不貼了,第一次自己搭建應(yīng)該會有不少問題的隅要,重要的是慢慢嘗試

不知道什么原因一定要打印日志蝴罪,查看日志,拿錯誤日志搜索步清,是解決問題的最佳方法


有問題歡迎留言

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末要门,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子廓啊,更是在濱河造成了極大的恐慌炒瘟,老刑警劉巖廓推,帶你破解...
    沈念sama閱讀 218,682評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異藤肢,居然都是意外死亡钞澳,警方通過查閱死者的電腦和手機兰吟,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,277評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人烹卒,你說我怎么就攤上這事藐吮。” “怎么了?”我有些...
    開封第一講書人閱讀 165,083評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長哺壶。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,763評論 1 295
  • 正文 為了忘掉前任鹃两,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘寄啼。我一直安慰自己杜漠,他們只是感情好晨缴,可當(dāng)我...
    茶點故事閱讀 67,785評論 6 392
  • 文/花漫 我一把揭開白布械拍。 她就那樣靜靜地躺著,像睡著了一般党窜。 火紅的嫁衣襯著肌膚如雪楚里。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,624評論 1 305
  • 那天纱扭,我揣著相機與錄音因惭,去河邊找鬼。 笑死咆繁,一個胖子當(dāng)著我的面吹牛纳胧,可吹牛的內(nèi)容都是我干的芝雪。 我是一名探鬼主播,決...
    沈念sama閱讀 40,358評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼妇垢,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,261評論 0 276
  • 序言:老撾萬榮一對情侶失蹤确沸,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體耙旦,經(jīng)...
    沈念sama閱讀 45,722評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡馆揉,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年下面,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片玷氏。...
    茶點故事閱讀 40,030評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡岛心,死狀恐怖来破,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情忘古,我是刑警寧澤徘禁,帶...
    沈念sama閱讀 35,737評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站髓堪,受9級特大地震影響送朱,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜干旁,卻給世界環(huán)境...
    茶點故事閱讀 41,360評論 3 330
  • 文/蒙蒙 一驶沼、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧争群,春花似錦回怜、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,941評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至轻要,卻和暖如春复旬,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背伦腐。 一陣腳步聲響...
    開封第一講書人閱讀 33,057評論 1 270
  • 我被黑心中介騙來泰國打工赢底, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留失都,地道東北人柏蘑。 一個月前我還...
    沈念sama閱讀 48,237評論 3 371
  • 正文 我出身青樓,卻偏偏與公主長得像粹庞,于是被迫代替她去往敵國和親咳焚。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,976評論 2 355

推薦閱讀更多精彩內(nèi)容