<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,如需转载请自行联系原作者