« qmail HOWTO - Chapter 1 - Installation of the Required Programs | Main | qmail HOWTO - Chapter 3 - Administrationr of the Mail System »

qmail HOWTO - Chapter 2 - Configuration of the Programs

Chapter 2.  Configuration of the Programs
2.1 Qmail
2.2 vpopmail
2.3 courier-imap
2.4 qmail-conf
2.5 daemontools

qmail HOWTO - Chapter 2
Configuration of the Programs

 

Chapter 2.  Configuration of the Programs

2.1 Qmail

2.2 vpopmail

2.3 courier-imap

2.4 qmail-conf

2.5 daemontools

This section deals with the configuration of the preceeding installed applications.

2.1 qmail


The first thing that must be done is to remove the start script that comes with the port installation of qmail.

chmod 000 /usr/local/etc/rc.d/qmail.sh

In the next three lines, three empty files will be created.  If qmail is installed without vpopmail, it is then required that the following files define to whom (or which account) the email for these special users are relayed.

touch /var/qmail/alias/.qmail-postmaster \
     /var/qmail/alias/.qmail-root \
     /var/qmail/alias/.qmail-mailer-daemon


Because vpopmail administers the domains and users on this server, it must be set up so that qmail's POP3d does not feel responsible for handling the domains.

echo "" > /var/qmail/control/locals

In order to conform to the email RFC's, your server should respond with it's own domain name when connecting to other servers.  Also, this is necessary if a given user has not defined the hostname and is sending or receiving email.  The following three lines contain the information for qmail to tack onto any unqualified addresses.

hostname > /var/qmail/control/me

hostname | sed -e 's/^[^\.]*\.//' > /var/qmail/control/defaultdomain

hostname | sed -e 's/^[^\.]*\.//' > /var/qmail/control/plusdomain

2.2 vpopmail

After a successful authentication through one of the mail services, SMTP will be available for relay to that specific IP for a given amount of time.  Thusly, unauthorized relaying will be prohibited or impossible.  In order to make the the time period limited, the following should be placed in your crontab file:

crontab -l >crontab

echo "40 * * * * /usr/local/vpopmail/bin/clearopensmtp >/dev/null 2>&1 " >>crontab

crontab crontab -u root

[For some reason the above commands do not work for me, and I do the *wrong* thing and edit the crontab file by hand with the second line.  Make a backup of your current crontab file - yes, I have even wiped it out accidentaly - before you perform these commands or make any changes.]

2.3 courier-imap

At first, the given configuration files can be used without modification.

sh -c ' \
      for i in imapd imapd-ssl imapd.cnf pop3d pop3d-ssl pop3d.cnf ; do \
     cp /usr/local/etc/courier-imap/$i.dist /usr/local/etc/courier-imap/$i ; \
     done'


The POP3s and IMAP4s each require an SSL-certificate.  You can create one by entering the following commands:

/usr/local/share/courier-imap/mkpop3dcert

/usr/local/share/courier-imap/mkimapdcert

You will want to hack the included start script with:

perl -pi -e 's|(\$LIBAUTHMODULES) \\\n| \1 \$\{exec_prefix\}/bin/open_relay \\\n|g' \
     /usr/local/libexec/courier-imap/*.rc


Now the POP3s, IMAP4 and IMAP4s services are ready to start.  In order to have the services start after a power-up or restart, the following shell scripts should be copied to the /usr/local/etc/rc.d directory:

cd /usr/local/libexec/courier-imap/

install -m 755 imapd.rc /usr/local/etc/rc.d/imapd.sh

install -m 755 imapd-ssl.rc /usr/local/etc/rc.d/imapd-ssl.sh

install -m 755 pop3d-ssl.rc /usr/local/etc/rc.d/pop3d-ssl.sh

2.4 qmail-conf

The group of scripts for POP3, SMTP and mail distribution [[vpopmail)] need to be configured for use with daemontools.

/var/qmail/bin/qmail-pop3d-conf /usr/local/vpopmail/bin/vchkpw \
      qmaill /var/qmail/service/pop3d

cd /var/qmail/service/pop3d/

echo ":allow" >tcp

make


/var/qmail/bin/qmail-smtpd-conf qmaild qmaill /var/qmail/service/smtpd

cd /var/qmail/service/smtpd/

rm -f tcp.cdb

ln -s /usr/local/vpopmail/etc/tcp.smtp.cdb /var/qmail/service/smtpd/tcp.cdb

make /var/qmail/service

echo '#!/bin/sh' >/var/qmail/rc

echo 'exec env - PATH="/var/qmail/bin:$PATH" \' >>/var/qmail/rc

echo 'qmail-start ./Maildir/ /usr/local/bin/multilog t /var/log/qmail qmaill' >>/var/qmail/rc

chmod 755 /var/qmail/rc

/var/qmail/bin/qmail-delivery-conf qmaill /var/qmail/service/qmail

mkdir /var/log/qmail

chmod 750 /var/log/qmail

chown qmaill /var/log/qmail

2.5 daemontools

The program "svscan" [(the daemontools service)] searches through all of the subdirectories of a /service directory for a script called "run."  The /service directory must be created and symbolic links made to the directories where the services are located that you want run.

mkdir /service

ln -s /var/qmail/service/pop3d /service/pop3d

ln -s /var/qmail/service/smtpd /service/smtpd

ln -s /var/qmail/service/qmail /service/qmail

In order for "svscan" to start after a reboot, the following should be placed in /etc/rc.local***:

echo 'cd /service' >> /etc/rc.local

echo 'env - PATH="/var/qmail/bin:/usr/local/bin:/usr/bin:/bin" \
     svscan >/dev/null 2>&1 &' >> /etc/rc.local

echo 'echo $! > /var/run/svscan.pid' >> /etc/rc.local

[***If you already have daemontools installed from the source - i.e. you did not install it from the ports collection, you do not need to follow this last set of directions.  DJB has rewritten the install script so that this part is taken care of as part of the installation.]

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on March 1, 2003 8:36 PM.

The previous post in this blog was qmail HOWTO - Chapter 1 - Installation of the Required Programs.

The next post in this blog is qmail HOWTO - Chapter 3 - Administrationr of the Mail System.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.