installing qmail

installing qmail

This article was written by Ryan Troy
  Thanks Ryan.

Removing Sendmail
Compiling Qmail from the ports collection
Installing qpopper
Making pine use ./Maildir format

Another reference for qmail is at

1. Removing sendmail

OK, we need to turn off sendmail before installing qmail, we are
going to edit the rc.conf file.  Below is an example.

# vi /etc/rc.conf

Now we are in the rc.conf file, search for sendmail you will see something
similar to this.

sendmail_enable="YES" # Run the sendmail daemon (or NO).
sendmail_flags="-bd -q30m" # Flags to sendmail (if enabled)

We want to change YES to NO

Save the file and exit.

To remove sendmail from the sytem we will do this.  Note the binary may be at a
different location on your machine. [ed: This doesn’t actually
remove the files, it makes them non-executable, non-readble, non-writeable

chmod 0 /usr/lib/sendmail
chmod 0 /usr/sbin/sendmail
chmod 0 /usr/lib/

Move the sendmail binary out of the way.  Again this may vary from system to

mv /usr/lib/sendmail /usr/lib/sendmail.bak
mv /usr/sbin/sendmail /usr/sbin/sendmail.bak  

2.Compiling Qmail from the ports collection

cd /usr/ports/mail/qmail
make install

This will download the code from an ftp site, if you haven’t already copied the
source files into /usr/ports/distfiles.

Here we are going to setup some qmail options, so it will boot at startup time and use
the ./Maildir mail delivery structure

cp /var/qmail/boot/home /var/qmail/rc

Now we are editing the boot file to change to ./Maildir format

vi /var/qmail/rc

Now you will see:

# Using splogger to send the log through syslog.
# Using qmail-local to deliver messages to ~/Mailbox by default.

exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start ./Mailbox splogger qmail&

We want this, notice the highlighted ./Maildir:

# Using splogger to send the log through syslog.
# Using qmail-local to deliver messages to ~/Mailbox by default.
exec env - PATH="/var/qmail/bin:$PATH" \
    qmail-start ./Maildir splogger qmail&

We want to link the sendmail file (from the qmail installation) to
the locations of the old sendmail binary so.

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

Then we edit the inetd.conf file so we can run qmail and pop3

vi /etc/inetd.conf

Uncomment this line the following line.  This will make let qmail run
from inetd. [note this line has been wrapped in this article to make it fit the

smtp stream tcp nowait qmaild /var/qmail/bin/tcp-env 
                              tcp-env /var/qmail/bin/qmail-smtpd 

This line will let pop3 run from inetd

pop3 stream tcp nowait root /usr/local/libexec/popper popper 

Now qmail automatically puts a bootup file in /usr/local/etc/rc.d/
The file name is and it will make sure qmail starts when the
box gets rebooted. 

3. Installing qpopper

Download the the patch here

the qpopper source here

[ed: I questioned Troy about this patch.  He said it provides qpopper
with MAILDIR support.  Someone else told me the patch at
allows PINE and imap2 to read messages from MAILDIRs]

Now install the qmail patch and compile qpopper2.53

tar xvzf qpopper2.53.tar.Z
tar qpopper2.53.patch.tar.gz

Then copy qpopper.patch qpopper2.53

cd qpopper2.53
patch < qpopper.patch

Now we have to edit popper.h search for HOMEDIRMAIL you will see this

/* Define HOMEDIRMAIL as the string for the mail drop location 
 * if you have the the user mailboxes in the user's home 
 * directory.

/* #define HOMEDIRMAIL "./mail" */
#define HOMEDIRMAIL "/Mailbox"

We want to change the ./Mailbox to ./Maildir

/* #define HOMEDIRMAIL "./mail" */
#define HOMEDIRMAIL "/Maildir"

Now lets compile qpopper and install it

cp popper /usr/local/libexec/

If you’re going to be using pine, you will need to find the global pine.conf file mine
is located in /usr/local/etc/

4. Making pine use ./Maildir format

To make pine see ./Maildir you need to edit pine.conf and
change inbox-path=Maildir, see the example below.

vi /usr/local/etc/pine.conf

# Path of (local or remote) INBOX, e.g. ={}inbox
# Normal Unix default is the local INBOX (usually 
# /usr/spool/mail/$USER).


killall -HUP inetd

Mailbox migration (added on 31 December 2000)

Troy Bowman wrote in with this suggestion:

Just want to add to the qmail migration page, that it is also nifty to change the
location of everyone’s mailbox.  You can do this by editing /etc/login.conf,
and changing the line:


to: (/home/$/Mailbox or /home/$/Maildir — whatever you use)


That way, programs like mail should notice where the mailbox is through the MAIL
environment variable.

1 thought on “installing qmail”

  1. The article and patches for qpopper do not provide support for qmail-style ~/Maildir/ mailboxes. Instead, it only tells qpopper to look in a *file* named ~/Maildir for messages — a flat file. Maildir format is a directory with subdirs tmp/, new/, and cur/ where single-message-per-file mail lives.

    The MTA delivery for true Maildir support would specify "./Maildir/" instead of "./Maildir".

    I’ve examined the sources, tried the patch anyway, and verified this does not do true Maildir. Bummer. I really need this for an existing system I can’t gut and replace wholesale; I would really like to use qpopper since that’s what my client has.

    I see reference for Maildir patches for qpopper but haven’t found any real ones yet.

    Only option I can see is to use DJB’s qmail-pop3d suite, with a shim for the APOP support we need, then hack our custom scripts to parse the new daemon’s log files to do what we need.

    If I’m wrong or folks know an alternative, I’d love to hear about them. Thanks.

Leave a Comment

Scroll to Top