______________________________________________________________________________

1:6extman 后台数据库
tar -zxvf extman-1.1.tar.gz -C /usr/local/http/htdocs/
mv /usr/local/http/htdocs/extman-1.1 /usr/local/http/htdocs/extman
mysql -u root -p < /usr/local/http/htdocs/extman/docs/extmail.sql
mysql -u root -p < /usr/local/http/htdocs/extman/docs/init.sql
mysql -u root -p
GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
GRANT all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';

______________________________________________________________________________
1:7安装authlib
(1)安装依懒的包
yum -y install postgresql-devel expect libtool-ltdl-devel
rpm -ivh courier-authlib-*
cd /etc/authlib/
mv authdaemonrc authdaemonrc.bak
vim authdaemonrc   添加如下
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10
authdaemonvar=/var/spool/authdaemon
DEBUG_LOGIN=2
DEFAULTOPTIONS="wbnodsn=1"
LOGGEROPTS=""

mv authmysqlrc authmysqlrc.bak
vim authmysqlrc   添加如下
MYSQL_SERVER    localhost
MYSQL_USERNAME  extmail
MYSQL_PASSWORD  extmail
MYSQL_PORT      0
MYSQL_SOCKET    /var/lib/mysql/mysql.sock
MYSQL_OPT       0
MYSQL_DATABASE  extmail

MYSQL_SELECT_CLAUSE     SELECT username,password,"",uidnumber,gidnumber,\
                        CONCAT('/extmail/',homedir),               \
                        CONCAT('/extmail/',maildir),               \
                        quota,                                          \
                        name                                            \
                        FROM mailbox                                    \
                        WHERE username = '$(local_part)@$(domain)'

启动courier-authlib
service courier-authlib  start
Starting Courier authentication services: authdaemond
chmod 777 /var/spool/authdaemon

______________________________________________________________________________
1:8安装courier-imap
rpm -ivh courier-imap-4.4.1-1.5Server.i386.rpm
rpm -ivh courier-imap-debuginfo-4.4.1-1.5Server.i386.rpm
/etc/init.d/courier-imap start

______________________________________________________________________________

1:9安装cyrus-sasl
rpm -qa | grep cyrus
cyrus-sasl-2.1.22-5.el5
cyrus-sasl-devel-2.1.22-5.el5
cyrus-sasl-plain-2.1.22-5.el5
cyrus-sasl-lib-2.1.22-5.el5

vim /usr/lib/sasl2/smtpd.conf
pwcheck_method:authdaemond
log_level:3
mech_list:PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket

/etc/init.d/saslauthd start
chkconfig saslauthd on
______________________________________________________________________________xc
1:10安装postfix
rpm -ivh postfix-2.5.4-2.rhel4.i386.rpm
rpm -ivh postfix-debuginfo-2.5.4-2.rhel4.i386.rpm

rpm -e sendmail --nodeps
cd /usr/sbin/
mv sendmail sendmail.bak
newaliases
ln -s sendmail.postfix sendmail

配置postfix
cd /etc/postfix/
mv main.cf main.cf.bak
vim main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
unknown_local_recipient_reject_code = 550
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = /usr/share/doc/postfix-2.5.2-documentation/html
manpage_directory = /usr/share/man
sample_directory = /etc/postfix
readme_directory = /usr/share/doc/postfix-2.5.2-documentation/readme
alias_database = hash:/etc/postfix/aliases
alias_maps = hash:/etc/postfix/aliases
myhostname = mail.extmail.org
mydomain = extmail.org
mydestination = $myhostname
smtpd_banner = mail.extmail.org ESMTP Mail System
message_size_limit = 14680064
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_base = /extmail
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf
virtual_transport = maildrop:
maildrop_destination_recipient_limit = 1
#sasl
smtpd_sasl_auth_enable = yes
smtpd_sasl2_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_unaut

h_pipelining,reject_invalid_hostname

cp /usr/local/http/htdocs/extman/docs/mysql_virtual_* /etc/postfix/

/etc/init.d/postfix start
______________________________________________________________________________
1:11安装maildrop
rpm -qa | grep pcre-devel
rpm -ivh maildrop-*
______________________________________________________________________________
添加虚似用户及创建目录
groupadd -g 1000 extmail
useradd -g 1000 -u 1000 -s /sbin/nologin -M extmail
vim /etc/postfix/master.cf
maildrop unix -     n     n     -     -     pipe
 flags=DRhu user=extmail argv=/usr/bin/maildrop -d ${user}@${nexthop} ${recipient} ${user} ${extension}

${nexthop}

mkdir -p /extmail/extmail.org/postmaster
maildirmake /extmail/extmail.org/postmaster/Maildir
chown -R exmail.extmail /extmail

echo "test" | maildrop -V 10 -d postmaster@extmail.org
maildrop: authlib: groupid=1000
maildrop: authlib: userid=1000
maildrop: authlib: logname=postmaster@extmail.org, home=/extmail/extmail.org/postmaster,

mail=/extmail/extmail.org/postmaster/Maildir/
maildrop: Changing to /extmail/extmail.org/postmaster
Message start at 0 bytes, envelope sender=postmaster@extmail.org
maildrop: Attempting .mailfilter
maildrop: Delivery complete.

测试pop3
telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK Hello there.
user postmaster@extmail.org
+OK Password required.
pass extmail
+OK logged in.
list
+OK POP3 clients that break here, they violate STD53.
1 6
.
retr 1
+OK 6 octets follow.
test
.
.
-ERR Invalid command.
quit
+OK Bye-bye.
Connection closed by foreign host.


测试postfix
perl -MMIME::Base64 -e 'print encode_base64("postmaster\@extmail.org");'
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==

perl -MMIME::Base64 -e 'print encode_base64("extmail");'
ZXh0bWFpbA==

service postfix restart
Shutting down postfix:                                     [  OK  ]
Starting postfix: 
                                                           [  OK  ]
telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 extmail.org ESMTP Mail System
ehlo mail.extmail.org
250-mail.extmail.org
250-PIPELINING
250-SIZE 14680064
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth login
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334 UGFzc3dvcmQ6
ZXh0bWFpbA==
235 2.7.0 Authentication successful
quit
221 2.0.0 Bye
Connection closed by foreign host.

______________________________________________________________________________

 1:12Extmail
(1) 安装perl
tar -zxvf Unix-Syslog-1.1.tar.gz -C /usr/src/
tar -zxvf DBI-1.610_90.tar.gz -C /usr/src/
tar -zxvf DBD-mysql-4.013.tar.gz -C /usr/src/
cd /usr/src/Unix-Syslog-1.1/
perl Makefile.PL
make
make install
cd ../DBI-1.610_90/
perl Makefile.PL
make
make install
cd ../DBD-mysql-4.013/
perl Makefile.PL
make
make install

(2)
tar -zxvf extmail-1.2.tar.gz -C /usr/local/http/htdocs/
cd /usr/local/http/htdocs/
mv extmail-1.2/ extmail
cd extmail/
chown -R extmail:extmail cgi/
cp webmail.cf.default webmail.cf

vim webmail.cf
2 SYS_CONFIG =  /usr/local/http/htdocs/extmail/
5 SYS_LANGDIR =  /usr/local/http/htdocs/extmail/lang
8 SYS_TEMPLDIR =  /usr/local/http/htdocs/extmail/html
77 SYS_USER_LANG = zh_CN
127 SYS_MAILDIR_BASE = /extmail
132 SYS_AUTH_SCHEMA = virtual
139 SYS_MYSQL_USER = extmail
140 SYS_MYSQL_PASS = extmail
141 SYS_MYSQL_DB = extmail
142 SYS_MYSQL_HOST = localhost
143 SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
145 SYS_MYSQL_TABLE = mailbox
146 SYS_MYSQL_ATTR_USERNAME = username
147 SYS_MYSQL_ATTR_DOMAIN = domain
148 SYS_MYSQL_ATTR_PASSWD = password
197 SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket


vim /usr/local/http/conf/httpd.conf
User extmail
Group extmail
390 Include conf/extra/httpd-vhosts.conf

vim /usr/local/http/conf/extra/httpd-vhosts.conf
NameVirtualHost 192.168.1.140
<VirtualHost 192.168.1.140>
    ServerAdmin shancg@corpmail.cn
    DocumentRoot "/usr/local/http/htdocs/extmail/html/"
    ServerName mail.extmail.org
    ScriptAlias /extmail/cgi /usr/local/http/htdocs/extmail/cgi/
    Alias /extmail /usr/local/http/htdocs/extmail/html/
    ErrorLog "logs/extmail.error_log"
    CustomLog "logs/extmail.access_log" common
</VirtualHost>

service httpd stop
service httpd start
http://mail.extmail.org

用户:postmaster@extmail.org
密码:extmail