1、安裝前的準備工做html
當用戶登陸到postfix發送郵件時,調用cyrus-sasl的庫函數,並經過courier-authlib來進行mysql認證,如認證經過,則能夠發送郵件,如所發郵件是本機所接受的郵件,則直接經過postfix存儲到mailbox中,而其餘用戶要想收郵件,dovecot能夠實現pop3和imap的MDA功能,而此過程,可經過配置dovecot使用mysql來進行對收取郵件的認證;extmail是實現經過web來代替outlook來實現MUA功能的,用戶登陸web的認證,也能經過mysql來實現,extman的功能是能夠經過用戶的註冊,修改密碼等請求來對帳戶進行管理的,如同163郵箱同樣。mysql
關於郵件服務器的幾個名詞: MUA=====》用戶代理端,即用戶使用的寫信、收信客戶端軟件 MTA=====》郵件傳送端,即常說的郵件服務器,用於轉發、收取用戶郵件。 MDA=====》郵件代理端,至關於MUA和MTA的中間人,可用於過濾垃圾郵件。 POP=====》郵局協議,用於MUA鏈接服務器收取用戶郵件,通訊端口110。 IMOP====》互聯網應用協議,功能較POP多,通訊端口143。 SMTP====》簡單郵件傳送協議,MUA鏈接MTA或MTA鏈接MTA發送郵件使用此協議,通訊端口25。
postfix的官網: http://www.postfix.org/linux
Courier-authlib(郵件驗證庫)的官網: http://www.courier-mta.org/authlib/c++
Dovecot的官網: http://www.dovecot.org/web
##IMAP/POP3服務器用以接收外界發送到本機的郵件sql
關於curus-sasl: http://www.linuxfromscratch.org/blfs/view/cvs/postlfs/cyrus-sasl.html 數據庫
##用以實現用戶認證服務ubuntu
extmail官網:http://www.extmail.org/ centos
##國內惟一開源免費的WebMail郵件服務器,最新開源版1.2版是09就發佈了的,不過最近 可能會發布1.3版瀏覽器
①安裝所需軟件包:
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install httpd mysql mysql-server mysql-devel openssl openssl-devel dovecot dovecot-mysql tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect expect-devel gcc gcc-c++ # yum install 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 telnet libicu-devel
注:因爲centos7默認安裝數據庫爲MariaDB,因此須要添加MySQL的yum源
②添加相關用戶和組
# yum remove postfix ##刪除centos7自帶postfix # 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
注:postdrop - Postfix mail posting utility(直譯:後綴郵件發送工具)
http://www.postfix.org/postdrop.1.html
③啓動依賴服務
# systemctl start mysql.service # chkconfig mysqld on # systemctl start saslauthd.service # chkconfig saslauthd on
④關閉SELinux和防火牆:
a、臨時關閉(不用重啓機器):
# setenforce 0 ##設置SELinux 成爲permissive模式 (關閉SELinux) # setenforce 1 ##設置SELinux 成爲enforcing模式 (開啓SELinux)
b、修改配置文件須要重啓機器:
# vi /etc/selinux/config
將SELINUX=enforcing 改成SELINUX=disabled(需重啓機器)
c、可本身作策略開放相應端口,這裏我直接關閉:
# systemctl status firewalld.service ##查看防火牆狀態 # systemctl stop firewalld.service ##關閉防火牆
2、安裝配置postfix
①安裝postfix
# wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-3.0.2.tar.gz # tar -zxvf postfix-3.0.2.tar.gz # cd postfix-3.0.2/ # 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' ###CCARGS參數:爲編譯器提供額外的參數 ###AUXLIBS參數:指出位於標準位置以外的額外函數庫 ### -DUSE:使其可以使用SASL、TLS功能 ###-I:指出標準的額外頭文件的存放目錄 ###-DHAS_MYSQL:使其支持MySQL驅動 ###-lz=====>壓縮庫文件 ###-lm=====>模塊文件 # make # make install install_root: [/] ##指定postfix的安裝目錄 tempdir: [/root/postfix-3.0.2] /tmp/postfix ##指定臨時文件目錄 config_directory: [/etc/postfix] ##指定配置文件目錄 command_directory: [/usr/sbin] ##指定命令文件目錄 daemon_directory: [/usr/libexec/postfix] ##指定守護進程目錄 data_directory: [/var/lib/postfix] ##指定數據文件目錄 html_directory: [no] /var/www/html/postfix ##指定HTML的目錄 mail_owner: [postfix] ##指定postfix的全部者隊列 mailq_path: [/usr/bin/mailq] ##指定mailq命令的路徑 manpage_directory: [/usr/local/man] ##指定man手冊安裝目錄 newaliases_path: [/usr/bin/newaliases] queue_directory: [/var/spool/postfix] readme_directory: [no] sendmail_path: [/usr/sbin/sendmail] setgid_group: [postdrop] shlib_directory: [no] ##指定共享庫文件 meta_directory: [/etc/postfix] ##指定可執行文件目錄
編譯出現的錯誤1:
make -f Makefile.in MAKELEVEL= Makefiles (echo "# Do not edit -- this file documents how Postfix was built for your machine."; /bin/sh makedefs) >makedefs.tmp makedefs:行726: gcc: 未找到命令 make: *** [Makefiles] 錯誤 1 make: *** [makefiles] 錯誤 2
未安裝gcc
編譯出現的錯誤2:
make -f Makefile.in MAKELEVEL= Makefiles (echo "# Do not edit -- this file documents how Postfix was built for your machine."; /bin/sh makedefs) >makedefs.tmp No <db.h> include file found. Install the appropriate db*-devel package first. make: *** [Makefiles] 錯誤 1 make: *** [makefiles] 錯誤 2
在編譯時出現上述錯誤的緣由是相應軟件包沒有安裝徹底形成的,至於網絡上所說的安裝DB4-devel包之類的不靠譜,libdb4(Berkeley DB)安裝後依然報如上錯誤。
②啓動postfix
問題1:
# postfix start postfix/postfix-script: warning: not owned by postfix: /var/lib/postfix/. postfix/postfix-script: warning: not owned by postfix: /var/lib/postfix/./master.lock postfix/postfix-script: warning: not owned by postfix: /var/spool/postfix/private postfix/postfix-script: warning: not owned by postfix: /var/spool/postfix/public postfix/postfix-script: warning: not owned by group postdrop: /var/spool/postfix/public postfix/postfix-script: starting the Postfix mail system postfix/postfix-script: fatal: mail system startup failed
解決方法:
# chown -R postfix.postfix /var/lib/postfix/./master.lock # chown -R postfix.postfix /var/spool/postfix/private # chown -R postfix.postdrop /var/spool/postfix/public # postfix start
問題2:
# postfix start postfix/postfix-script: warning: not owned by postfix: /var/lib/postfix/. postfix/postfix-script: starting the Postfix mail system postfix/postfix-script: fatal: mail system startup failed
解決方法:
# chown -R postfix.postfix /var/lib/postfix/.
③生成別名二進制文件:
# newaliases
3、配置postfix並測試
①配置postfix
# vi /etc/postfix/main.cf myhostname = mail.zhi.com #設定Mail服務器域名 mydomain = zhi.com ##指定域名 myorigin = zhi.com ##指定發件人地址 inet_interfaces = all ##指定postfix系統監聽的網絡接口 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ##指定postfix接收郵件時收件人的域名 mynetworks_style = subnet ##指定信任網段類型,即容許轉發的來源網段,可選subnet子網,class 網段,host本機 mynetworks = 192.168.10.0/24, 127.0.0.0/8 ##容許轉發的來源IP relay_domains = $mydestination ## 指定容許中轉郵件的域名 inet_protocols = ipv4 ##指定支持的協議
注:主機名需與Mail服務器域名一致
②snmp登陸並測試郵件發送:
[root@mail ~]# telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 mail.zhi.com ESMTP Postfix ehlo localhost ##握手 250-mail.zhi.com 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:sd@localhost ##指定接收郵件的帳號 250 2.1.5 Ok data ##輸入data命令,開始寫郵件 354 End data with <CR><LF>.<CR><LF> Subject:test postfix ##郵件主題 hello ##內容 . ##表示郵件完成 250 2.0.0 Ok: queued as A49F33EA87E quit ##退出 221 2.0.0 Bye Connection closed by foreign host.
③查看是否收到郵件:
$ sudo mail ##進入該用戶,sudo到mail查看 Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/spool/mail/sd": 1 message 1 new ##提示有一封新郵件 >N 1 root@localhost Fri Sep 11 11:30 15/452 "t test postfix" ##郵件列表 & 1 ##輸入1進行查看,有多封郵件時,輸入對應編號便可查看 Message 1: From root@localhost Fri Sep 11 11:30:46 2015 Return-Path: <root@localhost> X-Original-To: sd@localhost Delivered-To: sd@localhost Subject:tr Subject:test postfix Date: Fri, 11 Sep 2015 11:29:08 +0800 (CST) From: root@localhost Status: R hello
4、配置DNS服務器
①測試郵件發送
[root@mail ~]# telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 mail.zhi.com ESMTP Postfix helo localhost 250 mail.zhi.com ehlo localhost 250-mail.zhi.com 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250 SMTPUTF8 mail from:admin@google.com 250 2.1.0 Ok rcpt to:sd@zhi.com 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> subject : google hello,welcome to google...... . 250 2.0.0 Ok: queued as 606F53EA87E quit 221 2.0.0 Bye Connection closed by foreign host.
②登陸該用戶進行查看
$ sudo mail Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/spool/mail/sd": 2 messages 1 unread 1 root@localhost Fri Sep 11 11:30 16/463 "t test postfix" >U 2 admin@google.com Fri Sep 11 13:41 15/469 "google" & 2 Message 2: From admin@google.com Fri Sep 11 13:41:45 2015 Return-Path: <admin@google.com> X-Original-To: sd@zhi.com Delivered-To: sd@zhi.com subject: google Date: Fri, 11 Sep 2015 13:40:04 +0800 (CST) From: admin@google.com Status: RO hello,welcome to google......
注:這裏顯示是Google發來的郵件,但事實並非這樣,全部咱們須要DNS來防止地址僞造
③安裝Bind服務器並配置
# yum install bind bind-utils # vi /etc/named.conf # listen-on port 53 { 127.0.0.1; }; # listen-on-v6 port 53 { ::1; }; ##註釋或刪除以上兩行 # vi /etc/named.rfc1912.zones ##配置區域文件 zone "zhi.com" IN { ##定義正向區域 type master; ##定義爲主域名服務器 file "zhi.com.zone"; ##指定區域資源文件位置 allow-update { none; }; ##禁止更新 allow-transfer { none;}; ##禁止區域傳送 }; zone "10.168.192.in-addr.arpa" IN { ##定義反向區域 type master; file "192.168.10.zone"; allow-update { none; }; allow-transfer { none;}; }; # named-checkconf /etc/named.conf ##檢測配置 # cd /var/named/ # vi zhi.com.zone ##新建區域資源文件位置 $TTL 600 @ IN SOA ns.zhi.com admin.zhi.com. ( 2015091111 2H 10M 3D 1D) IN NS ns IN MX 10 mail www IN A 192.168.10.128 ns IN A 192.168.10.128 mail IN A 192.168.10.128 # cp zhi.com.zone 192.168.10.zone # vi 192.168.10.zone $TTL 600 @ IN SOA ns.zhi.com admin.zhi.com. ( 2015091111 2H 10M 3D 1D) IN NS ns.zhi.com. 1 IN PTR ns.zhi.com 1 IN PTR mail.zhi.com 1 IN PTR www.zhi.com # named-checkzone "zhi.com" zhi.com.zone zone zhi.com/IN: loaded serial 2015091111 OK # named-checkzone "10.168.192.in-addr.arpa" 192.168.10.zone zone 10.168.192.in-addr.arpa/IN: loaded serial 2015091111 OK
出現的錯誤:
# named-checkzone "10.168.192.in-addr.arpa" 192.168.10.zone zone 10.168.192.in-addr.arpa/IN: NS 'ns.zhi.com.10.168.192.in-addr.arpa' has no address records (A or AAAA) zone 10.168.192.in-addr.arpa/IN: not loaded due to errors.
緣由:區域資源文件編輯不完整,切記NS記錄後域名的「.」。
④更改權限並啓動Bind
# chgrp named zhi.com.zone 192.168.10.zone ##更改組名 # chmod 640 zhi.com.zone 192.168.10.zone ##更改權限 # named-checkzone "zhi.com" zhi.com.zone ##檢查語法 # named-checkzone "10.168.192.in-addr.arpa" 192.168.10.zone # systemctl start named.service # chkconfig named on
⑤測試DNS
# dig -t MX zhi.com @192.168.10.128 ##查看MX記錄
# dig -t A mail.zhi.com ##查詢A記錄
# dig -t A mail.zhi.com @192.168.10.128
# dig -x 192.168.10.128 @192.168.10.128 ##查看反向解析
問題及解決方法:
# dig -t MX zhi.com @192.168.10.128 ; <<>> DiG 9.9.4-RedHat-9.9.4-18.el7_1.5 <<>> -t MX zhi.com @192.168.10.128 ;; global options: +cmd ;; connection timed out; no servers could be reached # vi /etc/named.conf # listen-on port 53 { 127.0.0.1; }; # listen-on-v6 port 53 { ::1; }; ##監聽IP出錯,更改或將該兩行註釋、刪除 # systemctl restart named.service
5、爲postfix開啓基於cyrus-sasl的認證功能
①驗證postfix是否支持cyrus風格的sasl認證
# /usr/sbin/postconf -a cyrus dovecot
②配置postfix
# vi /etc/postfix/main.cf ############################CYRUS-SASL############################ broken_sasl_auth_clients = yes ##使用SSL驗證客戶端身份 smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination ###收件人限定 smtpd_sasl_auth_enable = yes ##啓用SSL認證 smtpd_sasl_local_domain = $myhostname ##SSL認證的本地域 smtpd_sasl_security_options = noanonymous ##不支持匿名用戶 smtpd_sasl_path = smtpd ##指定需使用SSL認證的程序 smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available! ##歡迎信息
# vi /usr/lib64/sasl2/smtpd.conf ##新建文件並添加以下 pwcheck_method: saslauthd ##指定密碼檢查方法 mech_list: PLAIN LOGIN ##指定認證機制
# postfix reload ##從新加載postfix postfix/postfix-script: refreshing the Postfix mail system # systemctl start saslauthd.service
③驗證一下
# telnet localhost 25 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 Welcome to our localhost.localdomain ESMTP,Warning: Version not Available! ehlo mail.zhi.com 250-localhost.localdomain 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN ##出現以上兩行說明cyrus-sasl認證功能已添加成功 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250 SMTPUTF8 quit 221 2.0.0 Bye Connection closed by foreign host.
6、安裝Courier authentication library
①安裝courier-unicode
# wget http://nchc.dl.sourceforge.net/project/courier/courier-unicode/1.3/courier-unicode-1.3.tar.bz2 # tar -jxvf courier-unicode-1.3.tar.bz2 # cd courier-unicode-1.3 # ./confgure # make # make install
錯誤1:如configure出現/libtool: line 1125: g++: command not found是因爲缺乏gcc的C++模塊,
yum install gcc-c++便可。
錯誤2:courier-unicode-1.4是剛推出的,CentOS7系統configure時老出錯,換成1.3版本即編譯成功。
注:編譯安裝courier-authlib時會提示安裝該程序,我第二次安裝時先編譯該程序後再編譯courier-authlib,提示找不到文件或目錄,不能進行指定,全部最好仍是先編譯courier-authlib,等提示了在編譯courier-unicode。
②安裝courier-authlib
# wget http://nchc.dl.sourceforge.net/project/courier/authlib/0.66.3/courier-authlib-0.66.3.tar.bz2 # tar -jxvf courier-authlib-0.66.3.tar.bz2 # cd courier-authlib-0.66.3/ #./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 # make # make install
# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon # cp /etc/authdaemonrc.dist /etc/authdaemonrc # cp /etc/authmysqlrc.dist /etc/authmysqlrc
# vi /etc/authdaemonrc ##修改以下內容 authmodulelist="authmysql" authmodulelistorig="authmysql" daemons=10
③配置其經過mysql進行郵件賬號認證
# vi /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 mailx MYSQL_CRYPT_PWFIELD password 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)
④添加相關係統服務
# cd courier-authlib-0.66.3/ # cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib ##添加服務腳本 # chmod 755 /etc/init.d/courier-authlib # chkconfig --add courier-authlib # chkconfig courier-authlib on # echo "/usr/local/courier-authlib/lib/courier-authlib" >>/etc/ld.so.conf.d/courier-authlib.conf ##添加庫文件 # ldconfig -v |grep courier ##查看庫文件是否載入 /usr/local/courier-authlib/lib/courier-authlib: libcourierauthcommon.so -> libcourierauthcommon.so libcourierauthsaslclient.so -> libcourierauthsaslclient.so libcourierauthsasl.so -> libcourierauthsasl.so libcourierauth.so -> libcourierauth.so # systemctl start courier-authlib.service ##開啓服務 # ps -aux |grep courier ##查看進程是否啓動
⑤配置postfix和courier-authlib
新建虛擬用戶郵箱所在的目錄,並將其權限賦予postfix用戶:
# mkdir –pv /var/mailbox # chown -R postfix /var/mailbox # vi /usr/lib64/sasl2/smtpd.conf ##增長以下內容 log_level: 3 authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
7、配置postfix支持虛擬域和虛擬用戶
編輯/etc/postfix/main.cf文件,添加以下:
# vi /etc/postfix/main.cf ########################Virtual Mailbox Settings######################## virtual_mailbox_base = /var/mailbox virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf virtual_alias_domains = virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf virtual_uid_maps = static:2525 virtual_gid_maps = static:2525 virtual_transport = virtual maildrop_destination_recipient_limit = 1 maildrop_destination_concurrency_limit = 1 ##########################QUOTA Settings######################## message_size_limit = 14336000 virtual_mailbox_limit = 20971520 virtual_create_maildirsize = yes virtual_mailbox_extended = yes virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf virtual_mailbox_limit_override = yes virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later. virtual_overquota_bounce = yes
8、配置dovecot
# vi /etc/dovecot/dovecot.conf ##添加以下內容 protocols = imap pop3 mail_location = maildir:/var/mailbox/%d/%n/Maildir …… auth default { mechanisms = plain passdb sql { args = /etc/dovecot-mysql.conf } userdb sql { args = /etc/dovecot-mysql.conf } ……
# vi /etc/dovecot/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'
# systemctl start dovecot.service # chkconfig dovecot on
9、安裝extman和extmail
①下載extman和extmail
# wget http://7xivyw.com1.z0.glb.clouddn.com/extmail-1.2.tar.gz # wget http://7xivyw.com1.z0.glb.clouddn.com/extman-1.1.tar.gz
②建立目錄並解壓extmail
# mkdir -p /var/www/extsuite # tar -zxvf extmail-1.2.tar.gz # mv extmail-1.2 /var/www/extsuite/extmail # chown -R postfix.postfix /var/www/extsuite/extmail/cgi/ ##修改extmail的cgi目錄的屬主和屬組
③配置extmail
# cd /var/www/extsuite/extmail/ # cp webmail.cf.default webmail.cf # vi webmail.cf SYS_SESS_DIR=/tmp/extmail SYS_UPLOAD_TMPDIR=/tmp/extmail/upload SYS_USER_LANG=zh_CN ##修改web界面顯示的語言 SYS_MESSAGE_SIZE_LIMIT = 5242880 ##用戶磁盤空間(默認5M) SYS_MAILDIR_BASE = /var/mailbox ##修改成前文中所設置的用戶郵件的存放目錄 SYS_MYSQL_USER = extmail SYS_MYSQL_PASS = extmail ##修改鏈接數據庫的用戶名和密碼 SYS_MYSQL_HOST = localhost ##指定數據庫主機名 SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock ##鏈接數據庫的sock文件的存放位置 SYS_MYSQL_TABLE = mailbox SYS_MYSQL_ATTR_USERNAME = username SYS_MYSQL_ATTR_DOMAIN = domain SYS_MYSQL_ATTR_PASSWD = password SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket ##指明authdaemon socket 的文件存放位置
④解決依賴關係
# yum install perl-Unix-Syslog
注:如無本軟件,登陸extmail頁面時會提示錯誤,提示安裝該軟件。
如直接yum沒有包,能夠添加第三方yum源EPEL進行下載,方法參見本博。
⑤安裝並配置extman
# tar -zxvf extman-1.1.tar.gz -C /var/www/extsuite/ # cd /var/www/extsuite/ # mv extman-1.1 extman # cd extman # cp webman.cf.default webman.cf # vi webman.cf SYS_MAILDIR_BASE = /var/mailbox ##改成前文中所設置的用戶郵件的存放目錄 SYS_CAPTCHA_ON = 0 ##關閉驗證碼 SYS_DEFAULT_SERVICES = webmail,smtpd,smtp,pop3,netdisk,imap ##添加對imap協議的支持 SYS_DEFAULT_UID = 2525 ##設置用戶ID SYS_DEFAULT_GID = 2525 ##設置用戶組的ID SYS_MYSQL_USER = extmail SYS_MYSQL_PASS = extmail ##鏈接數據庫的用戶名和密碼 SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock ##鏈接數據庫的sock文件的存放位置 # chown -R postfix.postfix /var/www/extsuite/extman/cgi##修改extman 的cgi目錄的屬主和屬組 # mkdir -pv /tmp/extman # chown postfix.postfix /tmp/extman
# cp /var/www/extsuite/extman/docs/mysql_virtual_* /etc/postfix/ ##拷貝支持虛擬域和虛擬用戶所用到的配置文件 # cd /var/www/extsuite/extman/docs # sed -i 's/TYPE=MyISAM/ENGINE=MyISAM/g' extmail.sql # sed -i 's/TYPE=MyISAM/ENGINE=MyISAM/g' init.sql ##對以上兩文件進行更改,否則會導入錯誤 # mysql -u root -p < extmail.sql # mysql -u root -p < init.sql ##導入以上兩文件至MySQL數據庫 # mysql -u root ##這裏咱們是默認的,沒有密碼 mysql> grant all on extmail.* to extmail@'localhost' identified by 'extmail'; mysql> grant all on extmail.* to extmail@'127.0.0.1' identified by 'extmail'; mysql> flush privileges; ##授予extmail用戶訪問extmail數據庫權限並刷新權限
注:啓用虛擬域後,需取消中心域,即註釋掉myhostname, mydestination, mydomain, myorigin幾個指令
問題:
# mysql -u root -p < extmail.sql Enter password: ERROR 1364 (HY000) at line 31: Field 'ssl_cipher' doesn't have a default value
解決方法:
# vi /etc/my.cnf 將sql-mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 更改成sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION # systemctl restart mysql.service
⑥重啓postfix
# postfix stop # postfix check ##進行配置檢查 # postfix start
10、配置httpd服務器
# vi /etc/httpd/conf/httpd.conf User postfix Group postfix <VirtualHost *:80> ServerName mail.zhi.com DocumentRoot /var/www/extsuite/extmail/html/ ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi Alias /extmail /var/www/extsuite/extmail/html ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi Alias /extman /var/www/extsuite/extman/html </VirtualHost> #DocumentRoot /var/www/html ##註釋掉該行 # systemctl start httpd.service
# vi /etc/hosts 127.0.0.1 mail.zhi.com
在瀏覽器中輸入mail.zhi.com:
提示:Unix::Syslog not found, please install it first!
解決方法:在第九部分安裝extman和extmail中已經說過了,直接yum install perl-Unix-Syslog
刷新進入extmail頁面
輸入用戶名和密碼登陸郵箱管理【默認用戶名:root@extmail.org;默認密碼:extmail*123*】
登陸郵箱管理後出現的問題:
Can't open /tmp/extman//sid_c81e7e25d1009368071502ec9842fac0, No such file or directory
緣由:extman的臨時文件默認是放到/tmp/extman下的,CentOS、RHEL會不按期清理tmp文件夾下的文件
解決方法:
# mkdir -p /var/www/extsuite/extman/session # chmod 777 -R /var/www/extsuite/extman/session # vi /var/www/extsuite/extman/webman.cf SYS_SESS_DIR = /var/www/extsuite/extman/session
成功登陸後臺
新建用戶並測試
這裏顯示已經收到郵件
測試發送郵件至163郵件
(因爲咱們的域名並不存在,其餘如QQ郵箱等會將郵件當垃圾郵件攔截,沒法發送,仍是163人性化)
也能發送成功,固然因爲咱們的域名不存在,因此沒法回信了
問題1:
# tail -f /var/log/httpd/error_log Prototype mismatch: sub Encode::IMAPUTF7::decode ($$;$) vs none at /var/www/extsuite/extman/libs/Encode/IMAPUTF7.pm line 76
解決方法:
# wget https://cpan.metacpan.org/authors/id/P/PM/PMAKHOLM/Encode-IMAPUTF7-1.05.tar.gz # tar -zxvf Encode-IMAPUTF7-1.05.tar.gz # cd Encode-IMAPUTF7-1.05/ # perl Makefile.PL # cd lib/Encode/ # cp IMAPUTF7.pm /var/www/extsuite/extman/libs/Encode/ # systemctl restart httpd.service
問題2:
新建用戶後登陸提示:
Insecure dependency in sprintf while running with -T switch at /usr/lib64/perl5/vendor_perl/Unix/Syslog.pm line 59.
解決方法:
# vi /var/www/extsuite/extmail/cgi/index.cgi #!/usr/bin/perl -wT ##將該行的T去掉便可
問題3:
登陸後臺管理系統沒法顯示系統信息,提示No such file or directory,安裝網絡上說的
# ps aux | grep cmdserver
# kill -9 xxxx
# /var/www/extsuite/extman/daemon/cmdserver -v -d
並未解決問題,不知道是否是版本久遠的緣由啊
附1:該處內容更爲完備:
http://blog.chinaunix.net/uid-23914782-id-2856289.html
附2:Ubuntu關於postfix的wiki:
http://wiki.ubuntu.org.cn/Postfix
http://wiki.ubuntu.org.cn/Postfix_%E5%9F%BA%E6%9C%AC%E8%AE%BE%E7%BD%AE%E6%8C%87%E5%8D%97
http://my.oschina.net/baratsemet/blog/413923