qmail相关补丁下载地址
1 添加Qmail所必须的用户和组
[root@RHEL5 soft]# mkdir /var/qmail
[root@RHEL5 soft]# groupadd nofiles
[root@RHEL5 soft]# useradd -g nofiles -d /var/qmail/alias alias
[root@RHEL5 soft]# useradd -g nofiles -d /var/qmail qmaild
[root@RHEL5 soft]# useradd -g nofiles -d /var/qmail qmaill
[root@RHEL5 soft]# useradd -g nofiles -d /var/qmail qmailp
[root@RHEL5 soft]# groupadd qmail
[root@RHEL5 soft]# useradd -g qmail -d /var/qmail qmailq
[root@RHEL5 soft]# useradd -g qmail -d /var/qmail qmailr
[root@RHEL5 soft]# useradd -g qmail -d /var/qmail qmails
2.停止sendmail服务
[root@RHEL5 soft]# service sendmail stop
将现存的 /usr/lib/sendmail 替代为 qmail 版本.
[root@RHEL5 soft]# mv /usr/lib/sendmail /usr/lib/sendmail.old # 忽略错误提示
[root@RHEL5 soft]# mv /usr/sbin/sendmail /usr/sbin/sendmail.old # 忽略错误提示
[root@RHEL5 soft]# chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old # 忽略错误提示
[root@RHEL5 soft]# ln -s /var/qmail/bin/sendmail /usr/lib
[root@RHEL5 soft]# ln -s /var/qmail/bin/sendmail /usr/sbin
注意: 创建 sendmail 的链接是很重要的, 即使不管以前的MTA, sendmail 命令也是一个会被很多程序调用来发送邮件的重要命令
3 为qmail打补丁
[root@RHEL5 soft]# tar -xzvf qmail-1.03.tar.gz
[root@RHEL5 soft]# cd qmail-1.03
[root@RHEL5 qmail-1.03]# patch -p1 < ../qmail-1.03.errno.patch
[root@RHEL5 qmail-1.03]# patch -p1 < ../qmail-1.03-bind-interface.patch
注:qmail-1.03.errno.patch,qmail-1.03-bind-interface.patch放在qmail-1.03的上一级目录上
4 编译安装qmail
[root@RHEL5 qmail-1.03]# make setup check
5 指定一域名,为该域名建立邮件服务器
[root@RHEL5 qmail-1.03]# ./config-fast rhel5.com
6 为ucspi打补丁
[root@RHEL5 soft]# tar -xvzf ucspi-tcp-0.88.tar.gz
[root@RHEL5 soft]# cd ucspi-tcp-0.88
[root@RHEL5 ucspi-tcp-0.88]# patch -p1 < ../ucspi-tcp-0.88.errno.patch
7 编安装ucspi-tcp
[root@RHEL5 ucspi-tcp-0.88]# make
[root@RHEL5 ucspi-tcp-0.88]# make setup check
8 配置
[root@RHEL5 soft]# touch ~alias/.qmail-postmaster ~alias/.qmail-mailer-daemon ~alias/.qmail-root
[root@RHEL5 soft]# chmod 644 ~alias/.qmail*
#设置投递方式
[root@RHEL5 soft]# cp /var/qmail/boot/home /var/qmail/rc
[root@RHEL5 soft]# sed 's/Mailbox/Maildir\//g' /var/qmail/boot/home >/var/qmail/rc
9 启动
qmail 启动脚本,放在/etc/init.d/下
#!/bin/sh
######## define the ok function
echook ()
{
echo -ne "\033[40C ["
echo -ne "\033[32m"
echo -ne "\033[1C OK"
echo -ne "\033[39m"
echo -ne "\033[1C ]\n"
}
####### get qmail sid and uid
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
###### touch tcpserver log file
if [ -z /var/qmail/tcpserver.log ]
then
touch /var/qmail/tcpserver.log
else :
fi
####### mail
case "$1" in
start)
echo -en "Note: You can find the tcpserver log in /var/qmail/tcpserver.log.\n"
date >/var/qmail/tcpserver.log
echo -n "Start qmail service: "
/var/qmail/rc &
echook
echo -n "Start smtp service: "
#echo -n "you can find the tcpserver log in /var/qmail/tcpserver.log."
/usr/local/bin/tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
/usr/local/bin/tcpserver -v -H -l localhost -c 100 -x /etc/tcp.smtp.cdb \
-u $QMAILDUID -g $NOFILESGID 0 smtp /var/qmail/bin/qmail-smtpd >>/var/qmail/tcpserver.log 2>&1 &
echook
#echo -en "Note: You can find the tcpserver log in /var/qmail/tcpserver.log.\n"
#echo -n "start pop3 service:"
#/usr/local/bin/tcpserver -R -H 0 pop3 \
#/var/qmail/bin/qmail-popup rhel5.com \
#/home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir &
;;
stop)
echo -n "Stop qmail service: "
echook
killall -9 qmail-remote >/dev/null 2>&1
killall -9 qmail-send >/dev/null 2>&1
killall -9 tcpserver >/dev/null 2>&1
;;
restart|reload)
cd `pwd`
$0 stop
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac
exit 0
使用 service qmail start
10 测试
[root@RHEL5 soft]# adduser z3
为z3建立文件夹
[root@RHEL5 qmail]# su - z3
[z3@RHEL5 ~]$ /var/qmail/bin/maildirmake Maildir
[z3@RHEL5 ~]$ echo hello |/var/qmail/bin/qmail-inject z3
察看z3家下的Maildir里是否有邮件。
如果测试不成功,查日至 tail /var/log/maillog
11 使支持邮件帐号和系统帐号分离
安装vpopmail
[root@RHEL5 soft]# groupadd vchkpw
[root@RHEL5 soft]# useradd -g vchkpw vpopmail
[root@RHEL5 soft]# tar -xvzf vpopmail-5.4.25.tar.gz
[root@RHEL5 soft]# cd vpopmail-5.4.25
[root@RHEL5 vpopmail-5.4.25]# ./configure
[root@RHEL5 vpopmail-5.4.25]# make
[root@RHEL5 vpopmail-5.4.25]# make install
管理vpopmail
//qmail的其它命令查看/home/vpopmail/bin
[root@RHEL5 vpopmail-5.4.25]# cd /home/vpopmail
增加虚拟域
[root@RHEL5 soft]# /home/vpopmail/bin/vadddomain 域名
删除虚拟域
[root@RHEL5 soft]# /home/vpopmail/bin/vdeldomain 域名
增加用户
[root@RHEL5 soft]# /home/vpopmail/bin/vadduser 用户名[@域名]
删除用户
[root@RHEL5 soft]# /hom/vpopmail/bin/vdeluser 用户名[@域名]
设置缺省域名
[root@RHEL5 soft]# echo 域名>/home/vpopmail/etc/defaultdomain