Courier IMAP

see man imapd for using file alteration monitor (package fam). configuration files all live in /etc/courier

install packages

> apt-get install courier-base courier-authdaemon fam \
courier-ldap courier-imap courier-ssl courier-imap-ssl \
courier-pop courier-pop-ssl courier-doc

It is your choice if you want directories or files for the courier configuration. These notes assume files.

startup script

here is a handy startup script to start and stop all courier processes.

/etc/init.d/courier:

#!/bin/sh

case "$1" in
start)
          /etc/init.d/courier-authdaemon start
          /etc/init.d/courier-imap start
          /etc/init.d/courier-imap-ssl start
          /etc/init.d/courier-pop start
          /etc/init.d/courier-pop-ssl start
          ;;
stop)
          /etc/init.d/courier-authdaemon stop
          /etc/init.d/courier-imap stop
          /etc/init.d/courier-imap-ssl stop
          /etc/init.d/courier-pop stop
          /etc/init.d/courier-pop-ssl stop
          ;;
restart | reload | force-reload)
          $0 stop
          sleep 1
          $0 start
          ;;
*)
        echo "Usage: $0 {start|stop|reload}" >&2
        exit 1
        ;;
esac
exit 0

logging

NOTE: instead of this hack, just use syslog-ng instead. It will let you send all the courier log entries to a courier file, plus can slice and dice (and remove IPs!).
in tcpd/logger.c, change LOG_MAIL to LOG_LOCAL3 this way, we can log to a different log file, which is really nice to be able to do. copy the tcpd/logger executable to /usr/sbin/courierlogger (or where it is specified in /etc/init.d/courier-*).

edit /etc/syslog.conf:
local3.*   -/var/log/courier.log

testing

Once you have courier all configured, you can test authentication and the user backend by using courierauthtest:

# courierauthtest <user> [password]

for example:

# courierauthtest redcursor xxxxx
Authenticated: module authdaemon
Home directory: /var/maildir/r/redcursor
UID/GID: 8/8
Maildir: /var/maildir/r/redcursor
AUTHADDR=redcursor
AUTHFULLNAME=Red Cursor Collective
OPTIONS=<none>

if it is not working, you will get
Authentication FAILED!