天天看點

Qmail+vpopmail+daemontools+ucspi郵件系統安裝及其SMTP認證配置

    最近線上的一台qmail郵件系統因硬體出現故障,又重新部署了新的Qmail郵件系統,在網上查閱了好多關于qmail安裝資料,下面是我整理的qmail安裝和SMTP認證配置文檔。

準備條件:

系統:centos 5.5 64位

安裝qmail郵件系統依賴的相關軟體包

yum install g++ gcc-g++ gdbm gdbm-devel openssl openssl-devel stunnel krb5-devel bzip2 bzip2-devel

然後删除系統自帶的郵件系統,以免安裝受影響

rpm -e --nodeps sendmail postfix

mkdir -p /var/src/qmail

軟體包:

qmail           http://www.qmail.org/netqmail-1.05.tar.gz

ucspi-tcp       http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tat.gz

daemontools     http://cr.yp.to/daemontools/daemontools-0.76.tar.gz

vpopmail        http://shupp.org/software/vpopmail-5.4.10.tar.gz

安裝netqmail

cd ../

tar -zxvf qmail/netqmail-1.05.tar.gz

cd netqmail-1.05

./collate.sh

安裝daemontools

mkdir -p /package

chmod 1755 /package

cd /package

tar -zxvf /var/src/qmail/daemontools-0.76.tar.gz

cd admin/daemontools-0.76

patch -p1 < /var/src/netqmail-1.05/other-patches/daemontools-0.76.errno.patch

package/install

安裝ucspi-tcp

cd /var/src/

tar -zxvf qmail/ucspi-tcp-0.88.tar.gz

cd ucspi-tcp-0.88

patch -p1 < /var/src/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch

make

make setupcheck

設定qmail檔案目錄使用者及其使用者組

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 /var/src

tar -zxvf qmail/toaster-scripts-0.8.tar.gz

cd netqmail-1.05/netqmail-1.05/

ln -s /usr/include/ /usr/kerberos/include/

rm /usr/sbin/sendmail

make setup check

注意qmail的更新檔将在vpopmail安裝以後打

打開SPF checking

echo 3 > /var/qmail/control/spfbehavior

cd ~alias; echo "[email protected]" > .qmail-postmaster

echo "[email protected]" > .qmail-mailer-daemon

echo "[email protected]" > .qmail-root

chmod 644 ~alias/.qmail*

./config-fast mail.test.com   你可以填寫你實際郵件伺服器的域名

修改qmail的man路徑

Edit  /etc/man.config

Add "MANPATH /var/qmail/man"

相應腳本

cp toaster-scripts-0.8/rc /var/qmail/rc

chmod 755 /var/qmail/rc

mkdir /var/log/qmail

echo ./Maildir/ >/var/qmail/control/defaultdelivery

cp toaster-scripts-0.8/qmailctl /var/qmail/bin/

chmod 755 /var/qmail/bin/qmailctl

ln -s /var/qmail/bin/qmailctl /usr/bin

ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail

ln -s /var/qmail/bin/sendmail /usr/lib/sendmail

#Now create the supervise directories/scripts for the qmail services:

mkdir -p /var/qmail/supervise/qmail-send/log

mkdir -p /var/qmail/supervise/qmail-smtpd/log

mkdir -p /var/qmail/supervise/qmail-pop3d/log

mkdir -p /var/qmail/supervise/qmail-pop3ds/log

cp /var/src/toaster-scripts-0.8/send.run /var/qmail/supervise/qmail-send/run

cp /var/src/toaster-scripts-0.8/send.log.run /var/qmail/supervise/qmail-send/log/run

cp /var/src/toaster-scripts-0.8/smtpd.run /var/qmail/supervise/qmail-smtpd/run

cp /var/src/toaster-scripts-0.8/smtpd.log.run /var/qmail/supervise/qmail-smtpd/log/run

cp /var/src/toaster-scripts-0.8/pop3d.run /var/qmail/supervise/qmail-pop3d/run

cp /var/src/toaster-scripts-0.8/pop3d.log.run /var/qmail/supervise/qmail-pop3d/log/run

cp /var/src/toaster-scripts-0.8/pop3ds.run /var/qmail/supervise/qmail-pop3ds/run

cp /var/src/toaster-scripts-0.8/pop3ds.log.run /var/qmail/supervise/qmail-pop3ds/log/run

echo 20 > /var/qmail/control/concurrencyincoming

chmod 644 /var/qmail/control/concurrencyincoming

chmod 755 /var/qmail/supervise/qmail-send/run

chmod 755 /var/qmail/supervise/qmail-send/log/run

chmod 755 /var/qmail/supervise/qmail-smtpd/run

chmod 755 /var/qmail/supervise/qmail-smtpd/log/run

chmod 755 /var/qmail/supervise/qmail-pop3d/run

chmod 755 /var/qmail/supervise/qmail-pop3d/log/run

chmod 755 /var/qmail/supervise/qmail-pop3ds/run

chmod 755 /var/qmail/supervise/qmail-pop3ds/log/run

mkdir -p /var/log/qmail/smtpd

mkdir -p /var/log/qmail/pop3d

mkdir -p /var/log/qmail/pop3ds

chown -R qmaill /var/log/qmail

允許daemontools來啟動qmail

ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service

啟動qmail服務

qmailctl start

安裝vpopmail

groupadd -g 89 vchkpw

useradd -u 89 -g vchkpw vpopmail

tar -zxvf qmail/vpopmail-5.4.10.tar.gz

cd vpopmail-5.4.10

./configure --enable-logging=v

make install-strip

echo '127.:allow,RELAYCLIENT=""' > ~vpopmail/etc/tcp.smtp

cd ~vpopmail/etc

tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp

安裝vpopmail啟動腳本

cp ../toaster-scripts-0.8/vpopmailctl /var/qmail/bin/vpopmailctl

chmod 755 /var/qmail/bin/vpopmailctl

ln -s /var/qmail/bin/vpopmailctl /usr/bin

安裝qmail的更新檔

cd /var/src/netqmail-1.05/netqmail-1.05

bunzip2 -c ../../tar/qmail/qmail-toaster-0.9.2.patch.bz2 | patch -p0

make clean

qmailctl stop

chown -R vpopmail:vchkpw /var/qmail/spam

重新開機啟動qmail

允許daemontools來啟動vpopmail

ln -s /var/qmail/supervise/qmail-pop3d /var/qmail/supervise

/qmail-pop3ds /service

啟動vpopmail

vpopmailctl start

添加域:

/home/vpopmail/bin/vadddomain test.com [系統會讓使用者定義域管理者密碼的]

添加使用者:

/home/vpopmail/bin/vadduser -q 10MB [email protected]

qmail SMTP 認證配置

在/var/src/netqmail-1.05/netqmail-1.05目錄裡面備份qmail-smtpd.c檔案,然後拷貝http://down.51cto.com/data/452396裡面的qmail-smtpd.c檔案到該目錄下面,然後執行下面指令:

./compile qmail-smtpd.c

./load qmail-smtpd rcpthosts.c commands.c timeoutread.c timeoutwrite.c ip.c ipme.c ipalloc.c control.c constmap.c received.c date822fmt.c now.c qmail.c cdb.a fd.a wait.a datetime.a getln.a open.a sig.a case.a env.a stralloc.a alloc.a substdio.a error.a str.a fs.a auto_qmail.o `cat socket.lib`

cp qmail-smtpd /var/qmail/bin/qmail-smtpd.auth

chmod 6755 /home/vpopmail/

chmod 6755 /home/vpopmail/bin/vchkpw

測試:

root@mail netqmail-1.05]# su - qmaild -c "/var/qmail/bin/qmail-popup localhost /home/vpopmail/bin/vchkpw pwd"

+OK <24041.1323042311@localhost>

user [email protected]

+OK

pass jerry

/home/vpopmail/domains/test.com/jerry 如果出現使用者郵件的家目錄說明認證配置成功

kill 掉tcpserver程序,安裝下面的方法重新開機tcpserver服務,其中504,503為qmaild使用者的屬主和屬組。

/usr/local/bin/tcpserver  -H -R -l 0 -t 1  -c 100 -x /home/vpopmail/etc/tcp.smtp.cdb -u504 -g503 \

0 smtp /var/qmail/bin/qmail-smtpd.auth /home/vpopmail/bin/vchkpw /bin/true 2>&1 \

| /var/qmail/bin/splogger smtpd 3 &

必須出現下面程序SMTP認證才會成功,否則在用戶端SMTP認證通不過的

[root@mail ~]# ps -auxw |grep “ tcpserver”

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ

qmaild    8473  0.0  0.0   5916   564 ?        S    Dec06   0:00 /usr/local/bin/tcpserver -H -R -l 0 -t 1 -c 100 -x /home/vpopmail/etc/tcp.smtp.cdb -u504 -g503 0 smtp /var/qmail/bin/qmail-smtpd.auth /home/vpopmail/bin/vchkpw /bin/true

    标注:源碼包和SMTP認證檔案下載下傳位址:http://down.51cto.com/data/452396

本文轉自 sfzhang 51CTO部落格,原文連結:http://blog.51cto.com/sfzhang88/852059,如需轉載請自行聯系原作者

繼續閱讀