基于虚拟用户的电子邮件系统

在现实生活中,我们根本不可能为邮件用户在邮件服务器上添加系统账号。互联网上成千上万的人每天都在进行邮件传输和邮箱申请。

正是采用了利用虚拟账号映射成我们邮件系统的系统账号。现实生活中的126 、QQ、sina等邮箱正是使用这种技术来实现邮件的传输。

Extmail能够提供例如126邮箱等webmail的所有功能,还能够在其基础上进行二次开发,下面我们就通过实际的操作配置来切实的体验一下吧

用户可以通过Extmail提供的Webmail来注册虚拟用户的帐号和密码,用户的帐号和密码都保存在mysql数据库中,当用户使用虚拟的帐号和密码通过postfix发送邮件时要通过mysql对其帐号和密码进行认证(需要配置postfix基于mysql的认证),只有认证成功虚拟用户才可以发送邮件,当邮件服务器接收到一个本地用户的邮件的时候,这个用户的帐号和密码也必须通过mysql的认证,否则将不能通过dovecot来接受邮件

142435502

邮件服务器IP地址:192.168.145.100

DNS服务器IP地址:192.168.145.100

Apache服务器:192.168.145.100

Mysql数据库:192.168.145.100

主机名:mail.zz.com

邮件账号:使用虚拟用户。

POP3/IMAP服务器软件:Dovecot

Webmail平台软件:Extmail、Extman

APACHE、MYSQL平台:apache mysql

SMTP服务器软件:编译安装的postfix

认证功能实现软件:编译安装的courier-authlib

依赖关系的解决:extmail将会用到perl的Unix::syslogd功能

下面进行环境的搭建:

[root@localhost ~]# vim /etc/resolv.conf

nameserver 192.168.145.100 //dns服务器指向
search localdomain

[root@localhost ~]# vim /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=mail.zz.com //主机名

[root@localhost ~]# vim /etc/hosts

127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

[root@localhost ~]# hostname mail.zz.com

重新登录使修改生效

由于所安装的软件依赖性较多。本次采用一次性安装

[root@localhost ~]# mount /dev/cdrom /mnt/cdrom

[root@mail ~]# yum install bind bind-chroot caching-nameserver

[root@mail ~]# cd /var/named/chroot/etc/

[root@mail etc]# cp -p named.caching-nameserver.conf named.conf

[root@mail etc]# vim 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 添加如下

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

[root@mail etc]# cd ../var/named/

[root@mail named]# cp -p localhost.zone zz.com.zone

[root@mail named]# vim zz.com.zone

image

[root@mail named]# service named start

[root@mail named]# rndc reload

[root@mail named]# chkconfig named on

[root@mail named]# service sendmail stop

[root@mail named]# chkconfig sendmail off

[root@mail ~]# yum install httpd php php-mysql mysql mysql-server mysql-devel openssl-devel dovecot perl-DBD-MySQL tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect

源码编译安装的必需环境

Development Libraries
Development Tools
Legacy Software Development
X Software Development

启动mysql数据库,并给mysql的root用户设置密码:

[root@mail ~]# service mysqld start

[root@mail ~]# chkconfig mysqld on

在MYSQL中输入以下指令

---------------------------------授权本地用户
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 ~]# mysqladmin -u root password 'redhat'

启动saslauthd服务,并将其加入到自动启动队列:

[root@mail ~]# service saslauthd start

[root@mail ~]# chkconfig saslauthd on

准备好需要用到的软件包

[root@mail ~]# ll
总计 6976
-rw------- 1 root root 1287 2012-08-11 anaconda-ks.cfg
-rw-r--r-- 1 root root 2268626 08-11 16:23 courier-authlib-0.63.1.20111230.tar.bz2
drwxr-xr-x 2 root root 4096 08-11 15:20 Desktop
-rw-r--r-- 1 root root 541279 08-11 16:23 extmail-1.2.tar.gz
-rw-r--r-- 1 root root 586234 08-11 16:23 extman-1.1.tar.gz
-rw-r--r-- 1 root root 35369 2012-08-11 install.log
-rw-r--r-- 1 root root 3995 2012-08-11 install.log.syslog
-rw-r--r-- 1 root root 3644570 08-11 16:23 postfix-2.8.2.tar.gz
-rw-r--r-- 1 root root 13738 08-11 16:23 Unix-Syslog-1.1.tar.gz

安装配置postfix

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

[root@mail ~]# cd /usr/local/src/postfix-2.8.2/

[root@mail postfix-2.8.2]# groupadd -g 2000 postfix

[root@mail postfix-2.8.2]# useradd -g postfix -u 2000 -s /sbin/nologin -M postfix

[root@mail postfix-2.8.2]# groupadd -g 2001 postdrop

[root@mail postfix-2.8.2]# useradd -g postdrop -u 2001 -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]

生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低:

[root@mail postfix-2.8.2]# newaliases

[root@mail postfix-2.8.2]# postfix start

[root@mail postfix-2.8.2]# postconf -m

btree
cidr
environ
hash
internal
mysql
nis
proxy
regexp
static
tcp
texthash
unix

把postfix改变成服务

[root@mail postfix-2.8.2]# mkdir /tmp/qq

[root@mail postfix-2.8.2]# cd /tmp/qq

[root@mail qq]# cp /mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./

[root@mail qq]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm | cpio -id

[root@mail qq]# cd etc

[root@mail etc]# cd rc.d/

[root@mail rc.d]# cd init.d/

[root@mail init.d]# cp postfix /etc/init.d/

[root@mail init.d]# service postfix restart

[root@mail init.d]# chkconfig postfix on

进行一些基本配置,测试启动postfix并进行发信

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

75 myhostname = mail.zz.com

83 mydomain = zz.com

99 myorigin = $mydomain

113 inet_interfaces = all

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

260 mynetworks = 127.0.0.0/8

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

[root@mail init.d]# service postfix restart

[root@mail init.d]# useradd user1
[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.zz.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject:ok
wwwwwwwwwwww
.
250 2.0.0 Ok: queued as 88C90ED762
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 [email protected] Sat Aug 11 17:09 14/447 "ok"
& 1
Message 1:
From [email protected] Sat Aug 11 17:09:41 2012
X-Original-To: [email protected]
Delivered-To: [email protected]
subject:ok
Date: Sat, 11 Aug 2012 17:09:05 +0800 (CST)
From: [email protected]

wwwwwwwwwwww

&

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

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

添加以下内容:

652 ############################CYRUS-SASL############################
653 broken_sasl_auth_clients = yes
654 smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_inval id_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sen der,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelinin g,reject_unauth_destination
655 smtpd_sasl_auth_enable = yes
656 smtpd_sasl_local_domain = $myhostname
657 smtpd_sasl_security_options = noanonymous
658 smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!

[root@mail init.d]# vim /usr/lib/sasl2/smtpd.conf

pwcheck_method: saslauthd
mech_list: PLAIN LOGIN

[root@mail init.d]# service saslauthd restart

[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 Welcome to our mail.zz.com ESMTP,Warning: Version not Available!
ehlo 127.0.0.1
250-mail.zz.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

安装Courier authentication library

[root@mail init.d]# cd

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

[root@mail ~]# cd /usr/local/src/courier-authlib-0.63.1.20111230/

[root@mail courier-authlib-0.63.1.20111230]# ./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

[root@mail courier-authlib-0.63.1.20111230]# make

[root@mail courier-authlib-0.63.1.20111230]# make install

[root@mail courier-authlib-0.63.1.20111230]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon

[root@mail courier-authlib-0.63.1.20111230]# cp /etc/authdaemonrc.dist /etc/authdaemonrc

[root@mail courier-authlib-0.63.1.20111230]# cp /etc/authmysqlrc.dist /etc/authmysqlrc

[root@mail courier-authlib-0.63.1.20111230]# vim /etc/authdaemonrc

27 authmodulelist="authmysql"

34 authmodulelistorig="authmysql"

53 daemons=10

编辑/etc/authmysqlrc 为以下内容,其中2000,2000 为postfix 用户的UID和GID。

26 MYSQL_SERVER localhost

27 MYSQL_USERNAME extmail (这时为后文要用的数据库的所有者的用户名)

28 MYSQL_PASSWORD extmail (密码)

49 MYSQL_SOCKET /var/mysql/mysql.sock

56 MYSQL_PORT 3306 (指定你的mysql监听的端口,这里使用默认的3306)

68 MYSQL_DATABASE extmail

83 MYSQL_USER_TABLE mailbox

92 MYSQL_CRYPT_PWFIELD password

113 MYSQL_UID_FIELD 2000

119 MYSQL_GID_FIELD 2000

128 MYSQL_LOGIN_FIELD username

133 MYSQL_HOME_FIELD concat('/var/mailbox/',homedir)

139 MYSQL_NAME_FIELD name

150 MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir)

[root@mail courier-authlib-0.63.1.20111230]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib

[root@mail courier-authlib-0.63.1.20111230]# chmod 755 /etc/init.d/courier-authlib

[root@mail courier-authlib-0.63.1.20111230]# chkconfig --add courier-authlib

[root@mail courier-authlib-0.63.1.20111230]# chkconfig --level 2345 courier-authlib on

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

[root@mail courier-authlib-0.63.1.20111230]# ldconfig -v

新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:

[root@mail courier-authlib-0.63.1.20111230]# cd

[root@mail ~]# mkdir -pv /var/mailbox

[root@mail ~]# chown -R postfix /var/mailbox

接下来重新配置SMTP 认证,编辑 /usr/local/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

[root@mail ~]# service saslauthd restart

[root@mail ~]# service courier-authlib start

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

[root@mail ~]# vim /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:2000

virtual_gid_maps = static:2000

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

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

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

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

[root@mail docs]# mysql -u root -p <extmail.sql

[root@mail docs]# mysql -u root -p &lt;init.sql

[root@mail docs]# mysql -u root -p
Enter password:
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> 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)

mysql&gt; \q

[root@mail docs]# cp mysql* /etc/postfix/

授予用户extmail访问extmail数据库的权限

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

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

mysql&gt; GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
Query OK, 0 rows affected (0.00 sec)

mysql&gt; GRANT all privileges on extmail.* TO [email protected] IDENTIFIED BY 'extmail';
Query OK, 0 rows affected (0.00 sec)

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

mysql&gt; \q
Bye

说明:启用虚拟域以后,需要取消中心域,即注释掉myhostname, mydestination, mydomain, myorigin几个指令;当然,你也可以把mydestionation的值改为你自己需要的。

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

75 #myhostname = mail.zz.com

83 #mydomain = zz.com

99 #myorigin = $mydomain

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

[root@mail docs]# service postfix restart

配置dovecot

[root@mail docs]# vim /etc/dovecot.conf

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

795 #passdb pam {

828 #}

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

896 #userdb passwd {

903 #}

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

postfix的配置文件也要该

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

415 home_mailbox = Maildir/

[root@mail docs]# 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'

[root@mail docs]# service postfix restart

[root@mail docs]# service dovecot start

[root@mail docs]# chkconfig dovecot on

[root@mail docs]# cd
[root@mail ~]# tar zxvf extmail-1.2.tar.gz

[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

[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_MYSQL_HOST = localhost
指明数据库服务器主机名,这里默认即可

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

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

77 SYS_USER_LANG = zh_CN

127 SYS_MAILDIR_BASE = /var/mailbox

139 SYS_MYSQL_USER = extmail
140 SYS_MYSQL_PASS = extmail

197 SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

apache相关配置

[root@mail ~]# service httpd start

[root@mail ~]# chkconfig httpd on

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

没有打开apache服务器的suexec功能可如下设置:

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

231 User postfix
232 Group postfix

992 <VirtualHost 192.168.145.100:80>
993 ServerName mail.zz.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>

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

<VirtualHost *:80>
ServerName mail.test.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运行身份用户:
[root@mail ~]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/

安装Extman-1.1

[root@mail ~]# 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

12 SYS_MAILDIR_BASE = /var/mailbox

21 SYS_CAPTCHA_ON = 0 //为了方便。改为无验证码。

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

修改
SYS_CAPTCHA_ON = 1

SYS_CAPTCHA_ON = 0

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

<VirtualHost 192.168.145.100:80>
ServerName mail.zz.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>

如果打开了apache服务器的suexec功能,我们应该修改上面extmail的选项加入这两句话

还应修改

[root@mail ~]# chown -R postfix.postfix /var/www/extsuite/extman/cgi/

extman运行还需要临时目录

创建其运行时所需的临时目录,并修改其相应的权限:

[root@mail ~]# mkdir -pv /tmp/extman

[root@mail ~]# chown postfix.postfix /tmp/extman

如果希望可以显示校验码,安装perl-GD模块会解决这个问题。如果想简单,您可以到以下地址下载适合您的平台的rpm包,安装即可: http://dries.ulyssis.org/rpm/packages/perl-GD/info.html

extman-1.1自带了图形化显示日志的功能;此功能需要rrdtool的支持,您需要安装此些模块才可能正常显示图形日志。

此处这些就不做了。

依赖关系的解决

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

[root@mail Unix-Syslog-1.1]# make install

启动apache服务

[root@mail ~]# service httpd restart

这样我们的基于虚拟账号的电子邮件系统就搭建好了

在客户端输入:http://192.168.145.100
image

选择管理即可登入extman进行后台管理了。默认管理帐号为:[email protected] 密码为:extmail*123*

我们进去后选择添加管理员就行了,这里添加的是账户名:test 密码:123

我们可以选择添加域,这里添加的是bj.zz.com与sh.zzcom

进入到添加的域。点击允许自由注册。

我们就可以进行注册了

注册账户[email protected][email protected]

密码均设为123 ,注册用户的时候先选择域。

进行邮件发送传输测试

user2登录向user3发送邮件

image

image

查看邮件服务器的日志

[root@mail ~]# tail -f /var/log/maillog

Aug 11 20:35:04 localhost postfix/qmgr[19733]: 48A00EDC5C: from=<[email protected]>, size=589, nrcpt=1 (queue active)
Aug 11 20:35:04 localhost postfix/smtpd[19742]: disconnect from localhost.localdomain[127.0.0.1]
Aug 11 20:35:04 localhost postfix/virtual[19750]: 48A00EDC5C: to=<[email protected]>, relay=virtual, delay=0.09, delays=0.07/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)
Aug 11 20:35:04 localhost postfix/qmgr[19733]: 48A00EDC5C: removed

user3登录查看是否收到邮件

image

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章