Qmail 3.0 will give you the best possible installation for a secure Mail Transfer Agent. This guide will provide the following services POP3D-SSL (Port 995) SMTP-SSL (Port 465) SMTP-TLS (Port 587) SMTP (Incoming only Port 25) Secure Webmail running on Apache 2.4 and Rainloop for Webmail. This guide has been tested with FreeBSD 11.2 as of August 11, 2018.

Please make sure your ports system is up-to-date.

If you are using IPv4 and not IPv6 you can disable the IPv6 checkmark from any port by running the following command:

# echo 'OPTIONS_UNSET=IPV6' >> /etc/make.conf

We need to install Curl then install the rest of the required ports:

# cd /usr/ports/ftp/curl
# make install clean

Shortly after this starts installing, you will get a popup box that has in it:

Options for ca_root_nss 3.11.9_2
[X] ETCSYMLINK Add symlink to /etc/ssl/cert.pem

Make sure that box is checked by hitting the space bar and then hit tab and hit enter.
Perl 5.26

# cd /usr/ports/lang/perl5.26
# make install clean

Bash Shell

# cd /usr/ports/shells/bash
# make install clean


# cd /usr/ports/devel/gmake
# make install clean


# cd /usr/ports/archivers/unzip
# make install clean


# cd /usr/ports/ftp/wget
# make install clean

Bind Tools

# cd /usr/ports/dns/bind-tools
# make install clean


# cd /usr/ports/textproc/groff
# make install clean

When the popup box comes up for groff uncheck the option for X11 devices.
We need to install ucspi-ssl so qmail will accept smtp connections with ssl. We can do that like so:

# cd /usr/ports/sysutils/ucspi-ssl
# make install clean

You will need to install apache for webmail but you should install mysql for the Rainloop Address Book database:

Apache 2.4 or better with SSL and PHP 7.0 (SSL is HIGHLY recommended)
Mysql Server 5.6 or Higher

If you would like to create a queuing server please check out the following link:

How to create a queing server

A few of John Simpson's scripts use a link to perl which doesn't exist on FreeBSD so we need to create a symlink to it as follows:

# cd /usr/bin
# ln -s /usr/local/bin/perl perl

Type in the following commands to eliminate sendmail from being called on your box:

# killall sendmail
# mv /usr/sbin/sendmail /usr/sbin/sendmail.old
# chmod 0 /usr/sbin/sendmail.old

To tell FreeBSD not to tell sendmail to start on boot, add this to /etc/rc.conf like so:
NOTE: If you are running FreeBSD 12 CURRENT please use the following line:

# echo "sendmail_enable=NONE" >> /etc/rc.conf
# echo "sendmail_submit_enable=NO" >> /etc/rc.conf
# echo "sendmail_outbound_enable=NO" >> /etc/rc.conf
# echo "sendmail_msp_queue_enable=NO" >> /etc/rc.conf

Now to tell sendmail not to interfere with your qmail setup, add this to your /etc/make.conf like so:

# echo "NO_SENDMAIL=yes" >> /etc/make.conf
# echo "NO_MAILWRAPPER=yes" >> /etc/make.conf

Now lets tell anything that calls sendmail from the common location that we want it to send to qmail instead:

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

If you are using periodic.conf for your system messages you should also disable clean-purgestat from it. Open up /etc/periodic.conf and edit the following line as follows:

# 150.clean-hoststat
daily_clean_hoststat_enable="NO" # Purge sendmail host