实验配置概况图:

p_w_picpath

具体配置:

[root@gjp99 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:2A:5C:13 
          inet addr:192.168.10.99  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe2a:5c13/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:70 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7153 (6.9 KiB)  TX bytes:14730 (14.3 KiB)
          Interrupt:67 Base address:0x2000

[root@gjp99 ~]# vim /etc/resolv.conf
[root@gjp99 ~]# cat /etc/resolv.conf
#search domain.org
nameserver 192.168.10.99
[root@gjp99 ~]# vim /etc/sysconfig/network
[root@gjp99 ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=mail.bht.com
[root@gjp99 ~]# vim /etc/hosts

[root@gjp99 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1   localhost.localdomain  localhost
::1        localhost6.localdomain6 localhost6

[root@gjp99 ~]# hostname mail.bht.com

重新登录一下:

[root@mail ~]# hostname
mail.bht.com
[root@mail ~]# mkdir /mnt/cdrom
[root@mail ~]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@mail ~]# cd /mnt/cdrom/Server
[root@mail Server]# vim /etc/yum.repos.d/rhel-debuginfo.repo
[root@mail Server]# cat /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-server]
name=Red Hat Enterprise Linux server
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

[root@mail Server]# yum install bind  -y

[root@mail etc]# yum install bind-chroot

[root@mail named]# yum install caching-nameserver –y

cd   /var/named/chroot/etc
 

[root@mail etc]# ll
total 16
-rw-r--r-- 1 root root   405 Aug  2 21:30 localtime
-rw-r----- 1 root named 1230 Jul 30  2009 named.caching-nameserver.conf
-rw-r----- 1 root named  955 Jul 30  2009 named.rfc1912.zones
-rw-r----- 1 root named  113 Aug  3 14:10 rndc.key
[root@mail etc]# cp –p named.caching-nameserver.conf named.conf

15         listen-on port 53 {  any; };

27         allow-query     { any; };
28         allow-query-cache { any; };

37         match-clients      { any; };
38         match-destinations { any; };

[root@mail etc]# vim named.rfc1912.zones

26 zone "bht.com" IN {
27         type master;
28         file "bht.com.zone";
29         allow-update { none; };
30 };

[root@mail etc]# cd ../var/named/
[root@mail named]# pwd
/var/named/chroot/var/named
[root@mail named]# ll
total 36
drwxrwx--- 2 named named 4096 Aug 26  2004 data
-rw-r----- 1 root  named  198 Jul 30  2009 localdomain.zone
-rw-r----- 1 root  named  195 Jul 30  2009 localhost.zone
-rw-r----- 1 root  named  427 Jul 30  2009 named.broadcast
-rw-r----- 1 root  named 1892 Jul 30  2009 named.ca
-rw-r----- 1 root  named  424 Jul 30  2009 named.ip6.local
-rw-r----- 1 root  named  426 Jul 30  2009 named.local
-rw-r----- 1 root  named  427 Jul 30  2009 named.zero
drwxrwx--- 2 named named 4096 Jul 27  2004 slaves
[root@mail named]# cp -p localhost.zone bht.com.zone
[root@mail named]# vim  bht.com.zone

p_w_picpath

[root@mail etc]# service named start
Starting named:                                            [  OK  ]
[root@mail etc]# rndc reload
server reload successful

[root@mail etc]# chkconfig named on    开机自动启动!

postfix源代码支持mysql数据库!

配置:

1.安装所需的rpm包,这包括以下这些:

[root@mail etc]# yum install httpd  php  php-mysql  mysql  mysql-servenssl-devel  dovecot  perl-DBD-MySQL  tcl  tcl-devel  libart_lgpl  libaol-ltdl  libtool-ltdl-devel  expect

2、关闭sendmail,并将它的随系统自动启动功能关闭:
# service sendmail stop
# chkconfig sendmail off

3、安装以下开发所用到的rpm包组:

[root@mail etc]# yum grouplist  检查四个组是否启动
Development Libraries
Development Tools
Legacy Software Development
X Software Development

方法:
# yum groupinstall "packge_group_name"

4、启动mysql数据库,并给mysql的root用户设置密码:
# service mysqld start
# chkconfig mysqld on
# mysqladmin -u root password 'your_password'
也可以
---------------------------------授权本地用户
SET  PASSWORD FOR root@'localhost'=PASSWORD('redhat');
SET  PASSWORD FOR root@'127.0.0.1'=PASSWORD('redhat');
FLUSH PRIVILEGES;
-------------------------------授权远程用户
GRANT  ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'redhat';
FLUSH PRIVILEGES;

[root@mail etc]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SET  PASSWORD FOR root@'localhost'=PASSWORD('redhat');
Query OK, 0 rows affected (0.00 sec)

mysql> SET  PASSWORD FOR root@'127.0.0.1'=PASSWORD('redhat');
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT  ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye

# 5、启动saslauthd服务,并将其加入到自动启动队列:
# service saslauthd start
# chkconfig saslauthd on

[root@mail ~]# ll
total 6976
-rw------- 1 root root     960 Aug  2 21:30 anaconda-ks.cfg
-rw-r--r-- 1 root root 2268626 Aug  3 18:18 courier-authlib-0.63.1.20111230.tar.bz2
drwxr-xr-x 2 root root    4096 Aug  2 21:41 Desktop
-rw-r--r-- 1 root root  541279 Aug  3 18:18 extmail-1.2.tar.gz
-rw-r--r-- 1 root root  586234 Aug  3 18:18 extman-1.1.tar.gz
-rw-r--r-- 1 root root   35556 Aug  2 21:30 install.log
-rw-r--r-- 1 root root    4062 Aug  2 21:30 install.log.syslog
-rw-r--r-- 1 root root 3644570 Aug  3 18:18 postfix-2.8.2.tar.gz
-rw-r--r-- 1 root root   13738 Aug  3 18:18 Unix-Syslog-1.1.tar.gz

[root@mail ~]# tar -zxvf postfix-2.8.2.tar.gz  -C /usr/local/src

[root@mail ~]# cd /usr/local/src
[root@mail src]# ll
total 4
drwxr-xr-x 16 1001 wheel 4096 Mar 15  2011 postfix-2.8.2
[root@mail src]# cd postfix-2.8.2/
[root@mail postfix-2.8.2]# ls
AAAREADME             LICENSE                          RELEASE_NOTES-2.0
auxiliary             makedefs                         RELEASE_NOTES-2.1
bin                   Makefile                         RELEASE_NOTES-2.2
COMPATIBILITY         Makefile.in                      RELEASE_NOTES-2.3
conf                  Makefile.init                    RELEASE_NOTES-2.4
COPYRIGHT             man                              RELEASE_NOTES-2.5
examples              mantools                         RELEASE_NOTES-2.6
HISTORY               pflogsumm-conn-delays-dsn-patch  RELEASE_NOTES-2.7
html                  PORTING                          src
implementation-notes  postfix-install                  TLS_ACKNOWLEDGEMENTS
include               proto                            TLS_CHANGES
INSTALL               README_FILES                     TLS_LICENSE
IPv6-ChangeLog        RELEASE_NOTES                    TLS_TODO
lib                   RELEASE_NOTES-1.0                US_PATENT_6321267
libexec               RELEASE_NOTES-1.1

[root@mail postfix-2.8.2]#  groupadd -g 2525 postfix
[root@mail postfix-2.8.2]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
[root@mail postfix-2.8.2]# groupadd -g 2526 postdrop
[root@mail postfix-2.8.2]# useradd -g postdrop -u 2526 -s /bin/false -M postdrop

[root@mail postfix-2.8.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/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2   -lssl –lcrypto'

[root@mail postfix-2.8.2]# make

[root@mail postfix-2.8.2]# make install

install_root: [/] /
tempdir: [/usr/local/src/ postfix-2.6.5] /tmp
config_directory: [/etc/postfix] /etc/postfix
daemon_directory: [/usr/libexec/postfix]
command_directory: [/usr/sbin]
queue_directory: [/var/spool/postfix]
sendmail_path: [/usr/sbin/sendmail]
newaliases_path: [/usr/bin/newaliases]
mailq_path: [/usr/bin/mailq]
mail_owner: [postfix]
setgid_group: [postdrop]  
       html_directory: [no] /var/www/postfix_html
       manpages: [/usr/local/man]
       readme_directory: [no]

[root@mail postfix-2.8.2]# newaliases

[root@mail postfix-2.8.2]# postfix start
postfix/postfix-script: starting the Postfix mail system
[root@mail postfix-2.8.2]# netstat -tupln |grep master

[root@mail postfix-2.8.2]# netstat -tupln |grep master
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      25609/master

[root@mail postfix-2.8.2]# postconf –m     //模块
btree
cidr
environ
hash
internal
mysql
nis
proxy
regexp
static
tcp
texthash
unix

[root@mail postfix-2.8.2]# postconf -a
cyrus
dovecot

实现用service 服务名 start 启动服务!

源代码没有控制脚步,可借助于rpm包的控制脚步

[root@mail postfix-2.8.2]# mkdir /tmp/abc
[root@mail postfix-2.8.2]# cd /tmp/abc
[root@mail abc]# cp /mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm  ./
[root@mail abc]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
16333 blocks

[root@mail abc]# ll
total 3664
drwxr-xr-x 5 root root    4096 Aug  3 19:15 etc
-r--r--r-- 1 root root 3734257 Sep 16 11:22 postfix-2.3.3-2.1.el5_2.i386.rpm
drwxr-xr-x 7 root root    4096 Aug  3 19:15 usr
drwxr-xr-x 3 root root    4096 Aug  3 19:15 var

root@mail abc]# cd etc
[root@mail etc]# ll
total 12
drwxr-xr-x 2 root root 4096 Aug  3 19:15 pam.d
drwxr-xr-x 2 root root 4096 Aug  3 19:15 postfix
drwxr-xr-x 3 root root 4096 Aug  3 19:15 rc.d
[root@mail etc]# cd rc.d
[root@mail rc.d]# ll
total 4
drwxr-xr-x 2 root root 4096 Aug  3 19:15 init.d
[root@mail rc.d]# cd init.d
[root@mail init.d]# ll
total 4
-rwxr-xr-x 1 root root 2404 Aug  3 19:15 postfix
[root@mail init.d]# cp postfix /etc/init.d
[root@mail init.d]# pwd
/tmp/abc/etc/rc.d/init.d

[root@mail init.d]# netstat -tupln |grep 25 
tcp        0      0 0.0.0.0:25               0.0.0.0:*         LISTEN      4370/master        

[root@mail init.d]# tail   /etc/passwd
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
avahi-autoipd:x:100:103:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
sabayon:x:86:86:Sabayon user:/home/sabayon:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
dovecot:x:97:97:dovecot:/usr/libexec/dovecot:/sbin/nologin
postfix:x:2525:2525::/home/postfix:/sbin/nologin
postdrop:x:2526:2526::/home/postdrop:/bin/false
[root@mail init.d]# useradd user1
[root@mail init.d]# passwd
Changing password for user root.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@mail init.d]# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.bht.com ESMTP Postfix
helo mail.bht.com
250 mail.bht.com
mail from:root@localhost
250 2.1.0 Ok
rcpt to:user1@localhost
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject:xuchang
xuchangxueyuan!
.
250 2.0.0 Ok: queued as A287FC5F0C
quit
221 2.0.0 Bye
Connection closed by foreign host.

[root@mail init.d]# su - user1
[user1@mail ~]$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/user1": 1 message 1 new
&gt;N  1 root@localhost.bht.c  Sun Sep 16 11:52  14/498   "xuchang"

 

[root@mail ~]# vim /etc/postfix/main.cf
75 myhostname = mail.bht.com
82 mydomain = bht.com

98 myorigin = $mydomain      地址伪装使用

113 inet_interfaces = all

161 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

260 mynetworks =  127.0.0.0/8

[root@mail ~]# service postfix restart
Shutting down postfix:                                     [  OK  ]
Starting postfix:                                          [  OK  ]

说明:
myorigin参数用来指明发件人所在的域名;
mydestination参数指定postfix接收邮件时收件人的域名,即您的postfix系统要接收到哪个域名的邮件;
myhostname 参数指定运行postfix邮件系统的主机的主机名,默认情况下,其值被设定为本地机器名;
mydomain参数指定您的域名,默认情况下,postfix将myhostname的第一部分删除而作为mydomain的值;
mynetworks 参数指定你所在的网络的网络地址,postfix系统根据其值来区别用户是远程的还是本地的,如果是本地网络用户则允许其访问;
inet_interfaces 参数指定postfix系统监听的网络接口;

注意:
1、在postfix的配置文件中,参数行和注释行是不能处在同一行中的;
2、任何一个参数的值都不需要加引号,否则,引号将会被当作参数值的一部分来使用;
3、每修改参数及其值后执行 postfix reload 即可令其生效;但若修改了inet_interfaces,则需重新启动postfix;
4、如果一个参数的值有多个,可以将它们放在不同的行中,只需要在其后的每个行前多置一个空格即可;postfix会把第一个字符为空格或tab的文本行视为上一行的延续;

启动postfix
/usr/local/postfix/sbin/postfix  start

三、为postfix开启基于cyrus-sasl的认证功能

使用以下命令验正postfix是否支持cyrus风格的sasl认证,如果您的输出为以下结果,则是支持的:
 

[root@mail ~]# postconf -a
cyrus
dovecot
[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
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!

[root@mail sasl2]# pwd
/usr/lib/sasl2
[root@mail sasl2]# cp -p Sendmail.conf  smtpd.conf
[root@mail sasl2]# vim smtpd.conf
[root@mail sasl2]# cat smtpd.conf
pwcheck_method:saslauthd
mech_list:LOGIN PLAIN
[root@mail sasl2]# service saslauthd restart
Stopping saslauthd:                                        [  OK  ]
Starting saslauthd:                                        [  OK  ]
[root@mail sasl2]# chkconfig saslauthd on

[root@mail sasl2]# telnet mail.bht.com  25
Trying 192.168.10.99...
Connected to mail.bht.com (192.168.10.99).
Escape character is '^]'.
220 Welcome to our bht.com ESMTP,Warning: Version not Available!
ehlo mail.bht.com
250-bht.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

mail from:root@bht.com
250 2.1.0 Ok
rcpt to:user1@bht.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
connect success !
.
250 2.0.0 Ok: queued as 2B151C5F0C
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@mail sasl2]# su - user1
[user1@mail ~]$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/user1": 1 message 1 new
&gt;N  1 root@bht.com          Sun Sep 16 15:30  13/415

四、安装Courier authentication library

[root@mail ~]# tar -jxvf courier-authlib-0.63.1.20111230.tar.bz2 -C /usr/local/src

[root@mail ~]# cd /usr/local/src
[root@mail src]# ll
total 8
drwxrwxr-x 15 1000  1000 4096 Dec 31  2011 courier-authlib-0.63.1.20111230
drwxr-xr-x 16 1001 wheel 4096 Aug  3 18:37 postfix-2.8.2
[root@mail src]# cd courier-authlib-0.63.1.20111230/
[root@mail courier-authlib-0.63.1.20111230]# ls     看到有configure文件

执行以下命令:

./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --with-authmysql --with-mysql-libs=/usr/lib/mysql --with-mysql-includes=/usr/include/mysql --with-redhat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc --with-ltdl-lib=/usr/lib --with-ltdl-include=/usr/include

make

make  install

[root@mail courier-authlib-0.63.1.20111230]# cd /usr/local/courier-authlib/var/spool/
[root@mail spool]# ll
total 4
drwxr-x--- 2 daemon daemon 4096 Sep 16 15:39 authdaemon
[root@mail spool]# chmod 755 authdaemon/

[root@mail spool]# cp /etc/authdaemonrc.dist  /etc/authdaemonrc
[root@mail spool]# cp /etc/authmysqlrc.dist   /etc/authmysqlrc

[root@mail spool]# vim /etc/authdaemonrc

27 authmodulelist=" authmysql"
34 authmodulelistorig="authmysql"

53 daemons=10

[root@mail spool]# vim /etc/authmysqlrc

MYSQL_SERVER localhost
MYSQL_USERNAME  extmail      (这时为后文要用的数据库的所有者的用户名)
MYSQL_PASSWORD extmail        (密码)

MYSQL_PORT 3306        (指定你的mysql监听的端口,这里使用默认的3306)
MYSQL_SOCKET  /var/lib/mysql/mysql.sock
MYSQL_DATABASE  extmail
MYSQL_USER_TABLE  mailbox
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)

行号:(大概)26-28 49 56 68 83 92 113 119  128 133

注意:虚拟账号的主目录在  /var/mailbox

[root@mail courier-authlib-0.63.1.20111230]# pwd
/usr/local/src/courier-authlib-0.63.1.20111230
[root@mail courier-authlib-0.63.1.20111230]# ll |grep init
-rw-r--r-- 1 root root    943 Sep 16 15:37 courier-authlib.sysvinit
-rw-rw-r-- 1 1000 1000    892 May 25  2011 courier-authlib.sysvinit.in

# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
# chmod 755 /etc/init.d/courier-authlib
# chkconfig --add courier-authlib
# chkconfig --level 2345 courier-authlib on

[root@mail ~]# echo "/usr/local/courier-authlib/lib/courier-authlib/"&gt;&gt;/etc/ld.so.conf.d/courier-authlib.conf
[root@mail ~]# ldconfig –v

[root@mail ~]# ldconfig -pv |grep courier

[root@mail ~]# service courier-authlib start(启动服务)
Starting Courier authentication services: authdaemond      courier-authlib的守护进程

新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:
[root@mail ~]# mkdir -pv /var/mailbox
mkdir: created directory `/var/mailbox'
[root@mail ~]# chown -R postfix /var/mailbox
[root@mail ~]#  ll -d  /var/mailbox
drwxr-xr-x 2 postfix root 4096 Sep 16 16:22 /var/mailbox

接下来重新配置SMTP 认证,编辑 /usr/local/lib/sasl2/smtpd.conf ,确保其为以下内容:

[root@mail lib]# vim /usr/lib/sasl2/smtpd.conf
[root@mail lib]# cat /usr/lib/sasl2/smtpd.conf
pwcheck_methoeck_method: authdaemond
log_level: 3
mech_list:PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket:saslauthd

五、让postfix支持虚拟域和虚拟用户

1、编辑/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

2、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库:

# tar zxvf  extman-1.1.tar.gz
# cd extman-1.1/docs
-------------------------------------------------------------------------------------------------------------
# mysql -u root -p <extmail.sql
# mysql -u root -p &lt;init.sql
   mysql -u root -p   进行验证
# cp mysql*  /etc/postfix/

 

[root@mail ~]# tar zxvf extman-1.1.tar.gz

[root@mail ~]# cd extman-1.1 /docs

[root@mail docs]# pwd
/root/extman-1.1/docs
[root@mail docs]# ls
backport                    ldap_virtual_domains_maps.cf   mysql_virtual_limit_maps.cf
extmail.schema              ldap_virtual_limit_maps.cf     mysql_virtual_mailbox_maps.cf
extmail.sql                 ldap_virtual_mailbox_maps.cf   mysql_virtual_sender_maps.cf
init.ldif                   ldap_virtual_sender_maps.cf    README.postfix
init.sql                    mysql_virtual_alias_maps.cf
ldap_virtual_alias_maps.cf  mysql_virtual_domains_maps.cf

[root@mail docs]# mysql -u root -p &lt;extmail.sql  
Enter password:  密码为:redhat
[root@mail docs]# mysql -u root -p &lt;init.sql
Enter password: 密码为:redhat
 

测试:

[root@mail docs]# mysql -u root -p
Enter password:  密码为:redhat
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| extmail            |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql&gt; use extmail;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql&gt; show tables;
+-------------------+
| Tables_in_extmail |
+-------------------+
| alias             |
| domain            |
| domain_manager    |
| mailbox           |
| manager           |
+-------------------+
5 rows in set (0.00 sec)

# cp mysql*  /etc/postfix/

3、授予用户extmail访问extmail数据库的权限
mysql&gt; GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
mysql&gt; GRANT all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';
mysql&gt;FLUSH PRIVILEGES;   让设置的内容生效
cp mysql_virtual_* /etc/postfix/

service  postfix  restart

说明:启用虚拟域以后,需要取消中心域,即注释掉myhostname, mydestination, mydomain, myorigin几个指令;当然,你也

可以把mydestionation的值改为你自己需要的。

[root@mail docs]# service dovecot start
Starting Dovecot Imap:                                     [  OK  ]
[root@mail docs]# netstat -tupln |grep dov
tcp        0      0 :::993                      :::*                        LISTEN      4889/dovecot       
tcp        0      0 :::995                      :::*                        LISTEN      4889/dovecot       
tcp        0      0 :::110                      :::*                        LISTEN      4889/dovecot       
tcp        0      0 :::143                      :::*                        LISTEN      4889/dovecot       
[root@mail docs]# vim /etc/dovecot.conf

禁掉:795-828

869   passdb sql {
870     # Path for SQL configuration file, see doc/dovecot-sql-example.conf
871     args =/etc/dovecot-mysql.conf
872   }

930   userdb sql {
931     # Path for SQL configuration file, see doc/dovecot-sql-example.conf
932     args =/etc/dovecot-mysql.conf
933   }

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

把userdb的其他相关禁用
  vim /etc/postfix/main.cf
#postfix的配置文件也要改

[root@mail docs]# vim /etc/postfix/main.cf

414 home_mailbox = Maildir/  此行打开
# 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'

接下来启动dovecot服务:

# service dovecot start
# chkconfig dovecot on

七、安装Extmail-1.2  (先安装httpd)

1、安装
[root@mail ~]# tar zxvf extmail-1.2.tar.gz

[root@mail ~]# mkdir -pv /var/www/exsuite
mkdir: created directory `/var/www/exsuite'

[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

部分修改选项的说明:

104 SYS_MESSAGE_SIZE_LIMIT = 5242880

用户可以发送的最大邮件

SYS_USER_LANG = en_US
语言选项,可改作:
 

77 SYS_USER_LANG = zh_CN  简体中文

SYS_MAILDIR_BASE = /home/domains
此处即为您在前文所设置的用户邮件的存放目录,可改作:
127 SYS_MAILDIR_BASE = /var/mailbox

SYS_MYSQL_USER = db_user
SYS_MYSQL_PASS = db_pass
以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库,这里修改为:
 

139 SYS_MYSQL_USER = extmail
140 SYS_MYSQL_PASS = extmail
142 SYS_MYSQL_HOST = localhost
指明数据库服务器主机名,这里默认即可

145 SYS_MYSQL_TABLE = mailbox
146 SYS_MYSQL_ATTR_USERNAME = username
147 SYS_MYSQL_ATTR_DOMAIN = domain
148 SYS_MYSQL_ATTR_PASSWD = password

以上用来指定验正用户登录里所用到的表,以及用户名、域名和用户密码分别对应的表中列的名称;这里默认即可

SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket
此句用来指明authdaemo socket文件的位置,这里修改为:
197 SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

[root@mail ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using mail.bht.com for ServerName
                                                           [  OK  ]
[root@mail ~]# chkconfig httpd on

3、apache相关配置

由于extmail要进行本地邮件的投递操作,故必须将运行apache服务器用户的身份修改为您的邮件投递代理的用户;本例中打开

了apache服务器的suexec功能,故使用以下方法来实现虚拟主机运行身份的指定。此例中的MDA为postfix自带,因此将指定为

[root@mail ~]# vim /etc/httpd/conf/httpd.conf

postfix用户:
 

<VirtualHost 192.168.10.99:80>
ServerName mail.bht.com
DocumentRoot /var/www/extsuite/extmail/html/
ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
Alias /extmail /var/www/extsuite/extmail/html
SuexecUserGroup postfix postfix
</VirtualHost>

修改 cgi执行文件属主为apache运行身份用户:
# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/

如果您没有打开apache服务器的suexec功能,也可以使用以下方法解决:
# vi /etc/httpd/httpd.conf
 

231 User postfix
232 Group postfix

992 <VirtualHost 192.168.10.99:80>
993 ServerName mail.bht.com
994 DocumentRoot /var/www/extsuite/extmail/html/
995 ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
996 Alias /extmail /var/www/extsuite/extmail/html
997 </VirtualHost>

4、依赖关系的解决

extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装。
# tar zxvf Unix-Syslog-0.100.tar.gz
 

[root@mail ~]# cd Unix-Syslog-1.1
[root@mail Unix-Syslog-1.1]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Unix::Syslog
[root@mail Unix-Syslog-1.1]# make
# make install

5、启动apache服务
# service httpd start
# chkconfig httpd on

p_w_picpath

八、安装Extman-1.1

1、安装及基本配置

# tar zxvf  extman-1.1.tar.gz
[root@mail ~]# mv extman-1.1 /var/www/extsuite/extman

修改配置文件以符合本例的需要:
 

[root@mail ~]# cp /var/www/extsuite/extman/webman.cf.default /var/www/extsuite/extman/webman.cf
[root@mail ~]# vim /var/www/extsuite/extman/webman.cf

SYS_MAILDIR_BASE = /home/domains
此处即为您在前文所设置的用户邮件的存放目录,可改作:
12 SYS_MAILDIR_BASE = /var/mailbox

修改
SYS_CAPTCHA_ON = 1

21 SYS_CAPTCHA_ON = 0   验证文件

修改cgi目录的属主:
# chown -R postfix.postfix /var/www/extsuite/extman/cgi/

在apache的主配置文件中Extmail的虚拟主机部分,添加如下两行:
ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
Alias /extman /var/www/extsuite/extman/html

创建其运行时所需的临时目录,并修改其相应的权限:
#mkdir  -pv  /tmp/extman
#chown postfix.postfix  /tmp/extman

好了,到此为止,重新启动apache服务器后,您的Webmail和Extman已经可以使用了,可以在浏览器中输入指定的虚拟主机的名

称进行访问,如下:
http://mail.bht.com

测试:

客户机:

p_w_picpath

选择管理即可登入extman进行后台管理了。默认管理帐号为:root@extmail.org  密码为:extmail*123*

p_w_picpath

p_w_picpath

说明:
(1) 如果您安装后无法正常显示校验码,安装perl-GD模块会解决这个问题。如果想简单,您可以到以下地址下载适合您的平台

的rpm包,安装即可:  http://dries.ulyssis.org/rpm/packages/perl-GD/info.html
(2) extman-1.1自带了图形化显示日志的功能;此功能需要rrdtool的支持,您需要安装此些模块才可能正常显示图形日志。

p_w_picpath

p_w_picpath

再次点击域名  勾选允许自由注册~

创建用户!

p_w_picpath p_w_picpath

用刚创建的用户名gjp、密码123 登陆

p_w_picpath 

用账号lzw   密码:123 登录测试:

p_w_picpath

p_w_picpath

2、配置Mailgraph_ext,使用Extman的图形日志:(下面所需的软件包面要自己下载)

接下来安装图形日志的运行所需要的软件包Time::HiRes、File::Tail和rrdtool,其中前两个包您可以去

http://search.cpan.org搜索并下载获得,后一个包您可以到 http://oss.oetiker.ch/rrdtool/pub/?M=D下载获得;

注意安装顺序不能改换。

安装Time::HiRes
#tar zxvf Time-HiRes-1.9707.tar.gz
#cd Time-HiRes-1.9707
#perl Makefile.PL
#make
#make test
#make install

安装File::Tail
#tar zxvf File-Tail-0.99.3.tar.gz
#cd File-Tail-0.99.3
#perl Makefile.PL
#make
#make test
#make install

安装rrdtool-1.2.23
#tar zxvf rrdtool-1.2.23.tar.gz
#cd rrdtool-1.2.23
#./configure --prefix=/usr/local/rrdtool
#make
#make install

创建必要的符号链接(Extman会到这些路径下找相关的库文件)
#ln -sv /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/auto/RRDs/RRDs.so  

/usr/lib/perl5/5.8.8/i386-linux-thread-multi/
#ln -sv /usr/local/rrdtool/lib/perl/5.8.8/RRDp.pm   /usr/lib/perl5/5.8.5
#ln -sv /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/RRDs.pm   /usr/lib/perl5/5.8.8

复制mailgraph_ext到/usr/local,并启动之
# cp -r /var/www/extsuite/extman/addon/mailgraph_ext  /usr/local 
# /usr/local/mailgraph_ext/mailgraph-init start

启动cmdserver(在后台显示系统信息)
# /var/www/extsuite/extman/daemon/cmdserver --daemon

添加到自动启动队列
# echo “/usr/local/mailgraph_ext/mailgraph-init start” &gt;&gt; /etc/rc.d/rc.local
# echo “/var/www/extsuite/extman/daemon/cmdserver -v -d” &gt;&gt; /etc/rc.d/rc.local

使用方法: 等待大约15分钟左右,如果邮件系统有一定的流量,即可登陆到extman里,点“图形日志”即可看到图形化的日志

。具体每天,周,月,年的则点击相应的图片进入即可。

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