apt-get install courier-imap courier-authlib-mysql fam

authdaemon

codetitle. /etc/courier/authdaemon

authmodulelist="authmysql"
daemons=10
DEBUG_LOGIN=1 # (sent to /var/log/mail.log in default syslog conf)

codetitle. /etc/courier/authmysqlrc

MYSQL_SERVER        user-pn
MYSQL_USERNAME      nest_mail
MYSQL_PASSWORD      xxxxx
MYSQL_DATABASE      nest

MYSQL_USER_TABLE    mailboxes
MYSQL_CRYPT_PWFIELD password
DEFAULT_DOMAIN      riseup.net
MYSQL_UID_FIELD     '8'
MYSQL_GID_FIELD     '8'
MYSQL_LOGIN_FIELD   address
MYSQL_HOME_FIELD    CONCAT('/maildir/',maildir)
MYSQL_MAILDIR_FIELD CONCAT('/maildir/',maildir)
MYSQL_QUOTA_FIELD   quota
MYSQL_WHERE_CLAUSE  storage_host='cormorant.riseup.net'

/etc/init.d/courier-authdaemon restart 

imapd

codetitle. /etc/courier/imapd

MAXDAEMONS=300
MAXPERIP=10000
IMAP_EMPTYTRASH=Trash:21,Spam:7,Sent:120

codetitle. /etc/courier/pop3d

MAXDAEMONS=300
MAXPERIP=10000