本文来自:China Linux Forum 作者:Lanry
机器名:mail.weifu.com 机器ip:192。168。203。181
域名:weifu.com
公司ip:192。168。
一、DNS配置
## named.conf - configuration for bind
# Generated automatically by bindconf, alchemist et al.
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
include "/etc/rndc.key";
options {
directory "/var/named/";
};
#zone "." {
# type hint;
# file "named.ca";
#};
zone "0.0.127.in-addr.arpa" {
type master;
file "0.0.127.in-addr.arpa.zone";
};
zone "203.168.192.in-addr.arpa" {
type master;
file "203.168.192.in-addr.arpa.zone";
};
zone "localhost" {
type master;
file "localhost.zone";
};
zone "weifu.com" {
type master;
file "weifu.com.zone";
};
##0.0.127.in-addr.arpa.zone
$TTL 86400
@ IN SOA localhost. root.localhost (
1 ; serial
28800 ; refresh
7200 ; retry
604800 ; expire
86400 ; ttk
)
@ IN NS localhost.
1 IN PTR localhost.
##203.168.192.in-addr.arpa.zone
$TTL 86400
@ IN SOA mail.weifu.com. root.weifu.com. (
2 ; serial
28800 ; refresh
7200 ; retry
604800 ; expire
86400 ; ttl
)
@ IN NS mail.weifu.com.
181 IN PTR mail.weifu.com.
##weifu.com.zone
$TTL 86400
@ IN SOA mail.weifu.com. root.weifu.com. (
2 ; serial
28800 ; refresh
7200 ; retry
604800 ; expire
86400 ; ttl
)
@ IN NS mail.weifu.com.
@ IN MX 10 mail.weifu.com.
mail.weifu.com. IN A 192.168.203.181
##named.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
##localhost.zone:
$TTL 86400
@ IN SOA @ root.localhost (
1 ; serial
28800 ; refresh
7200 ; retry
604800 ; expire
86400 ; ttl
)
@ IN NS localhost.
@ IN A 127.0.0.1
二、.使用软件:
qmail-1.03.tar.gz
checkpassword-0.90.tar.gz
qmail-smtpd.c
cmd5checkpw-0.22.tar.gz
ucspi-tcp-0.88.tar.gz
vpopmail-4.9.8-1.tar.gz
ezmlm-0.53.tar.gz
qmailadmin-0.42.tar.gz
sqwebmail-1.2.5.tar.gz
autorespond.tar.gz
四.安装步骤
(1)安装 checkpassword-0.90.tar.gz
# tar zxvf checkpassword-0.90.tar.gz
# cd checkpassword-0.90
# make
# make setup check
(2)安装 cmd5checkpw-0.22.tar.gz
# tar zxvf cmd5checkpw-0.22.tar.gz
# mkdir /usr/man
# mkdir /usr/man/man8
# cd cmd5checkpw-0.22
# make
# make install
(3)安装 ucspi-tcp-0.88.tar.gz
# tar zxvf ucspi-tcp-0.88.tar.gz
# cd ucspi-tcp-0.88
# make
# make setup check
(4)安装 qmail-1.03.tar.gz
# tar zxvf qmail-1.03.tar.gz
# cp qmail-smtpd.c qmail-1.03/
【出现提示,覆盖原文件】
【添加用户】
# mkdir /var/qmail
# groupadd nofiles
# useradd -g nofiles -d /var/qmail/alias alias
# useradd -g nofiles -d /var/qmail qmaild
# useradd -g nofiles -d /var/qmail qmaill
# useradd -g nofiles -d /var/qmail qmailp
# groupadd qmail
# useradd -g qmail -d /var/qmail qmailq
# useradd -g qmail -d /var/qmail qmailr
# useradd -g qmail -d /var/qmail qmails
【安装和基本配置】
# cd qmail-1.03
# make setup check
# ./config
# (cd ~alias; touch .qmail-postmaster .qmail-mailer-daemon .qmail-root)
# chmod 644 ~alias/.qmail*
# echo "127.0.0.1:allow,RELAYCLIENT=""" > /etc/tcp.smtp
【转换tcp.smtp为cdb格式,做任何此文件的更改都需要转换,否则不生效】
# /usr/local/bin/tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
【下面这一条setuid】
# chmod 4755 /bin/checkpassword
# cp /var/qmail/boot/home /var/qmail/rc
【修改/var/qmail/rc把./Mailbox 改成./Maildir/ 使用Maildir】
【启动qmail】
# csh -cf "/var/qmail/rc &"
(5)安装 vpopmail-4.9.8-1.tar.gz
# groupadd vchkpw
# useradd -g vchkpw vpopmail
# mkdir ~vpopmail/etc
# echo "127.0.01.:allow,RELAYCLIENT=""" > ~vpopmail/etc/tcp.smtp
# tar zxvf vpopmail-4.9.8-1.tar.gz
# cd vpopmail-4.9.8-1
# ./configure --enable-roaming-users=y --enable-default-domain=weifu.com--enable-passwd=n
# make
# make install-strip
# cd ~vpopmail/bin
【添加域名】
#./vadddomain weifu.com
【添加用户】
# ./vadduser lanry@weifu.com
【setuid】
# chmod 6755 /home/vpopmail/bin/vchkpw
# /usr/local/bin/tcpserver -v -x /etc/tcp.smtp.cdb -u UID -g GID 0 smtp /var/qmail/bin/qmail-smtpd 2>&1 /home/vpopmail/bin/vchkpw /bin/true /bin/md5checkpw /bin/true &
【以下是启动Pop3服务】
# /usr/local/bin/tcpserver -H -R 0 pop3 /var/qmail/bin/qmail-popup /home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir &
【编辑qmail启动文件,文件另附】
【至此,Qmail安装工作基本完成】
(6)安装 ezmlm-0.53.tar.gz
# tar zxvf ezmlm-0.53.tar.gz
# cd ezmlm-0.53
# make
# make man
# make setup
(7)安装 autorespond.tar.gz
# tar zxvf autorespond.tar.gz
# gcc -Wall -o autorespond autorespond.c
# cp autorespond /usr/local/bin/autorespond
(8)安装 qmailadmin-0.42.tar.gz
# tar zxvf qmailadmin-0.42.tar.gz
# cd qmailadmin-0.42
# ./configure --enable-htmldir=/var/www/html/ --enable-cgibindir=/var/www/cgi-bin/
【以上CGI-BIN路径为安装并可以正常使用的Apache目录下的cgi路径】
# make
# make install-strip
【此时,在浏览器中输入http://mail.weifu.com/cgi-bin/qmailadmin,用添加的域weifu.com和密码,可以登陆,并且可以管理】
(9)安装 sqwebmail-1.2.5.tar.gz
# tar zxvf sqwebmail-1.2.5.tar.gz
# cd sqwebmail-1.2.5.tar.gz
# ./configure --enable-cgibindir=/var/www/cgi-bin/ --without-gzip --enable-https=auto --with-defaultlang=en --enable-mimecharset=gb2312 --with-authvchkpw
【以上CGI-BIN路径为安装并可以正常使用的Apache目录下的cgi路径】
# make configure-check
# make
# make check
# make install-strip
# make install-configure
【最后一步很重要,否则不能登陆】
# /usr/local/libexec/authlib/authdaemond start
【此时,在浏览器中输入http://mail.weifu.com/cgi-bin/sqwebmail,用添加的邮箱地址合密码,可以登陆】
【Ok!完成!】
10.Vqsignup的安装。 #用web方式注册用户
#默认的apche目录为:/var/www/html
#默认的cgi-bin目录为: /var/www/cgi-bin
10.1 编译
tar xvzf vqsignup-0.5.tar.gz
cd vqsignup-0.5
./configure
make
make install
10.2 更改/var/www/html/vqsignup.html
<HTML><HEAD><TITLE>Signup</TITLE></HEAD><BODY><PRE>
<CENTER>Signup Form</CENTER><FORM ACTION="/cgi-bin/vqsignup/vqsignup.cgi" METHOD="POST">
Username: <INPUT TYPE="TEXT" NAME="user" MAXLENGTH="10" SIZE="10">@<SELECT NAME="domain">
<OPTION VALUE="weifu.com">weifu.com
</SELECT>
Password: <INPUT TYPE="PASSWORD" NAME="pass" MAXLENGTH="10" SIZE="10">
Enter password again: <INPUT TYPE="PASSWORD" NAME="vpass" MAXLENGTH="10" SIZE="10">
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
</FORM>
</PRE></BODY></HTML>
--------------------------------------------------------------------------------
10.3 更改 /var/www/cgi-bin/vqsignup/vqsignup.conf
# Domains supported
# This keeps users from trying to sign up for domains not listed here
# even if they do, or don't exist on your network.
#
add_domain weifu.com
#
# Result file paths
# If these files aren't provided inside the configuration file,
# the defaults from file.h will be used instead. The following
# settings are the same as listed in file.h
#
result_error html/error.html
result_failed_user html/failed-user.html
result_failed_pass html/failed-pass.html
result_failed_domain html/failed-domain.html
result_fields html/fields.html
result_domain html/domain.html
result_success html/success.html
~
--------------------------------------------------------------------------------
10.4 调整相应的/var/www/cgi-bin/vqsignup/html目录下的文件。
将所有其他域名改成自己的域名
在浏览器中输入http://mail.weifu.com/vqsignup.html 会出现帐号注册。
哈哈,所有工作到此胜利结束!
四、系统自动启动qmail的启动文件建立
【附件,Qmail启动文件】
在/etc/rc.d/init.d目录下建立qmail文件,并将下列内容写入
#! /bin/sh
case "$1" in
start)
echo -n "Starting Qmail:vinko"
/var/qmail/rc &
echo "."
echo -n "Starting Smtp service:vinko"
/var/local/bin/tcpserver --v -x /etc/tcp.smtp.cdb -u UID -g GID 0 smtp /var/qmail/bin/qmail-smtpd 2>&1 /home/vpopmail/bin/vchkpw /bin/true /bin/md5checkpw /bin/true &
echo "."
echo -n "Starting Pop3 service:vinko"
/var/local/bin/tcpserver -H -R 0 pop3 /var/qmail/bin/qmail-popup /home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir &
echo "."
echo –n “starting webmail:”
/usr/local/libexec/authlib/authdaemond start
echo “.”
;;
stop)
echo -n "Stoping Qmail:"
echo "."
;;
*)
exit 1
;;
esac
exit 0
然后进行以下操作和连接:
chmod +x /etc/rc.d/init.d/qmail
ln –s /etc/rc.d/init.d/qmail /etc/rc.d/rc3.d/S98qmail
ln –s /etc/rc.d/init.d/qmail /etc/rc.d/rc5.d/S98qmail
以后机器启动后qmail的所有服务正