Qmail

From KallestadWiki

Jump to: navigation, search

This page is in place to help track my own progress with installing qmail.

Contents

Step 1 setting up the users

The group id's and user ID values I'm using here are in place to match a previous installation of qmail that I am migrating from. I've seen different values in other how-to's, and I've seen how-to's without values. As far as I understand it, the only id that should matter is that the vpopmail id and vchkpw group have an id of 89. And believe it or not, I've also seen how-to's that show that id should be 98. Oh boy oh boy... welcome to the wonderful world of qmail. Isn't it sooo much better?!? </sarcasm>

mkdir /var/qmail
groupadd -g 89 vchkpw
useradd -u 89 -g 89 -c Vpopmail-Master -d /home/vpopmail -s /bin/false vpopmail
groupadd -g 65535 nofiles
groupadd -g 1000 qmail

useradd -u 1012 -g 65535 -d /var/qmail/alias -s /bin/false alias
useradd -u 1013 -g 65535 -d /var/qmail -s /bin/false qmaild
useradd -u 1014 -g 65535 -d /var/qmail -s /bin/false qmaill
useradd -u 1015 -g 65535 -d /var/qmail -s /bin/false qmailp
useradd -u 1016 -g 1000 -d /var/qmail -s /bin/false qmailq
useradd -u 1017 -g 1000 -d /var/qmail -s /bin/false qmailr
useradd -u 1018 -g 1000 -d /var/qmail -s /bin/false qmails 

Step 2 a few logging directories

These directories are used for logging.

mkdir /var/log/qmail
mkdir /var/log/qmail/qmail-send
mkdir /var/log/qmail/qmail-smtpd
mkdir /var/log/qmail/qmail-pop3d
chown -R qmaill.root /var/log/qmail
chmod -R 750 /var/log/qmail

The logs will now end up in /var/qmail/supervise/servicename/log/main - but to support what I thought was a standard location for these files, I'll put some soft links -

mkdir /var/log/qmail
ln -s /var/log/qmail/supervise/qmail-send/log/main ./qmail-send
ln -s /var/log/qmail/supervise/qmail-smtp/log/main ./qmail-smtp
ln -s /var/log/qmail/supervise/qmail-smtp-secure/log/main ./qmail-smtp-secure
ln -s /var/log/qmail/supervise/qmail-pop3d/log/main ./qmail-pop3d

Step 3 Grab and Compile

Why netqmail? Who the F knows. I think it's because it includes a patch for qmailqueue.

wget http://qmail.agarik.com/netqmail-1.05.tar.gz
tar -zxvf netqmail-1.05.tar.gz
cd netqmail-1.05/
./collate.sh
cd netqmail-1.05

I found another group of qmail patches that looks to be a bit more promising than netqmail, that John Simpson has put together. I'm reminded that the most difficult part of installing qmail is inspecting the available patches and deciding on which ones are both relevant and mature enough for my own installation.

Line by line...

  1. grab qmail
  2. grab John Simpson's combined patch (6c5 is the latest stable version as of 12/17/2006)
  3. unzip qmail
  4. move the qmail files to a directory name that reflects the files are patched
  5. get into that directory
  6. patch the files
  7. install qmail.
wget http://cr.yp.to/software/qmail-1.03.tar.gz
wget http://qmail.jms1.net/patches/qmail-1.03-jms1.6c5.patch
tar -xvzf qmail-1.03.tar.gz
mv qmail-1.03 qmail-1.03-jms1.6c5
cd qmail-1.03-jms1.6c5
patch < ../qmail-1.03-jms1.6c5.patch
make setup check

And a few more things for the initial setup

./config-fast heartbeat.bkweddings.com
make cert

Apparently, config-fast isn't really the thing to do for vpopmail installations. John Simpson spells out the problems with this configuration line here.

One thing to note here is that I already have ucspi-tcp and daemontools already installed. It's a pretty basic install, but you can see DJB's instructions somewhere over at cr.yp.to

Step 4 Moving on... how about maildrop next

nevermind... maildrop comes with courier

Step 5 OK then... vpopmail it is

download it and unpack it, view the configure options and compare them with my defaults

wget http://umn.dl.sourceforge.net/sourceforge/vpopmail/vpopmail-5.4.17.tar.gz
tar -xvzf vpopmail-5.4.17.tar.gz
./configure --help |less

Things that you probably want in your configure settings:

--enable-qmail-newu
--enable-qmail-inject
--enable-qmail-newmrh
--enable-tcprules-prog
--enable-tcpserver-file
--enable-relay-clear-minutes
--enable-learn-passwords
--enable-qmail-ext
--enable-auth-logging

There are probably more you want to consider. I'm personally not a big fan of using mysql authentication, but it's an option. My reasoning is really that I'd rather not have the overhead of mysql connections and querying to handle something as simple as mail authentication - but that's not to say that it's such a terrible idea. I imagine the overhead is pretty minimal, and in most environments the queries would be lightning quick. Maybe I'll reconsider at a later date for my own needs.

Again, this is a me-note, but I like to have my configure scripts stored for later use. Some people like to use config.nice to get the last command issued, but I've just gotten into the habit of using my own shell script.

Run the shell script, make, and install

./myconfiguration
make
make install-strip

Step 7 ezmlm-idx

ezmlm-idx is an add-on to ezmlm, so we need to grab both of them and unpack them.

wget http://cr.yp.to/software/ezmlm-0.53.tar.gz
wget http://www.ezmlm.org/archive/5.1.1/ezmlm-idx-5.1.1.tar.gz
tar -xvzf ezmlm-0.53.tar.gz
tar -xvzf ezmlm-idx-5.1.1.tar.gz

Move the idx files into the ezmlm directory and patch ezmlm

mv ezmlm-idx-5.1.1/** ezmlm-0.53
cd ezmlm-0.53
patch < idx.patch

Now compile and install

make; make man
make setup

Step 8 take a break

Good job so far. There's a lot of crap to do.

Step 9 Autoresponder

A nice and simple program has a nice and simple installation:

wget http://www.inter7.com/devel/autorespond-2.0.2.tar.gz
tar -xvzf autorespond-2.0.2.tar.gz
cd auto*
make
make install

Step 10 vqadmin

Download, configure, and install

wget http://www.inter7.com/vqadmin/vqadmin-2.3.2.tar.gz
tar -xvzf vqadmin-2.3.2.tar.gz
cd vqadmin-2.3.2
./configure --enable-cgibindir=/path/to/cgibin
make
make install-strip

Edit apache configuration to enable access

  <Directory "/path/to/cgibin/vqadmin">
    deny from all
    Options ExecCGI
    AllowOverride AuthConfig
    Order deny,allow
  </Directory>

After edit, test configuration, restart apache

/path/to/apachectl configtest
/path/to/apachectl graceful

Edit .htaccess file as necessary

vi /path/to/cgibin/vqadmin/.htaccess
  AuthType Basic
  AuthUserFile /usr/local/apache/conf/vqadmin.passwd
  AuthName vQadmin
  require valid-user
  satisfy any
chown nobody .htaccess
chmod 600 .htaccess

Set up htpasswd file

/usr/local/apache/bin/htpasswd -c /usr/local/apache/conf/vqadmin.passwd admin

Edit the acl file

vi /path/to/cgibin/vqadmin/vqadmin.acl

Step 11 qmailadmin

download and extract it

wget http://superb-west.dl.sourceforge.net/sourceforge/qmailadmin/qmailadmin-1.2.9.tar.gz
tar -xvzf qmailadmin-1.2.9.tar.gz
cd qmail-admin-1.2.9
<pre>
Now configure it with any number of the below options
<pre>
./configure --enable-htmllibdir= \
            --enable-qmaildir= \
            --enable-ezmlmdir= \
            --enable-cgipath= \
            --enable-autoresponder-path= \
            --enable-domain-autofill
            --enable-modify-spam \
            --enable-spam-command= \
            --enable-htmldir= \
            --enable-cgibindir= \
            --enable-imageurl= \
            --enable-imagedir=         

Note that the cgipath should include the qmailadmin cgi (i.e. /cgi-bin/qmailadmin) whereas the cgibindir should be the full system path to the cgi-bin directory (i.e. /var/www/cgi-bin).

Then make and install

make
make install-strip

Now do the help files

wget http://www.inter7.com/devel/qmailadmin-help-1.0.8.tar.gz
tar -xvzf qmailadmin-help-1.0.8.tar.gz
cd qmailadmin-help-1.0.8
mkdir /path/to/qmailadmin-images/help
cp -rp * /path/to/qmailadmin-images/help

If you run into 403 errors, it could be because of the .htaccess file.

Step 12 courier

First we need the authlib (I think)

wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.58.tar.bz2
tar -xvjf courier-authlib-0.58.tar.bz2

/configure --prefix=/usr/local/courier-authlib \
            --without-authpam \
            --without-authldap \
            --without-authpwd \
            --without-authmysql \
            --without-authpgsql \
            --without-authshadow \
            --without-authuserdb \
            --without-authcustom \
            --without-authcram \
            --without-authdaemon \
            --with-authvchkpw \
            --with-mailuser=vpopmail \
            --with-mailgroup=vchkpw
make
make install
make install-configure

Download and uncompress courier

wget http://prdownloads.sourceforge.net/courier/courier-imap-4.1.1.tar.bz2
tar -xvjf courier-imap-4.1.1.tar.bz2
cd courier-imap-4.1.1

Now for configuring courier, I think it's easier to do it with a shell script, so copy this to a file and then run it

#!/bin/sh
export CFLAGS="-DHAVE_OPEN_SMTP_RELAY -DHAVE_VLOGAUTH" 
export COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig
export CPPFLAGS=-I/usr/local/courier-authlib/include 

exec ./configure --prefix=/usr/local/courier-imap \
                 --with-ssl \
                 --disable-root-check 

After this runs for untold amounts of time, compile it and then install it:

make
make install
make install-configure

You thought you were done with courier? Think again.

Starting off with the initialization:

cp courier-imap.sysvinit /etc/init.d/courier-imap
chmod +x /etc/init.d/courier-imap
mkdir -p /var/lock/subsys/

Copy the distribution startup file, and edit it

cp /usr/local/courier-imap/etc/imapd.dist /usr/local/courier-imap/etc/imapd
vi /usr/local/courier-imap/etc/imapd

Change the TCPDOPTS line by adding

-user=vpopmail -group=vchkpw

and also change the IMAPDSTART line as follows

IMAPDSTART=YES

Now for imap ssl, copy the imapd-ssl.dist file

cp /usr/local/courier-imap/etc/imapd-ssl.dist /usr/local/courier-imap/etc/imapd-ssl

and edit the IMAPDSSLSTART line as follows

IMAPDSSLSTART=YES

Now update the /usr/local/courier-imap/etc/imapd.cnf file for the ssl cert

[ req_dn ]
C=US
ST=CA
L=California
O=Courier Mail Server
OU=Automatically-generated IMAP SSL key
CN=your.domain.name.com
emailAddress=ssl-autogen@yourdomain.com

Start up courier (cross your fingers)

/usr/local/courier-authlib/sbin/authdaemond start
/etc/init.d/courier-imap start

Once the server is launched :

chown vpopmail:vchkpw /usr/local/courier-imap/share/imapd.pem

Step 13 imapproxy

I have concerns about imapproxy and squirrelmail right now. You can read a little bit about my concerns on the security page. For now, I'm going to stick with sqwebmail, and perhaps look a little bit into imapproxy and squirrelmail at a later date. I don't want to implement a release candidate, and slimming down the number of applications that I need to keep track of is a good thing.

Step 15 qmailmrtg

Download, compile, and install

wget http://www.inter7.com/qmailmrtg7/qmailmrtg7-4.2.tar.gz
tar -xvzf qmailmrtg7-4.2.tar.gz
cd qmailmrtg7-4.2
make
make install

create a directory to stick the files on the webserver

mkdir /my/hostdirectory/qmail-stats/mrtg

create a configuration file, and put it in /etc/qmail.mrtg.cfg

vi /etc/qmail.mrtg.cfg

Once you've done that, run this a few times to pick up some stats:

/usr/bin/mrtg /etc/qmail.mrtg.cfg

Put a cron entry so that the stats update regularly:

2-57/5 * * * * /usr/bin/mrtg /etc/qmail.mrtg.cfg > /dev/null

Step 16 squirrelmail

Squirrelmail also exhibits some known security flaws, so for the moment, I'm going to refrain from implementing it. Squirrelmail's security page. Perhaps a few weeks or months down the road, I can take a look at the imapproxy and squirrelmail projects and implement them at that time.

Step 17 sqwebmail

wget http://umn.dl.sourceforge.net/sourceforge/courier/sqwebmail-5.1.3.tar.bz2
tar -xvjf sqwebmail-5.1.3.tar.bz2
cd sqwebmail-5.1.3

Configure is best done through a shell script:

#!/bin/sh
export CFLAGS="-DHAVE_OPEN_SMTP_RELAY -DHAVE_VLOGAUTH" 
export COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig
export CPPFLAGS=-I/usr/local/courier-authlib/include 

./configure --enable-cgibindir= \
            --enable-imagedir= \
            --enable-imageurl= \
            --enable-mimetypes=/etc/mime.types:/usr/local/apache/conf/mime.types \
            --with-ispell= \
            
make
make install-strip
make install-configure

And start the sqwebmail daemon

/usr/lib/sqwebmail/libexec/sqwebmaild.rc start

Step 18 ucspi-ssl for secure connections

sslserver is a secure version of tcpserver. It requires ucspi-tcp be installed, as well as open-ssl

cd /package
wget http://www.superscript.com/ucspi-ssl/ucspi-ssl-0.70.tar.gz
tar -xzvf ucspi-ssl-0.70.tar.gz
cd host/superscript.com/net/ucspi-ssl-0.70
package/compile
package/rts
package/install

Step 19 spamassassin

download, extract

wget http://apache.hoxt.com/spamassassin/source/Mail-SpamAssassin-3.1.7.tar.gz
tar -xvzf Mail-SpamAssassin-3.1.7.tar.gz
cd Mail-SpamAssassin-3.1.7

compile it

perl Makefile.PL
make
make install

For SuSE users...

cd /etc/init.d
wget http://kmail.kde.org/unsupported/spamd
chmod +x spamd

Otherwise, look in the spamd directory for an appropriate startup script.

create/edit /etc/default/spamassassin

ENABLED=1
OPTIONS="-v -m 50 --auto-whitelist"

edit /etc/mail/spamassassin/local.cf (for a list of options, check here) For a decent starting point:

add_header spam Flag _YESNOCAPS_
add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_
add_header all Level _STARS(*)_
add_header all Checker-Version SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_
dns_available yes
skip_rbl_checks 1
dns_available yes
bayes_path /var/qmail/spamassassin/
auto_whitelist_path /var/qmail/spamassassin/auto_whitelist
use pyzor 0
use razor2 0

Start up your spamd

/etc/init.d/spamd start

and then test it

spamc < sample-spam.txt
spamc < sample-nonspam.txt

Also of note here: I received several errors in my logs having to do with Received.pm and URIDNSB.pm (not sure if I got the names exactly right) until I installed the Net::DNS module.

Step 20 maintenance scripts

There are quite a few handy dandy scripts out there that help to manage qmail. Various problems crop up over time and it's handy to have some of these scripts available for when they do.

qmHandle

qmHandle helps to manage the qmail queue. When undeliverable messages start to get backed up in the queue, this handy little utility can provide information about them and get rid of them.

wget http://umn.dl.sourceforge.net/sourceforge/qmhandle/qmhandle-1.2.0.tar.gz
tar -xvzf qmhandle-1.2.0.tar.gz
chmod 0700 qmHandle
mv qmHandle /var/qmail/bin

You probably want to make some changes to qmHandle

To enable colored output by default: find

my $color = 0

and change it to

my $color = 1

and find

my ($stopqmail) = '/etc/init.d/qmail stop';
my ($startqmail) = '/etc/init.d/qmail start';

and replace it with:

my ($stopqmail) = '/var/qmail/bin/qmailctl stop';
my ($startqmail) = '/var/qmail/bin/qmailctl start';

Usage is as follows:

Available parameters:
  -a     : try to send queued messages now (qmail must be running)
  -l     : list message queues
  -L     : list local message queue
  -R     : list remote message queue
  -s     : show some statistics
  -mN    : display message number N
  -dN    : delete message number N
  -Stext : delete all messages that have/contain text as Subject
  -D     : delete all messages in the queue (local and remote)
  -V     : print program version

Additional (optional) parameters:
  -c     : display colored output
  -N     : list message numbers only
           (to be used either with -l, -L or -R)

You can view/delete multiple message i.e. -d123 -v456 -d567

For example:

/var/qmail/bin/qmHandle -l

shows you all of the messages in the queue. If you have a large queue, try

/var/qmail/bin/qmHandle -l |less

Step 21 startup files

I want to run several services on this particular mail server.

  1. qmail-smtp on port 25 for any inbound mail to this machine. This particular qmail-smtp daemon will not support authorization, and will not relay mail at all. It will only accept unauthorized logins, and only inbound mail for domains hosted on this machine. This service will utilize greylisting, and inbound mail will be filtered through spamassassin as well.
  2. qmail-smtp-secure on a different port, forcing secure authorization and allowing relayed mail to go through.
  3. qmail-pop3d For downloading mail via pop3
  4. qmail-send which I need to look into why exactly I'm running it.

I haven't figured out quite yet how I want to implement spamassassin. Do I use simscan, qmail-scanner, or I could actually just implement it through dot-qmail files too, and then of course there is this version of qmail-scanner that allows for per-user or per-domain spamassassin configuration. And last, but not least, apparently vpopmail now supports spamassassin through the delivery interface - which I probably would have gone for initially had I known about it yesterday.

At this point, I do know that I want to keep my supervise scripts all in /var/qmail/supervise. Keeping them all in a single directory under the qmail parent makes them easier to find later when I try to figure out the details of my own qmail installation.

mkdir /var/qmail/supervise
mkdir -m 1755 qmail-smtp
mkdir -m 1755 qmail-send
mkdir -m 755 qmail-send/log
mkdir -m 755 qmail-smtp/log
wget http://qmail.jms1.net/scripts/service-any-log-run
cp service-any-log-run qmail-send/log/run
cp service-any-log-run qmail-smtp/log/run
chmod 700 qmail-send/log/run
chmod 700 qmail-smtp/log/run
wget http://qmail.jms1.net/scripts/service-qmail-smtpd-run
cp service-qmail-smtpd-run qmail-smtp/run
wget http://qmail.jms1.net/scripts/service-qmail-send-run
cp service-qmail-send-run qmail-send/run
chmod 700 qmail-send/run
mkdir -m 1755 qmail-pop3d
mkdir -m 755 qmail-pop3d/log
cp service-any-log-run qmail-pop3d/log/run
chmod 700 qmail-pop3d/log/run

now we need to take a look and edit qmail-smtp/run and qmail-send/run (although qmail-send/run might just work as is - it's a pretty simple script.

vi qmail-smtp/run
vi qmail-send/run

Now that qmail-smtp is configured and ready to go...

cp -Rp qmail-smtp qmail-smtp-secure

and then edit qmail-smtp-secure/run

vi qmail-smtp-secure/run

After much consternation as to how to implement spamassassin, I've opted for simscan. Mainly, I've gone in this direction because the Wiki Documentation for simscan is pretty solid and I have confidence that I'll be able to put it to good use. I have nothing against qmail-scanner, but I have gotten confused reading through various web pages talking about it's implementation. I'm also going to opt away from implementing clamAV at this point because I rarely receive viral attachments, I'm pretty good about not opening attachments from unknown sources, and my email users are also pretty good in this regard as well. It's one more package to maintain that eats up resources, and for now at least I'm going to stay away from it.

so, on to installing simscan... (there's a configuration guide available if you want to have a look at implementing clamAV on your own.

wget http://www.inter7.com/simscan/simscan-1.1.tar.gz
tar -xvzf simscan-1.1.tar.gz
cd simscan-1.1
useradd -u 1019 -s /bin/false simscan
./configure --enable-clamav=n \
            --enable-spam=y \
            --enable-spamc-user=y \
            --enable-spam-hits=10 \
            --enable-qmail-queue=/var/qmail/bin/qmail-queue \
            --enable-received=y \
            --enable-spamassassin-path=/usr/bin/spamassassin
make
make install-strip

In order to get simscan to run, we have to export the QMAILQUEUE variable in our startup scripts. John Simpson's scripts already have some logic in there for handling various QMAILQUEUE exports, so I'll just add one to the list.

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

Find

if [ -f $VQ/bin/qmail-scanner-queue ]
then
        export QMAILQUEUE=$VQ/bin/qmail-scanner-queue
elif [ -f $VQ/bin/qmail-scanner-queue.pl ]
then
        export QMAILQUEUE=$VQ/bin/qmail-scanner-queue.pl
elif [ -f $VQ/bin/qmail-spamassassin -a -f /usr/bin/spamassassin ]
then
        export QMAILQUEUE=$VQ/bin/qmail-spamassassin
fi

and replace it with

if [ -f $VQ/bin/qmail-scanner-queue ]
then
        export QMAILQUEUE=$VQ/bin/qmail-scanner-queue
elif [ -f $VQ/bin/qmail-scanner-queue.pl ]
then
        export QMAILQUEUE=$VQ/bin/qmail-scanner-queue.pl
elif [ -f $VQ/bin/qmail-spamassassin -a -f /usr/bin/spamassassin ]
then
        export QMAILQUEUE=$VQ/bin/qmail-spamassassin
elif [ -f $VQ/bin/simscan ]
then
       export QMAILQUEUE=$VQ/bin/simscan
fi

whew! Now, we have to set up the pop3d service and we're almost home.

create /var/qmail/supervise/qmail-pop3d/run as follows

#!/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 \
     yourserver.yourdomain.com /home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1

The Control Script

Place the following qmailctl file in /var/qmail/qmailctl


#!/bin/sh

# For Red Hat chkconfig
# chkconfig: - 30 80
# description: the qmail MTA


PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH

QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`

case "$1" in
  start)
    echo "Starting qmail"
    if svok /service/qmail-send ; then
      svc -u /service/qmail-send /service/qmail-send/log
    else
      echo qmail-send service not running
    fi
    if svok /service/qmail-smtp ; then
      svc -u /service/qmail-smtp /service/qmail-smtp/log
    else
      echo qmail-smtp service not running
    fi
    if svok /service/qmail-smtp-secure ; then
      svc -u /service/qmail-smtp-secure /service/qmail-smtp-secure/log
    else
      echo qmail-smtp-secure service not running
    fi
    if [ -d /var/lock/subsys ]; then
      touch /var/lock/subsys/qmail
    fi
    if svok /service/qmail-pop3d ; then
      svc -u /service/qmail-pop3d /service/qmail-pop3d/log
    else
      echo qmail-pop3d service not running
    fi
    ;;
  stop)
    echo "Stopping qmail..."
    echo "  qmail-smtp"
    svc -d /service/qmail-smtp /service/qmail-smtp/log
    echo "  qmail-smtp-secure"
    svc -d /service/qmail-smtp-secure /service/qmail-smtp-secure/log
    echo "  qmail-send"
    svc -d /service/qmail-send /service/qmail-send/log
    if [ -f /var/lock/subsys/qmail ]; then
      rm /var/lock/subsys/qmail
    fi
    echo "  qmail-pop3d"
    svc -d /service/qmail-pop3d /service/qmail-pop3d/log
    ;;
  stat)
    svstat /service/qmail-send
    svstat /service/qmail-send/log
    svstat /service/qmail-smtp
    svstat /service/qmail-smtp/log
    svstat /service/qmail-smtp-secure
    svstat /service/qmail-smtp-secure/log
    svstat /service/qmail-pop3d
    svstat /service/qmail-pop3d/log
    qmail-qstat
    ;;
  doqueue|alrm|flush)
    echo "Sending ALRM signal to qmail-send."
    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-smtp"
    svc -p /service/qmail-smtp
    echo "Pausing qmail-smtp-secure"
    svc -p /service/qmail-smtp-secure
    echo "Pausing qmail-pop3d"
    svc -p /service/qmail-pop3d
    ;;
  cont)
    echo "Continuing qmail-send"
    svc -c /service/qmail-send
    echo "Continuing qmail-smtp"
    svc -c /service/qmail-smtp
    echo "Continuing qmail-smtp-secure"
    svc -c /service/qmail-smtp-secure
    echo "Continuing qmail-pop3d"
    svc -c /service/qmail-pop3d
    ;;
  restart)
    echo "Restarting qmail:"
    echo "* Stopping qmail-smtp."
    svc -d /service/qmail-smtp
    echo "* Stopping qmail-smtp-secure."
    svc -d /service/qmail-smtp-secure
    echo "* Sending qmail-send SIGTERM and restarting."
    svc -t /service/qmail-send
    echo "* Restarting qmail-smtp."
    svc -u /service/qmail-smtp
    echo "* Restarting qmail-smtp-secure."
    svc -u /service/qmail-smtp-secure
    echo "* Restarting qmail-pop3d."
    svc -t /service/qmail-pop3d
    ;;
  cdb)
    tcprules /etc/qmail/tcp/smtp.cdb /etc/qmail/tcp/smtp.tmp < /etc/qmail/tcp/smtp
    tcprules /etc/qmail/tcp/smtpssl.cdb /etc/qmail/tcp/smtpssl.tmp < /etc/qmail/tcp/smtpssl
    chmod 644 /etc/qmail/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 (smtp connections accepted, but 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 -- sends qmail-send ALRM, scheduling queued messages for 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


soft link it in /usr/sbin

ln -s /var/qmail/bin/qmailctl /usr/sbin/qmailctl
Personal tools