基於虛擬用戶的電子郵件系統

在現實生活中,我們根本不可能爲郵件用戶在郵件服務器上添加系統賬號。互聯網上成千上萬的人每天都在進行郵件傳輸和郵箱申請。

正是採用了利用虛擬賬號映射成我們郵件系統的系統賬號。現實生活中的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

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