Qmail 설치
Test 환경
CentOS 5.4 +
===========================
Qmail 관련 소스 다운로드
mkdir /usr/local/src/qmail
wget http://www.lug.or.kr/files/centos_book/qmail/netqmail-1.05.tar.gz
wget http://www.lug.or.kr/files/centos_book/qmail/ucspi-tcp-0.88.tar.gz
wget http://www.lug.or.kr/files/centos_book/qmail/daemontools-0.76.tar.gz
wget http://www.lug.or.kr/files/centos_book/qmail/qmail-date-localtime.patch => 표준GMT 시간 +9 한국시간 인식 패치
wget http://www.lug.or.kr/files/centos_book/qmail/netqmail-1.05-tls-smtpauth-20070417.patch => smtp 인증관련 패치
tar -xzf netqmail-1.05.tar.gz
===ucspi-tcp 패치, 컴파일, 설치====
=sendmail 관련 스크립트 제거
/etc/init.d/saslauthd stop
chkconfig --del saslauthd
/etc/init.d/dovecot stop
chkconfig --del dovecot
/etc/init.d/sendmail stop
chkconfig --del sendmail
tar -xzf ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch -p1 < /usr/local/src/qmail/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch
patch -p1 < /usr/local/src/qmail/netqmail-1.05/other-patches/ucspi-tcp-0.88.a_record.patch
patch -p1 < /usr/local/src/qmail/netqmail-1.05/other-patches/ucspi-tcp-0.88.nodefaultrbl.patch
make
make setup check
===daemontools 패치, 컴파일, 설치
cd ..
mkdir -p /package
chmod 1755 /package/
tar -xzf daemontools-0.76.tar.gz -C /package/
cd /package/admin/daemontools-0.76/
patch -p1 < /usr/local/src/qmail/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
package/install
qmail 컴파일 설치
cd /usr/local/src/qmail/netqmail-1.05
mkdir /var/qmail
./collate.sh
cd netqmail-1.05
# groupadd nofiles
# useradd -g nofiles -d /var/qmail/alias alias
# useradd -M -g nofiles -d /var/qmail qmaild
# useradd -M -g nofiles -d /var/qmail qmaill
# useradd -M -g nofiles -d /var/qmail qmailp
# groupadd qmail
# useradd -M -g qmail -d /var/qmail qmailq
# useradd -M -g qmail -d /var/qmail qmailr
# useradd -M -g qmail -d /var/qmail qmails
patch -p1 < /usr/local/src/qmail/qmail-date-localtime.patch
patch -p0 < /usr/local/src/qmail/netqmail-1.05-tls-smtpauth-20070417.patch
make
make setup check
make cert
make tmprsadh
./config-fast mail.parksunho.pe.kr
스크립트 작성
vi /var/qmail/rc
==================================================================
#!/bin/sh
# Using splogger to send the log through syslog.
# Using qmail-local to deliver messages to ~/Maildir/ by default.
exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start ./Maildir/ splogger qmail
===================================================================
chmod 755 /var/qmail/rc
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
chmod +t /var/qmail/supervise/qmail-send
chmod +t /var/qmail/supervise/qmail-smtpd
vi /var/qmail/supervise/qmail-send/run
==================
#!/bin/sh
exec /var/qmail/rc
==================
vi /var/qmail/supervise/qmail-send/log/run
=============================================
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
/usr/local/bin/multilog t /var/log/qmail
=============================================
vi /var/qmail/supervise/qmail-smtpd/run
=============================================================
#!/bin/sh
Q_UID=`id -u qmaild`
Q_GID=`id -g qmaild`
exec /usr/local/bin/softlimit -m 20000000 \
/usr/local/bin/tcpserver -vRHl 0 -x /etc/tcp.smtp.cdb \
-u $Q_UID -g $Q_GID 0 25 /var/qmail/bin/qmail-smtpd 2>&1
=============================================================
vi /var/qmail/supervise/qmail-smtpd/log/run
===================================================
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
/usr/local/bin/multilog t /var/log/qmail/smtpd
===================================================
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
mkdir -p /var/log/qmail/smtpd
chown qmaill /var/log/qmail /var/log/qmail/smtpd
vi /etc/tcp.smtp
==================================
127.0.0.1:allow,RELAYCLIENT=""
222.239.223.200:allow,RELAYCLIENT=""
==================================
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
qmail 시작 스크립트
vi /etc/rc.d/init.d/qmail
============================================================================================
#!/bin/sh
# For RedHat chkconfig
# chkconfig: - 80 30
# description: the qmail MTA
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
case "$1" in
start)
echo "Starting qmail"
if [ -e /service/qmail-send ] ; then
if svok /service/qmail-send ; then
svc -u /service/qmail-send
else
echo qmail-send supervise not running
fi
else
ln -s /var/qmail/supervise/qmail-send /service/
fi
if [ -e /service/qmail-smtpd ] ; then
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd
else
echo qmail-smtpd supervise not running
fi
else
ln -s /var/qmail/supervise/qmail-smtpd /service/
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
;;
stop)
echo "Stopping qmail..."
echo " qmail-smtpd"
svc -dx /service/qmail-smtpd /service/qmail-smtpd/log
rm -f /service/qmail-smtpd
echo " qmail-send"
svc -dx /service/qmail-send /service/qmail-send/log
rm -f /service/qmail-send
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
qmail-qstat
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /service/qmail-send
;;
pause)
echo "Pausing qmail-send"
svc -p /service/qmail-send
echo "Pausing qmail-smtpd"
svc -p /service/qmail-smtpd
;;
cont)
echo "Continuing qmail-send"
svc -c /service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /service/qmail-smtpd
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-smtpd."
svc -d /service/qmail-smtpd
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /service/qmail-send
echo "* Restarting qmail-smtpd."
svc -u /service/qmail-smtpd
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo "Reloaded /etc/tcp.smtp."
;;
help)
cat <<HELP
stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac
exit 0
==============================================================================================
chmod 755 /etc/rc.d/init.d/qmail
chkconfig --add qmail
chkconfig --level 35 qmail on
chkconfig --list|grep qmail
mv /usr/lib/sendmail /usr/lib/sendmail.org
mv /usr/sbin/sendmail /usr/sbin/sendmail.org
ln -s /var/qmail/bin/sendmail /usr/lib
ln -s /var/qmail/bin/sendmail /usr/sbin
echo master > /var/qmail/alias/.qmail-root
echo master > /var/qmail/alias/.qmail-postmaster
echo master > /var/qmail/alias/.qmail-mailer-daemon
chmod 644 /var/qmail/alias/.qmail*
/var/qmail/bin/maildirmake /etc/skel/Maildir
메일 테스트
telnet localhost 25