<b>郵件服務系列</b><b>-- postifx+sasl+dovecot+webmail+webmain</b><b>架構</b>
文章内容:介紹的是郵件服務系列配置中 postifx+sasl+dovecot+虛拟域+虛拟使用者+webmail+webman綜合實作
首先來解釋下郵件服務大概流程,如圖:
<a href="http://blog.51cto.com/attachment/201305/203758414.png" target="_blank"></a>
具體的示意圖(權威版的)
<a href="http://blog.51cto.com/attachment/201305/203848613.png" target="_blank"></a>
首先先來掃下盲,介紹下圖中字母的意思:
SMTP:Simple Mail Tansfer Protocol 郵件傳輸協定
SMTPD: 郵件傳輸伺服器端
MUA:郵件使用者代理 mail user agent
傳送給SMTPD(MTA:transfer agent)如果是本地調用lmtp localmail tp協定
如果不是調用SMTP,然後~
MDA:mail delivery agent郵件投遞代理
當郵件到達本地*D的時候,則調用自己的MDA傳送給使用者郵筒中
SASL: Simple Authinitication Secure Layer, 簡單認證安全層
DOVECOT:中文成為鴿子籠,也就是郵箱的意思
實驗過程簡介圖:
<a href="http://blog.51cto.com/attachment/201305/204049800.png" target="_blank"></a>
安裝前的準備工作
配置yum庫後安裝開發工具與開發庫
[root@localhost ~]# yum groupinstall "Development Tools" "Development Libraries" –y
安裝實驗中所有依賴的軟體包(這些都是在編譯的時候報錯時報告所依賴的;是以這裡就直接安裝了,這些包在紅帽系統自身帶的就有)
#yum install httpd openssl-devel perl-DBD-MySQL, tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect(主機間通信)
這些安裝包是在後面進行相關軟體中需要依賴的,這裡就直接安裝了(怕遇到問題的提前安裝,到具體過程筆者再講述他們的依賴關系)
DNS配置
前提:要提前安裝httpd,後邊要用到,并且這個步驟要用到測試:
[root@localhost ~]# yum install httpd -y
##紅帽5.8上面有新版本bind97,但是已經安裝了bind93,是以這裡先解除安裝bind93
[root@localhost ~]# rpm -e bind-utils bind-libs
[root@localhost ~]# yum install bind97 bind97-libs bind97-utils –y
修改named.conf配置檔案
修改options中定義的初始的幾個片段,保留以下内容
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursion yes;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
};
##然後在下面添加zone
zone "doubao.com" {
type master;
file "doubao.com.zone";
};
zone "111.16.172.in-addr.arpa" {
file "172.16.111.zone";
:wq 儲存退出
然後去編輯正向、反向區域配置檔案
[root@localhost ~]# vim /var/named/doubao.com.zone
##//添加内容:
$TTL 86400
@ IN SOA ns.doubao.com. admin.doubao.com. (
2013042801
2H
5M
3D
7D )
IN NS ns
IN MX 10 mail
ns IN A 172.16.111.3
mail IN A 172.16.111.3
www IN A 172.16.111.3
:wq
[root@localhost ~]# vim /var/named/172.16.111.zone
IN SOA ns.doubao.com. admin.doubao.com. (
IN NS ns.doubao.com.
3 IN PTR ns.doubao.com.
3 IN PTR mail.doubao.com.
3 IN PTR www.doubao.com.
修改權限、添加開機啟動服務
[root@localhost named]# chgrp named doubao.com.zone
[root@localhost named]# chgrp named 172.16.111.zone
[root@localhost named]# chmod 640 doubao.com.zone
[root@localhost named]# chmod 640 172.16.111.zone
[root@localhost named]# chkconfig --add named
[root@localhost named]# chkconfig named on
[root@localhost named]# chkconfig --list named
named 0:off 1:off 2:on 3:on 4:on 5:on 6:off
resolv.conf配置檔案中預設DNS
[root@localhost named]# vim /etc/resolv.conf
##//修改成如下所示
nameserver 172.16.111.3
search localdomain
(與mail伺服器域名保持一緻)
[root@localhost named]# vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=mail.doubao.com
GATEWAY=172.16.0.1
[root@localhost named]# vim /etc/hosts
[root@localhost named]# hostname mail.doubao.com
[root@localhost named]# hostname
mail.doubao.com
##//編輯Hosts檔案。去增加主機名:
[root@mail httpd]# vim /etc/hosts
172.16.111.3 mail.doubao.com
然後啟動DNS伺服器
[root@mail httpd]# service httpd start
Starting httpd: [ OK ]
[root@mail httpd]# service named restart
Starting named: [ OK ]
然後到實體機的hosts檔案修改,增加解析路徑能打開網頁測試
檔案路徑:C槽àWindowsàSystem32àdriversàetcàhosts
172.16.111.3 mail.doubao.com
然後打開IE,輸入172.16.111.3或者mail.doubao.com來測試下網頁
<a href="http://blog.51cto.com/attachment/201305/204417131.png" target="_blank"></a>
mysql
前提:需要安裝perl-DBD-MySQL
[root@mail httpd]# yum install perl-DBD-MySQL
##使用的是系統自帶rpm包
[root@mail httpd]# yum install mysql-server mysql-devel –y
##啟動mysql資料庫
[root@mail httpd]# service mysqld start
連接配接測試
<a href="http://blog.51cto.com/attachment/201305/204530483.png" target="_blank"></a>
postfix
關閉sedmail
紅帽5.8系統上sendmail服務預設是開啟的需要手動關閉它,它會影響postfix的服務的運作
[root@mail httpd]# service sendmail stop
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
[root@mail httpd]# chkconfig sendmail off
建立postfix使用者postfix組以及postdrop使用者postdrop組
[root@mail httpd]# groupadd -g 2525 postfix
[root@mail httpd]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
[root@mail httpd]# groupadd -g 2526 postdrop
[root@mail httpd]# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
使用的源碼包版本是postfix-2.9.6,在編譯安裝的之前要使用date指令檢視一下自己系統的的時間;因為在虛拟機中的linux系統很多都是挂起的,會導緻時間錯誤;如果軟體包的開發時間在系統時間的後面,這會讓我們的系統變得淩亂的
[root@mail httpd]# hwclock –s ##//将硬體時間同步到系統時間
##開始編譯(事先将postfix-2.9.6.tar.gz放入linux中)
[root@mail ~]# cd /usr/local/src
[root@mail src]# tar xf postfix-2.9.6.tar.gz
[root@mail src]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto'
[root@mail src]# make && make install
##在執行make install指令後,會讓選擇一些預設的路徑的安裝位置:(下面跟實驗過程中的順序也許會有點不一樣)
install_root: [/] / ------postfix安裝路徑
tempdir: [/root/postfix-2.9.3] /tmp/postfix ------臨時檔案的生成目錄
config_directory: [/etc/postfix] /etc/postfix -------配置檔案目錄
daemon_directory: [/usr/libexec/postfix] -------服務程序目錄
command_directory: [/usr/sbin] ------bash指令目錄
queue_directory: [/var/spool/postfix] ---郵件隊列
sendmail_path: [/usr/sbin/sendmail] ---smtp的用戶端,用于實作與sendmail用戶端相容的
newaliases_path: [/usr/bin/newaliases] ---生成新别名
mailq_path: [/usr/bin/mailq] ---郵件隊列程式
mail_owner: [postfix] ---郵件伺服器的運作者
setgid_group: [postdrop] ---用于實作将使用者的郵件投遞到它的郵箱中去的
html_directory: [no]/var/www/html/postfix ---當web伺服器沒有配置好就使用no選項
manpages: [/usr/local/man] ---man文檔的安裝路徑
readme_directory: [no] ---幫助文檔
data_directory:[/var/lib/postfix] ---可讀寫檔案的存放路徑
生成别名二進制檔案:
[root@mail src]# newaliases
##newaliases 的功能傳是将 /etc/aliases 轉換成其所能了解、處理的資料庫
postfix服務腳本
為postfix提供SysV服務腳本/etc/rc.d/init.d/postfix,内容如下(#END 之前):
[root@mail src]# vim /etc/rc.d/init.d/postfix
##//内容
#!/bin/bash
#
# postfix Postfix Mail Transfer Agent
# chkconfig: 2345 80 30
# description: Postfix is a Mail Transport Agent, which is the program \
# that moves mail from one machine to another.
# processname: master
# pidfile: /var/spool/postfix/pid/master.pid
# config: /etc/postfix/main.cf
# config: /etc/postfix/master.cf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ $NETWORKING = "no" ] && exit 3
[ -x /usr/sbin/postfix ] || exit 4
[ -d /etc/postfix ] || exit 5
[ -d /var/spool/postfix ] || exit 6
RETVAL=0
prog="postfix"
start() {
# Start daemons.
echo -n $"Starting postfix: "
/usr/bin/newaliases >/dev/null 2>&1
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog
start"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
echo
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Shutting down postfix: "
/usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog
stop"
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
echo
reload() {
echo -n $"Reloading postfix: "
/usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog
reload"
abort() {
/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog
abort"
return $?
flush() {
/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog
flush"
check() {
/usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog
check"
restart() {
stop
start
# See how we were called.
case "$1" in
start)
;;
stop)
restart)
reload)
reload
abort)
abort
flush)
flush
check)
check
status)
status master
condrestart)
[ -f /var/lock/subsys/postfix ] && restart || :
*)
echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|
condrestart}"
exit 1
esac
exit $?
# END
為此腳本賦予執行權限、将postfix服務添加至服務清單、開機自動啟動
[root@mail src]# chmod +x /etc/rc.d/init.d/postfix
[root@mail src]# chkconfig --add postfix
[root@mail src]# chkconfig postfix on
編輯postfix的配置檔案main.cf,修改以下幾項為您需要的配置
myhostname = mail.doubao.com ##------指定自己的郵件伺服器
myorigin = doubao.com ##------自己建立的域名
mydomain = doubao.com ##-----定義出站郵件使用的域名
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ##定義哪些域接收郵件
mynetworks = 192.168.1.0/24, 127.0.0.0/8 ##--------定義允許中繼的網絡
啟動postfix、進行測試
[root@mail src]# service postfix start
Starting postfix: [ OK ]
建立一個使用者用于測試郵件的收發
[root@mail src]# useradd hadoop && echo "hadoop" |passwd --stdin hadoop
連接配接到郵件伺服器進行測試發送
[root@mail src]# telnet mail.doubao.com 25
<a href="http://blog.51cto.com/attachment/201305/204846715.png" target="_blank"></a>
檢視郵件是否接收
<a href="http://blog.51cto.com/attachment/201305/204900120.png" target="_blank"></a>
dovecot
安裝dovecot軟體包
[root@mail ~]# yum install dovecot -y
##更改protocols保留需要的協定
[root@mail ~]# vim /etc/dovecot.conf
##添加dovecot到服務清單并啟動dovecot服務
[root@mail ~]# chkconfig --add dovecot
[root@mail ~]# chkconfig dovecot on
[root@mail ~]# chkconfig --list dovecot
dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail ~]# service dovecot start
測試郵件的是否可以成功接受
[root@mail ~]# telnet mail.doubao.com 25
<a href="http://blog.51cto.com/attachment/201305/205049110.png" target="_blank"></a>
到這裡 就要開啟虛拟機window 2003 登入上去設定好IP位址(172.16網段的)
然後進行收郵件的實驗:
<a href="http://blog.51cto.com/attachment/201305/205114754.png" target="_blank"></a>
<a href="http://blog.51cto.com/attachment/201305/205201583.png" target="_blank"></a>
<a href="http://blog.51cto.com/attachment/201305/205229841.png" target="_blank"></a>
然後完成檢視收件箱
<a href="http://blog.51cto.com/attachment/201305/205251864.png" target="_blank"></a>
這樣。就完成了郵件的收發
postfix開啟基于cyrus-sasl的認證功能
編輯saslauthd配置檔案,用來使用sasl認證
[root@mail ~]# vim /etc/sysconfig/saslauthd
##//将内容做一下修改
MECH=shadow ##//把原來的pam改成shadow,讓其從/etc/shadow中檢索賬号
将其添加到服務清單中,并啟動測試
[root@mail ~]# chkconfig --add saslauthd
[root@mail ~]# chkconfig saslauthd on
[root@mail ~]# chkconfig --list saslauthd
saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail ~]# service saslauthd start
Starting saslauthd: [ OK ]
##//做一下檢索賬号的測試
[root@mail ~]# testsaslauthd -uhadoop -phadoop
0: OK "Success."
編輯sasl配置檔案smtpd.conf
注:這裡Postfix是借助SASL來提供認證功能,SASL為其提供一個smtpd.conf配置檔案。這裡要進行配置。
[root@mail ~]# vim /usr/lib/sasl2/smtpd.conf
##//添加如下内容
pwcheck_method: saslauthd ##讓postfix知道要通過saslauthd來實作使用者認證
mech_list: PLAIN LOGIN ##真正要完成認證的功能是誰
儲存退出。
##//這個時候需要重新開機下讓其生效
編輯postfix配置檔案
[root@mail ~]# vim /etc/postfix/main.cf
############################CYRUS-SASL############################
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
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpdsmtpd_sasl_path = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
儲存退出
讓postfix重新加載配置檔案
[root@mail ~]# /usr/sbin/postfix reload
postfix/postfix-script: refreshing the Postfix mail system
然後進行測試:
<a href="http://blog.51cto.com/attachment/201305/205436442.png" target="_blank"></a>
webmail與webman的實作
courier-authlib
PS:這裡使用的是courier-authlib-0.64.0.tar,請事先下載下傳好放入linux中
[root@mail ~]# tar xf courier-authlib-0.64.0.tar.bz2
[root@mail ~]# cd courier-authlib-0.64.0
[root@mail courier-authlib-0.64.0]# ./configure \
--prefix=/usr/local/courier-authlib \ -----檔案的安裝路徑
--sysconfdir=/etc \ -----配置檔案的安裝位置
--without-authpam \
--without-authshadow \
--without-authvchkpw \
--without-authpgsql \ -----不支援pam/shadow/vchkpw/pgsql認證,這些選項不添加也可以
--with-authmysql \ ----支援mysql認證(重要就是支援者一項)
--with-mysql-libs=/usr/lib/mysql \ ------指明mysql的庫檔案路徑的安裝位置
--with-mysql-includes=/usr/include/mysql \ -------指明mysql的頭檔案的安裝路徑
--with-redhat \ ------說明系統類型
--with-authmysqlrc=/etc/authmysqlrc \ -----指定courier-authlib服務程序配置檔案路徑
--with-authdaemonrc=/etc/authdaemonrc \ -----守護程序,courier-authlib服務程序的配置檔案
--with-mailuser=postfix \ ----郵件收發管理的使用者
--with-mailgroup=postfix \ -----郵件收發管理的組
--with-ltdl-lib=/usr/lib \ -----ltdl動态子產品加載器,提供一個運作環境(對應了剛開始安裝的yum包)
--with-ltdl-include=/usr/include ----ltdl檔案的頭檔案路徑
[root@mail courier-authlib-0.64.0]# make && make install
改socket檔案的權限
[root@mail ~]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
把生成的配置檔案重新命名
[root@mail ~]# cp /etc/authdaemonrc.dist /etc/authdaemonrc
[root@mail ~]# cp /etc/authmysqlrc.dist /etc/authmysqlrc
修改/etc/authdaemonrc配置檔案
[root@mail ~]# vim /etc/authdaemonrc
authmodulelist="authmysql" -----指明認證的子產品
authmodulelistorig="authmysql" ------保留的原始子產品
daemons=10 ------預設啟動啟動的程序個數(根據需要修改)
DEBUG_LOGIN=2
編輯/etc/authmysqlrc配置檔案
##配置其通過mysql進行郵件帳号認證
MYSQL_SERVER localhost
MYSQL_PORT 3306 -----(指定你的mysql監聽的端口,這裡使用預設的3306)
MYSQL_USERNAME extmail ----- (這時為後文要用的資料庫的所有者的使用者名)
MYSQL_PASSWORD extmail ----- (密碼)
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password -----mysql中哪個字段是使用者密碼
MYSQL_UID_FIELD '2525'
MYSQL_GID_FIELD '2525'
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat('/var/mailbox/',homedir) -----使用者賬号的家目錄所在位置,虛拟使用者沒有家目錄,homedir是變量,等同于使用者名稱;concat是mysql内置的函數用于将兩個字元串連接配接起來
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir)
提供SysV服務腳本,為服務腳本添加執行權限并且添加到服務清單,設定開機啟動并啟動
[root@mail courier-authlib-0.64.0]# cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
[root@mail courier-authlib-0.64.0]# chmod 755 /etc/init.d/courier-authlib
[root@mail courier-authlib-0.64.0]# chkconfig --add courier-authlib
[root@mail courier-authlib-0.64.0]# chkconfig --level 2345 courier-authlib on
[root@mail courier-authlib-0.64.0]# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
[root@mail courier-authlib-0.64.0]# service courier-authlib start
Starting Courier authentication services: authdaemond
配置postfix和courier-authlib
建立虛拟使用者郵箱所在的目錄,并将其權限賦予postfix使用者
[root@mail ~]# mkdir –pv /var/mailbox
[root@mail ~]# chown -R postfix /var/mailbox
接下來重新配置SMTP 認證,編輯 /usr/lib/sasl2/smtpd.conf ,
[root@mail ~]# vim /usr/lib/sasl2/smtpd.conf
##確定其為以下内容
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
讓postfix支援虛拟域和虛拟使用者
編輯/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
virtualvirtual_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
##儲存退出
使用extman源碼目錄下docs目錄中的extmail.sql和init.sql建立資料庫
[root@mail ~]# tar xf extman-1.1.tar.gz ------事先準備~
[root@mail ~]# cd extman-1.1/docs/
[root@mail docs]# mysql -u root -p < extmail.sql -----密碼為空
Enter password:
[root@mail docs]# mysql -u root -p <init.sql
[root@mail docs]# cp mysql* /etc/postfix/
##//啟動mysql對使用者進行授權
[root@mail docs]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT all privileges on extmail.* TO [email protected] IDENTIFIED BY 'extmail';
說明:
1、啟用虛拟域以後,需要取消中心域,即注釋掉myhostname, mydestination, mydomain, myorigin幾個指令;當然,你也可以把mydestionation的值改為你自己需要的。
2、對于MySQL-5.1以後版本,其中的服務腳本extmail.sql執行會有文法錯誤;可先使用如下指令修改extmail.sql配置檔案,而後再執行。修改方法如下:
# sed -i 's@TYPE=MyISAM@ENGINE=InnoDB@g' extmail.sql
##需要逐個查找修改
mail_location = maildir:/var/mailbox/%d/%n/Maildir
auth default {
mechanisms = plain
passdb sql {
args = /etc/dovecot-mysql.conf
}
userdb sql {
[root@mail ~]# vim /etc/dovecot-mysql.conf
##添加如下内容
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = '%u'
說明:如果mysql伺服器是本地主機,即host=localhost時,如果mysql.sock檔案不是預設的/var/lib/mysql/mysql.sock,可以使用host=“sock檔案的路徑”來指定新位置;例如,使用通用二進制格式安裝的MySQL,其soc檔案位置為/tmp/mysql.sock,相應地,connect應按如下方式定義。
connect = host=/tmp/mysql.sock dbname=extmail user=extmail password=extmail
接下來啟動dovecot服務:
[root@mail ~]# service dovecot restart
Stopping Dovecot Imap: [ OK ]
Starting Dovecot Imap: [ OK ]
Extmail-1.2
說明:如果extmail的放置路徑做了修改,那麼配置檔案webmail.cf中的/var/www路徑必須修改為你所需要的位置。本文使用了預設的/var/www,是以,以下示例中并沒有包含路徑修改的相關内容。
1、安裝
[root@mail ~]# tar xf extmail-1.2.tar.gz
[root@mail ~ ]# mkdir -pv /var/www/extsuite
mkdir: created directory `/var/www/extsuite'
[root@mail ~]# mv extmail-1.2 /var/www/extsuite/extmail
[root@mail ~]# cp /var/www/extsuite/extmail/webmail.cf.default /var/www/extsuite/extmail/webmail.cf
2、修改主配置檔案
[root@mail ~]# vim /var/www/extsuite/extmail/webmail.cf
##部分修改選項的說明:
SYS_MESSAGE_SIZE_LIMIT = 5242880 ##使用者可以發送的最大郵件
SYS_USER_LANG = en_US
##語言選項,可改作:
SYS_USER_LANG = zh_CN
SYS_MAILDIR_BASE = /home/domains
##此處即為您在前文所設定的使用者郵件的存放目錄,可改作:
SYS_MAILDIR_BASE = /var/mailbox
SYS_MYSQL_USER = db_user
SYS_MYSQL_PASS = db_pass
##以上兩句句用來設定連接配接資料庫伺服器所使用使用者名、密碼和郵件伺服器用到的資料庫,這裡修改為:
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
##以上用來指定驗正使用者登入裡所用到的表,以及使用者名、域名和使用者密碼分别對應的表中列的名稱;這裡預設即可
SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket
##此句用來指明authdaemo socket檔案的位置,這裡修改為:
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
3、apache相關配置
由于extmail要進行本地郵件的投遞操作,故必須将運作apache伺服器使用者的身份修改為您的郵件投遞代理的使用者;本例中打開了apache伺服器的suexec功能,故使用以下方法來實作虛拟主機運作身份的指定。此例中的MDA為postfix自帶,是以将指定為postfix使用者:
##首先在/etc/httpd/conf/httpd.conf配置檔案中注釋中心主機
#DocumentRoot "/var/www/html"
##然後添加以下内容
<VirtualHost *:80>
ServerName mail.magedu.com
DocumentRoot /var/www/extsuite/extmail/html/
ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
Alias /extmail /var/www/extsuite/extmail/html
</VirtualHost>
##儲存退出。
修改 cgi執行檔案屬主為apache運作身份使用者:
[root@mail ~]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
[root@mail ~]# vim /etc/httpd/httpd.conf
User postfix
Group postfix
[root@mail ~]# vim /etc/httpd/conf/httpd.conf
4、依賴關系的解決
extmail将會用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜尋下載下傳原碼包進行安裝。
[root@mail ~]# tar zxvf Unix-Syslog-1.1.tar.gz
[root@mail ~]# cd Unix-Syslog-1.1
[root@mail Unix-Syslog-1.1]# perl Makefile.PL
[root@mail Unix-Syslog-1.1]# make && make install
5、啟動apache服務
[root@mail Unix-Syslog-1.1]# service httpd restart
Stopping httpd: [ OK ]
這時候打開IE來測試下
<a href="http://blog.51cto.com/attachment/201305/205942486.png" target="_blank"></a>
exman,使其能夠在apache伺服器通路;配置流程與extmail相似
首先建立webman使用者(在webman.cf配置檔案指定的預設使用者)
mysql建立webman
[root@mail ~]# mysql
mysql> GRANT ALL PRIVILEGES ON extmail.* TO webman@localhost IDENTIFIED BY 'webman';
mysql> GRANT ALL PRIVILEGES ON extmail.* TO [email protected] IDENTIFIED BY 'webman';
mysql> FLUSH PRIVILEGES;
[root@mail ~]# mv extman-1.1 /var/www/extsuite/extman
[root@mail ~]# cd /var/www/extsuite/extman/
[root@mail extman]# cp /var/www/extsuite/extman/webman.cf.default /var/www/extsuite/extman/webman.cf
編輯extman配置檔案
[root@mail extman]# vim /var/www/extsuite/extman/webman.cf
##修改内容
SYS_MAILDIR_BASE = /var/mailbox 修改郵箱位置
SYS_CAPTCHA_ON = 0 關閉驗證碼子產品
SYS_DEFAULT_UID = 2525
SYS_DEFAULT_GID = 2525 ##更改UID與GID(是postfixUID與其組的GID
修改完成,儲存退出 建立extman運作時所需的臨時目錄,并修改屬主屬組
[root@mail extman]# mkdir /tmp/extman
[root@mail extman]# chown postfix.postfix /tmp/extman
修改apache配置檔案,虛拟主機定義的内容最終修改如下
ScriptAlias /extmail/cgi /var/www/extsuite/extman/cgi
Alias /extman /var/www/extsuite/extmail/html
修改cgi目錄的屬主數組為postfix
[root@mail extman]# vim /etc/httpd/conf/httpd.conf
[root@mail extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi
修改完成後儲存退出 重新啟動apache服務
[root@mail extman]# service httpd restart
這個時候打開浏覽器輸入172.16.111.3/extman,就可以進入進去管理了。
本文轉自 陳延宗 51CTO部落格,原文連結:http://blog.51cto.com/407711169/1191832,如需轉載請自行聯系原作者