Blue Flower

Sunday, 19 July 2015 02:03

Installing Qmail - No Qmail Port

Written by
Rate this item
(0 votes)

Originally when I first started modifying the qmailrocks documentation for FreeBSD my goal was to use all the qmail ports to simplify the installation. Since then the qmail port has changed to support netqmail which causes a conflict with qmail. Starting on 2/7/17 I have modified this guide so you are no longer required to install this port. This allows a much cleaner and simplified way to install qmail directly from source.

Lets start with creating groups. users, groups and needed directories:

# pw groupadd nofiles
# pw groupadd vchkpw -g 89
# pw groupadd qscand
# pw useradd vpopmail -u 89 -g vchkpw -m -d /usr/home/vpopmail -s /sbin/nologin
# pw groupadd qnofiles -g 81
# pw groupadd qmail -g 82
# pw useradd qmaild -u 82 -g 81 -m -d /var/qmail -s /nonexistent
# pw useradd alias -u 81 -g 81 -m -d /var/qmail/alias -s /nonexistent
# pw useradd qmaill -u 83 -g 82 -m -d /var/qmail -s /nonexistent
# pw useradd qmailp -u 84 -g 81 -m -d /var/qmail -s /nonexistent
# pw useradd qmailq -u 85 -g 82 -m -d /var/qmail -s /nonexistent
# pw useradd qmailr -u 86 -g 82 -m -d /var/qmail -s /nonexistent
# pw useradd qmails -u 87 -g 82 -m -d /var/qmail -s /nonexistent
# pw useradd qscand -s /sbin/nologin -d /tmp
# mkdir /var/log/qmail
# mkdir /var/log/qmail/qmail-send /var/log/qmail/dovecot /var/log/qmail/qmail-smtpd /var/log/qmail/qmail-smtpd-ssl /var/log/qmail/qmail-smtpd-tls /var/log/qmail/qmail-scanner
# chown -R qmaill:wheel /var/log/qmail
# chmod -R 750 /var/log/qmail
# mkdir -p /var/qmail/supervise
# mkdir /var/qmail/supervise/qmail-smtpd /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd-ssl /var/qmail/supervise/qmail-smtpd-ssl/log/ /var/qmail/supervise/dovecot /var/qmail/supervise/qmail-smtpd/log /var/qmail/supervise/qmail-send/log /var/qmail/supervise/qmail-smtpd-tls /var/qmail/supervise/qmail-smtpd-tls/log/
# chmod +t /var/qmail/supervise/qmail-smtpd /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd-ssl /var/qmail/supervise/qmail-smtpd-tls /var/qmail/supervise/dovecot

Now download the qmail source so we can patch it:

# cd ~root
# fetch
# tar zxvf qmail2-1.03.tar.gz

This guide has been updated to include the two patches and qmail amd64 hotfix. These are not included in the path directory. John Simpson's site is located at . I am including this link because this guide includes his patches but his site has not been updated for quite some time now. Now let's patch qmail with John's patch:

# cd qmail-1.03
# patch < patches/qmail-1.03-jms1.7.08.patch

You will get an output of files that it patched. As long as it says done at the end with no errors you can continue.

Starting with FreeBSD 9.0 the user accounting database has been changed which resulted in an incompatible change to the data structure of the database. The utmp.h header file referenced by qbiff.c no longer exists since it's been replaced by utmpx.h.

Since it would take more time or interest than I have to change qbiff to be compatible with the change, I just removed all references to qbiff in hier.c, install-big.c, and the make file. The loss of qbiff functionality isn't significant for me since it is just for mail notifications for local system users. The following commands fixes this accounting issue:

# tar zxvf patches/qmail_fix2.tgz

If you are running FreeBSD 10.3 or 11.0 on AMD64 run the following. Everyone else skip this step:

# patch < patches/qmail64patch

Now run the following commands:

# make man
# make setup check

Lets get qmail setup for your local hostname. If your local hostname is bsd.localhost, use the following:

# ./config-fast bsd.localhost

You will get a output saying it is going to add that hostname to specific qmail control files. If you would like more information as to what these specific files control, please take a look at

Now we need to run a few more qmail fixes:

# cd ~root
# mkdir qmail
# cd qmail
# fetch
# tar zxvf scripts4.tgz
# rm scripts4.tgz
# cd /var/qmail/bin
# tar zxvf ~root/qmail/qmail_bin.tgz
# cd /var/qmail/queue
# touch /var/qmail/queue/lock/sendmutex
# chown qmails:qmail /var/qmail/queue/lock/sendmutex

At this point I would not recommend deleting any of the qmail files. They really don't take up a lot of room but if you ever delete anything by accident or need to rebuild you queue, you can stop qmail and then run make setup check and then start qmail again. This by any means won't fix everything but leaving the qmail files there won't hurt a bit.

One last thing to recommend is going into /var/qmail/control/locals and making sure that file is empty. If you need a good explanation as to why to do this:

rcpthosts is used for domains that we accept mail for - mostly used for vpopmail virtual domains that reside in /home/vpopmail/domains

If rcpthosts does not exist, you are an open relay. If it exists and is empty and there is no "morercpthosts.cdb" file as well, then your server will reject all incoming mail.

locals - domains that we deliver locally - mostly used for local delivery /home/$USER/Maildir

Read 65 times Last modified on Sunday, 12 February 2017 13:34

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.