« qmail HOWTO - Chapter 1 - Installation of the Necessary Programs | Main | Formatting, formatting and... some more formatting. »

qmail HOWTO - Chapter 2 - Configuration of the Services

!!!WARNING!!!

This HOWTO (which should be named "misleading install guide that is too old to be taken seriously) no longer matches Oli's at pofo.de. Please direct your attention to lifewithqmail.org for better help and more details. (I'm only leaving this up until I can figure out how to gracefully remove it.)
SF - 2005-11-30

Chapter 2. Configuration of the Services
Contents:
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 services installed in Chapter 1.

2.1 qmail

Firstly, the start scripts from the FreeBSD port must be deactivated.

rm /usr/local/etc/rc.d/qmail.sh

With the next three commands, we will create three empty files. If qmail were not installed with vpopmail, these three files would indicate the account to which emails to the respective (special) accounts would be forwarded.

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

Due to the fact that vpopmail is now responsible for the domains and subsequent users, the qmail POP3 daemon must be configured so that it is no longer responsible for any domains.

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

The next three commands/lines cause the server to respond to others with a valid domain name (in conformation with the proper RFC's). This also allows for emails to be processed where the domain is not directly indicated [(i.e. the email coming from the account "steve" will be tagged with @domain1.tld).]

hostname > /var/qmail/control/me
hostname | sed "s/`hostname -s`.//g" > /var/qmail/control/defaultdomain
hostname | sed "s/`hostname -s`.//g" > /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

Next, the supplied start script will be modified with the following hack.

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:

rm /usr/local/etc/rc.d/courier-imap-imapd.sh.sample
rm /usr/local/etc/rc.d/courier-imap-pop3d.sh.sample
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 service scripts for POP3, SMTP and the distribution agent for the emails will be configured and installed:

/var/qmail/bin/qmail-pop3d-conf /usr/local/vpopmail/bin/vchkpw \
  qmaill /var/qmail/service/pop3d
cd /var/qmail/service/pop3d/
echo ":allow" >tcp
echo "200" > env/CONCURRENCY
make

/var/qmail/bin/qmail-smtpd-conf qmaild qmaill /var/qmail/service/smtpd
cd /var/qmail/service/smtpd/
echo "200" > env/CONCURRENCY
rm -f tcp.cdb tcp
ln -s /usr/local/vpopmail/etc/tcp.smtp.cdb /var/qmail/service/smtpd/tcp.cdb
ln -s /usr/local/vpopmail/etc/tcp.smtp /var/qmail/service/smtpd/tcp
rm Makefile

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 /var/service
ln -s /var/qmail/service/pop3d /var/service/pop3d
ln -s /var/qmail/service/smtpd /var/service/smtpd
ln -s /var/qmail/service/qmail /var/service/qmail

The start script for "svscan" (i.e. daemontools) must be activated in order for svscan to work after a system reboot.

mv /usr/local/etc/rc.d/svscan.sh.sample /usr/local/etc/rc.d/0svscan.sh
chmod 744 /usr/local/etc/rc.d/0svscan.sh

Comments (13)

First,

Excellent job on the documentation.

I followed the documentation all the way thru all 4 chapters, went smoothly.

I did find one thing that was missed. I could not send outgoing mail, other then to the domains on the box.

So, I checked /usr/local/vpopmail/etc/tcp.smtp

I found it was empty.

I added 127.0.0.:allow,RELAYCLIENT=""

Rebuilt the tcp.smtp.cdb, and was able to send out mail.

I agree this doc has made installation go very smooth. I did however need to make one change to the following file. This change made it possible for imap to work.

/usr/local/etc/courier-imap/imapd

I needed to change:
AUTHMODULES="authdaemon"
to
AUTHMODULES="authvchkpw"


Thanks

Shouldnt we also disable some Sendmail-specific daily maintenance
routines in /etc/periodic.conf file?

daily_clean_hoststat_enable="NO"
daily_status_mail_rejects_enable="NO"
daily_status_include_submit_mailq="NO"
daily_submit_queuerun="NO"

Best regards,
Marco Gonçalves

Daniel Sebastian:

A VERY good documentation you've made here.
Step-to-step on everything. Keep up the good work!

Thanks for making life easier. :)

One following these instructions NEEDS to edit their /etc/mail/mailer.conf or the users on the box will not be able to send mail. (when you try the mailwrapper goes crazy and takes up your 95%+ CPU)

My mailer.conf has the following:

sendmail /var/qmail/bin/sendmail
send-mail /var/qmail/bin/sendmail
mailq /var/qmail/bin/qmail-qread
newaliases /usr/bin/newaliases
hoststat /var/qmail/bin/qmail-qstat
purgestat /usr/sbin/purgestat

Have fun .. and thanks Steven for the info and a great forum.
Kalman

mh:

For mysql backed on vpopmail, one can do:

make -DWITH_MYSQL -DWITH_VALIAS -DWITH_DOMAIN_QUOTAS -DHARDQUOTA=10000000 -DRELAYCLEAR=30 -DDEFAULT_DOMAIN=domain.tld -DLOGLEVEL=y -DWITH_MYSQL_SERVER=localhost -DWITH_MYSQL_USER=vpopmail -DWITH_MYSQL_PASSWD=secret -DWITH_MYSQL_DB=vpopmail

Of course the db name and the username can be changed.

Once you have this setup, create the database under mysql and Grant all privileges to user vpopmail@localhost
-- example:
mysql> create database vpopmail;
mysql> GRANT ALL PRIVILEGES ON vpopmail.* TO vpopmail@localhost IDENTIFIED BY "secret";

Once this is taken care of, edit /usr/local/vpopmail/etc/vpopmail.mysql. Simply insert the line:

localhost|0|vpopmail|secret|vpopmail

Format: user,pass,db
--
Thx for this How-to.

anonymous:

Marco,

Thanks for your suggestion. I agree that with qmail as the MTA, the 4 daily items are not desired.

Pavan:

Hello Sir,
I am new to all these mail administration and have found myself stuck in this.I have got qmail binaries got them installed and they run fine on checking the status.
Then the problem is that however the qmail is able to collect the mails but it doesnot forward them to the users either local or remote and mail log shows some CNAME resolution problem

can you please help
Pavan

Great doc but one thing u mised!
U dont have to change
AUTHMODULES="authdaemon"
to
AUTHMODULES="authvchkpw"
you do that in the authdaemon configuration file
authdaemonrc
In it there's a line saying
authmodulelist="authcustom authuserdb authvchkpw authpwd"
I just put
authmodulelist="authvchkpw"
there.

i followed the docs from chap 1 - 4 and everything is working except for imap-ssl. i got this error:


Mar 11 23:13:49 diameter imapd-ssl: Connection, ip=[::ffff:203.177.22.134]
Mar 11 23:13:49 diameter imapd-ssl: Opening smtp relay for IP [::ffff:203.177.22.134] apellido
Mar 11 23:13:49 diameter imapd-ssl: LOGIN, user=apellido@diameter.mactan.ph, ip=[::ffff:203.177.22.134], protocol=IMAP
Mar 11 23:13:49 diameter imapd-ssl: Unexpected SSL connection shutdown.
Mar 11 23:13:49 diameter imapd-ssl: DISCONNECTED, user=apellido@diameter.mactan.ph, ip=[::ffff:203.177.22.134], headers=0, body=0
Mar 11 23:13:49 diameter imapd-ssl: Connection, ip=[::ffff:203.177.22.134]
Mar 11 23:13:50 diameter imapd-ssl: Opening smtp relay for IP [::ffff:203.177.22.134] apellido
Mar 11 23:13:50 diameter imapd-ssl: LOGIN, user=apellido@diameter.mactan.ph, ip=[::ffff:203.177.22.134], protocol=IMAP
Mar 11 23:13:50 diameter imapd-ssl: couriertls: read: Connection reset by peer
Mar 11 23:13:50 diameter imapd-ssl: DISCONNECTED, user=apellido@diameter.mactan.ph, ip=[::ffff:203.177.22.134], headers=0, body=0

Stefan:

IS Are och een virus Scanner for deze Qmail ?

Jonathan Lin:

I have problems with my imap-ssl also. getting the exact same error.

sundeep:

hello sir plz talk me qmail configration and how to start qmail service .

yours
sundeep kumar

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 27, 2003 8:14 PM.

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

The next post in this blog is Formatting, formatting and... some more formatting..

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.