Home MiscellaneousQmail Installation

Qmail Installation

by SupportPRO Admin

qmail is an SMTP-based message transfer agent (MTA) that runs under all variants of Unix and is compatible with Sendmail. It is preferred over Sendmail as it is significantly easier to configure and deploy.

Download:

http://www.qmail.ca/netqmail-1.05.tar.gz
http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
http://cr.yp.to/daemontools/daemontools-0.76.tar.gz

# mkdir -p /package
# mv daemontools-0.75.tar.gz /package
# cd /package
# tar xvzf daemontools-0.76.tar.gz
# chmod 1755 /package
# cd /usr/tmp
# tar xvzf netqmail-1.05.tar.gz
# cd netqmail-1.05
# ./collate.sh

You should see 7 lines of text below. If you see anything else, then something might be wrong.

[1] Extracting qmail-1.03…
[2] Patching qmail-1.03 into netqmail-1.05. Look for errors below:
[4] The previous line should say 24 if you used GNU patch.
[5] Renaming qmail-1.03 to netqmail-1.05…
[6] Continue installing qmail using the instructions found at:
[7] http://www.lifewithqmail.org/lwq.html#installation

# cd /usr/tmp

# tar xvzf ucscpi-tcp-0.88.tar.gz

# mkdir /var/qmail

# cd /usr/tmp/netqmail-1.05/netqmail-1.05

# cp INSTALL.ids IDS

# vi IDS

Remove all entries in IDS not pertinent to a Linux install. Then customized the file to add specific group and user ids. You can use whatever ID #s you’d like. This is just an example. It should look like this:

groupadd -g 2108 nofiles
useradd -u 7790 -g nofiles -d /var/qmail/alias -s /bin/false alias
useradd -u 7791 -g nofiles -d /var/qmail -s /bin/false qmaild
useradd -u 7792 -g nofiles -d /var/qmail -s /bin/false qmaill
useradd -u 7793 -g nofiles -d /var/qmail -s /bin/false qmailp
groupadd -g 2107 qmail
useradd -u 7794 -g qmail -d /var/qmail -s /bin/false qmailq
useradd -u 7795 -g qmail -d /var/qmail -s /bin/false qmailr
useradd -u 7796 -g qmail -d /var/qmail -s /bin/false qmails

# chmod 700 IDS

# ./IDS

To build qmail

# make setup check

# ./config

You should see the following:

Your hostname is server.domain.com.
Your host’s fully qualified name in DNS is server.domain.com.
Putting server.domain.com into control/me…
Putting domain.com into control/defaultdomain…
Putting domain.com into control/plusdomain…

Checking local IP addresses:
0.0.0.0: PTR lookup failed. I assume this address has no DNS name.
127.0.0.1: Adding localhost to control/locals…
192.168.0.50: Adding server.domain.com to control/locals…

If there are any other domain names that point to you,
you will have to add them to /var/qmail/control/locals.
You don’t have to worry about aliases, i.e., domains with CNAME records.
Copying /var/qmail/control/locals to /var/qmail/control/rcpthosts…
Now qmail will refuse to accept SMTP messages except to those hosts.
Make sure to change rcpthosts if you add hosts to locals or virtualdomains!

Install ucspi-tcp

# cd /usr/tmp/ucspi-tcp-0.88

# patch < /usr/tmp/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch
patching file error.h

# make

# make setup check

Install daemontools

# cd /package/admin/daemontools-0.76/src

# patch < /usr/tmp/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
patching file error.h

# cd ..

# package/install

Daemontools should automatically start now. To verify:

# ps waux | grep sv

root 1544 0.0 0.2 2032 992 ? S 08:47 0:00/bin/sh
/command/svscanboot
root 6447 0.0 0.0 1404 304 ? S 08:47 0:00 svscan /service

Qmail startup script

Add the following to /var/qmail/rc:

# vi /var/qmail/rc

#!/bin/sh
# Using stdout for logging
# Using control/defaultdelivery from qmail-local to deliver messages by default
exec env – PATH=”/var/qmail/bin:$PATH” \
qmail-start “`cat /var/qmail/control/defaultdelivery`”

# chmod 755 /var/qmail/rc

# mkdir /var/log/qmail

Set the default mailbox type

# echo ./Maildir > /var/qmail/control/defaultdelivery
qmail startup script

Gerhard Mourani has a complete set of configuration files and scripts available at

ftp://ftp.openna.com/ConfigFiles-v3.0/floppy-3.0.tgz.

# tar xvzf floppy-3.0.tgz

# cp floppy-3.0/Qmail/etc/init.d/qmail /etc/init.d/

# chmod 700 /etc/init.d/qmail

# chown root.root /etc/init.d/qmail

# chkconfig –add qmail

Download http://www.lifewithqmail.org/qmailctl-script-dt70

# mv qmailctl-script-dt70 /var/qmail/bin/qmailctl

# chmod 755 /var/qmail/bin/qmailctl

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

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

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

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

Add the following to /var/qmail/supervise/qmail-send/run:

# vi /var/qmail/supervise/qmail-send/run

#!/bin/sh
exec /var/qmail/rc

Add the following to /var/qmail/supervise/qmail-send/log/run

# vi /var/qmail/supervise/qmail-send/log/run

#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail

Add the following to /var/qmail/supervise/qmail-smtpd/run:

# vi /var/qmail/supervise/qmail-smtpd/run

#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z “$QMAILDUID” -o -z “$NOFILESGID” -o -z “$MAXSMTPD” -o -z “$LOCAL” ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo “No /var/qmail/control/rcpthosts!”
echo “Refusing to start SMTP listener because it’ll create an open relay”
exit 1
fi
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -l “$LOCAL” -x /etc/tcp.smtp.cdb -c “$MAXSMTPD” \
-u “$QMAILDUID” -g “$NOFILESGID” 0 smtp /var/qmail/bin/qmail-smtpd 2>&1

# echo 20 > /var/qmail/control/concurrencyincoming

# chmod 644 /var/qmail/control/concurrencyincoming

Add the following to /var/qmail/supervise/qmail-smtpd/log/run:

# 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

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

# echo ‘127.:allow,RELAYCLIENT=””‘ >>/etc/tcp.smtp

# qmailctl cdb

Create system aliases:

# echo abc > /var/qmail/alias/.qmail-root

# echo abc > /var/qmail/alias/.qmail-postmaster

# ln -s /var/qmail/.qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon

# chmod 644 /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-postmaster

Start qmail and verify it is working:

# qmailctl start

# qmailctl stat

You should see:

/service/qmail-send: up (pid 31772) 51 seconds
/service/qmail-send/log: up (pid 12997) 51 seconds
/service/qmail-smtpd: up (pid 10926) 51 seconds
/service/qmail-smtpd/log: up (pid 18333) 1 seconds
messages in queue: 0
messages in queue but not yet preprocessed:

# su abc

$ /var/qmail/bin/maildirmake $HOME/Maildir

$ echo ./Maildir/ > ~/.qmail

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

Now we need to test to see that mail is working. Replace the name ‘ajith’ here with the name you used when creating the system aliases.

Now we’ll do a quick test to see if the system is accepting e-mail

# echo To: postmaster@server.domain.com | /var/qmail/bin/qmail-inject

# cd /home/ajith/Maildir/new

# ls -la

You should see a file in the directory like this:

1075665096.22387.server.domain.com
You can take a look at the file and see that it is the e-mail message:
# cat 1075665096.22387.server.domain.com

Return-Path: <root@server.domain.com>
Delivered-To: abc@server.domain.com
Received: (qmail 27454 invoked by alias);
Delivered-To: postmaster@server.domain.com
Received: (qmail 3400 invoked by uid 0);
Message-ID: <20040201195136.22873.qmail@server.domain.com>
From: root@server.domain.com
To: postmaster@server.domain.com

Now we need to add POP3 access for e-mail.

Download http://cr.yp.to/checkpwd/checkpassword-0.90.tar.gz

# tar xvzf checkpassword-0.90.tar.gz

# cd checkpassword-0.90

There is a bug in a the error.h files with glibc > 2.2. You must use a patch to fix this issue.

Download http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/checkpassword-
0.90.errno.patch

# patch < /usr/tmp/checkpassword-0.90.errno.patch

# make

# make setup check

Create /var/qmail/supervise/qmail-pop3d/run

# vi /var/qmail/supervise/qmail-pop3d/run

Add the following to /var/qmail/supervise/qmail-pop3d/run:

#!/bin/sh
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -h -l 0 0 110 /var/qmail/bin/qmail-popup \
server.domain.com /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir
2 >&1

Add the following to /var/qmail/supervise/qmail-pop3d/log/run:

# vi /var/qmail/supervise/qmail-pop3d/log/run

#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t\
/var/log/qmail/pop3d

# mkdir /var/log/qmail/pop3d

# chown qmaill /var/log/qmail/pop3d

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

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

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

We need to add the pop3d entries to qmailctl

# vi /bin/qmailctl

Add the following to qmailctl’s “start” section:

Add the following to qmailctl’s “stat” section:
svstat /service/qmail-pop3d
svstat /service/qmail-pop3d/log

if svok /service/qmail-pop3d ; then
svc -u /service/qmail-pop3d /service/qmail-pop3d/log
else
echo qmail-pop3d supervise not running
fi

Add the following to qmailctl’s “stop” section:

echo ” qmail-pop3d”
svc -d /service/qmail-pop3d /service/qmail-pop3d/log

Add the following to qmailctl’s “pause” section:

echo “Pausing qmail-pop3d”
svc -p /service/qmail-pop3d

Add the following to qmailctl’s “cont” section:

echo “Continuing qmail-pop3d”
svc -c /service/qmail-pop3d

Add the following to qmailctl’s “restart” section:

echo “* Restarting qmail-pop3d.”
svc -t /service/qmail-pop3d /service/qmail-pop3d/log

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

You may also like

Leave a Comment