Complete Virtual Mail Server/Courier-IMAP to Database

Introduction
Courier-IMAP will be used to provide both IMAP and POP3services. Many will be interested in IMAP as POP3 is not being used as much anymore. This is quite understandable as IMAP has many advantages.

The major difference between POP3 and IMAP would be that IMAP keeps messages on the server whereas with POP3, the client retrieves the messages and are then gone from the server. Having the messages kept on server allows for several clients to actively work with the same mailbox from different locations. The most basic example would be webmail and a desktop client, both accessing the same mailbox at the same time. Also in general, webmail clients strongly favor IMAP. The price this comes with of course, is primarily disk space and processing power on your server. With disk space being as cheap as it is these days, 32Gb set aside pure for e-mail offers a lot of space for mails, at hardly any cost. And if processing power is an issue, which are generally used by server-side based searches, they could be disabled.

This chapter will mainly focus on IMAP, but will include POP3 for completeness sake. Some research into the two protocols may be required if the choice is not so certain.

Installing Courier-IMAP
has a few useflags that need to be examined. is an important dependency as it is responsible for how users authenticate, so it's useflags are examined aswell.

Only choose the desired database backends.

If the proper useflags are set, emerging courier-imap should pull in courier-authlib.

Postgres
Courier-authlib runs as root, so access to the socket will be permitted by default.

If logins via user@domain.com instead of username, the value of PGSQL_LOGIN_FIELD needs to be changed from local_part to username.

To use more advanced authentication SQL statement the PGSQL_SELECT_CLAUSE can be used. Courier-authlib will ignore any of the previous set parameters for SELECT statements, but will use them for counting the number of accounts or for changing the password and thus when changing the password the username field is still used. If authentication is done against username remember that usernames need to be unique.

Configuring authdaemon
Authdaemon is actually responsible for doing the authentication. Here it needs to be configured which database backend needs to be used. Portage actually does set the authmodulelist variable properly. Verify this in the configuration file. Also enable debugging here.

Access permissions
Permissions must be set correctly, as the files can contain sensitive password information.

Testing courier-authlib
Courier-authlib includes a simple testing utility. At its least it requires a valid username as parameter. Don't hesitate to

for details. The man page is short but concise.

To perform some basic tests run authtest on the your testuser.

POP3
POP3 requires little configuring to get working. It is however recommended to skip this section and not enable/use pop3 and thus leave this setting at NO. A user may be able to remove all messages that where supposed to be stored on the server for imap usage, then incorrectly configure his mail client and purge the server of his mailbox this way.

IMAP
IMAP has a few capabilities that can be enabled.
 * SORT to allow server side searching through messages.
 * IDLE to allow 'push' like connections.

POP3
Courier-pop3d should be started.

Once started, telnet should be used to identify initial problems. Once logging in with telnet works, a mail client can be used.

If testing works properly, add courier-pop3d to the default runlevel.

IMAP
Courier-imapd should be started.

Once started, telnet should be sed to identify initial problems. Once logging in with telnet works, a mail client can be used.

If testing works properly, add courier-imap to the default runlevel.

Wrapping things up
Turn off debugging if this stage works properly.