Qmail How To
Qmail How To
Qmail How To
Aaron Hill
Copyright 2001, 2002, 2003, 2007 Aaron Hill $Date: 2007/11/25 03:59:12 $
Abstract
This document describes how to set up the qmail mail transfer agent on a FreeBSD system. These instructions are known to work with FreeBSD versions 4.2 through to 6.2, and it is expected they will work with versions earlier and later than that range. This document is intended to be quite minimalist. It contains only the raw instructions for installing qmail under FreeBSD distilled from the qmail documentation. As such, it is not a substitute for reading the documentation.
1. Pre-Installation
You need a FreeBSD system with the ports system installed. The machine should be connectied to an active Internet connection. You should always update the ports system before installing any new software from it, this will ensure you are getting the latest and most secure version of the software available. More information on how to use CVS to update the ports system is available at The FreeBSD Project. Of course if you want to receive email from the Internet you will need the FreeBSD system listed in an MX record of a correctly registered domain. The steps on how to do this will not be covered in this document. You will need to know the Fully Qualified Domain Name (FQDN) of the FreeBSD machine. This is basically the DNS name of the machine. For example if your server's name is known in DNS as mailserver.mydomain.com when the instructions below ask you to type the text HOSTNAME you should replace the word HOSTNAME with the word mailserver. Or when the instructions ask you to enter the text DOMAIN you should replace that word with the words mydomain.com The following Installation instructions must be performed as the user root.
2. Installation
2.1. Install qmail
# cd /usr/ports/mail/qmail # make all install clean
Click OK .
Then run:
# makewhatis
At this point, if you have a LAN on which client machines will require access to the SMTP port to send email, add the network part of the LAN's IP address space. For example, if hosts on the LAN are in the range 192.168.0.1 192.168.0.254, issue this command:
# echo "192.168.0.:allow,RELAYCLIENT=\"\"" >> /etc/tcp.smtp
2.6.2. dot.shrc
Append the following lines to the end of dot.shrc
MAIL=~/Mailbox MAILDIR=~/Maildir MAILTMP=~/Maildir/tmp/tmpfile export MAIL MAILDIR MAILTMP alias mail='/var/qmail/bin/maildir2mbox;/var/qmail/bin/qail' alias pine='/var/qmail/bin/maildir2mbox;/var/qmail/bin/pinq' alias elm='/var/qmail/bin/maildir2mbox;/var/qmail/bin/elq'
2.6.3. dot.qmail
Create the file dot.qmail and add this line:
2.6.4. Maildir
Execute the following command to make the Maildir directory:
# /var/qmail/bin/maildirmake /usr/share/skel/Maildir
In the following sections, HOSTNAME refers to the name of the localhost, and can be determined by running:
# hostname -s
HOSTNAME.DOMAIN refers to the machine's fully qualified domain name (FQDN), and can be determined with:
# hostname
Installing qmail under FreeBSD Obviously, DOMAIN refers to the domain in which the machine resides, and is the FQDN minus the HOSTNAME part. Create /var/qmail/rc:
#!/bin/sh # # This script starts and stops the qmail mail functions. # # Suck in the configuration variables. if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf source_rc_confs elif [ -r /etc/rc.conf ]; then . /etc/rc.conf fi case "$1" in start) case ${qmail_smtp_enable} in [Yy][Ee][Ss]) # Start the qmail smtp daemon /usr/local/bin/tcpserver -H -R -c 255 -x /etc/tcp.smtp.cdb \ -u 82 -g 81 0 25 /var/qmail/bin/qmail-smtpd & echo -n " qmail-smtp" ;; esac case ${qmail_pop_enable} in [Yy][Ee][Ss]) # Start the qmail pop daemon /usr/local/bin/tcpserver -H -R -c 255 0 110 \ /var/qmail/bin/qmail-popup HOSTNAME.DOMAIN \ /usr/local/bin/checkpassword /var/qmail/bin/qmail-pop3d \ Maildir & echo -n " qmail-pop" ;; esac case ${qmail_enable} in [Yy][Ee][Ss]) # Start qmail exec env - PATH="/var/qmail/bin:$PATH" \ qmail-start ./Maildir splogger qmail & echo -n " qmail" ;; esac ;; stop) # Stop the smtp daemon smtppid=`ps -axw | grep tcpserver | grep smtp | grep -v grep | awk '{ print $1 }'` if [ "$smtppid" != "" ]; then kill $smtppid echo -n " qmail-smtp" fi # Stop the pop daemon poppid=`ps -axw | grep tcpserver | grep popup | grep -v grep | awk '{ print $1 }'` if [ "$poppid" != "" ]; then kill $poppid echo -n " qmail-pop"
2.9.2. rcpthosts
# echo HOSTNAME.DOMAIN > /var/qmail/control/rcpthosts # echo DOMAIN >> /var/qmail/control/rcpthosts
2.9.3. locals
# echo HOSTNAME.DOMAIN > /var/qmail/control/locals # echo DOMAIN >> /var/qmail/control/locals
2.9.4. defaulthost
# echo HOSTNAME > /var/qmail/control/defaulthost
2.9.5. defaultdomain
# echo DOMAIN > /var/qmail/control/defaultdomain
2.9.6. plusdomain
# echo DOMAIN > /var/qmail/control/plusdomain
EMAILADDRESS is the real address to which you want root's mail sent. Alias files can contain multiple addresses, but each address must be on a separate line.
3. Post-installation
3.1. Stop sendmail
# killall sendmail # rm /var/run/sendmail.pid
B. Credits
Paul Hoadley converted this document from HTML to DocBook XML and back again.