Next the configuration of the authentication module, it will be used by everything the mail-server does. SMTP authentication, access to the IMAP mailbox and eventually access to the web based mail program. To enable the authentication module to use the Postfix database we created earlier configure it as follows:

Edit the file ‘authmysqlrc‘ in the directory ‘/usr/local/etc/authlib‘. This will configure the database access like where it is, how to connect, which user and password and which tables and fields to use.

MYSQL_SERVER localhost
MYSQL_USERNAME postfix
MYSQL_PASSWORD postfixpassword
 
# if you used the MySQL package from MySQL.com use the
# following settings otherwise check your MySQL installation.
MYSQL_SOCKET /private/tmp/mysql.sock
MYSQL_PORT 3306
 
# The name of the MySQL database we will use:
MYSQL_DATABASE postfix
 
# the table in the database with the users
MYSQL_USER_TABLE mailbox
 
# which field in the table has the password
MYSQL_CRYPT_PWFIELD password
 
# the numerical userid of the _vmail account
MYSQL_UID_FIELD ’102′
 
#the numerical groupid of the postfix account
MYSQL_GID_FIELD ’27′
 
# the username as defined in the table mailbox
MYSQL_LOGIN_FIELD username
 
# the location of the mailboxes on the server
# Please change this is you are going to use a different location.
MYSQL_HOME_FIELD ‘/usr/local/virtual’
 
# The user’s name (optional)
MYSQL_NAME_FIELD name
 
# The location where the user mailbox is defined in the table.
MYSQL_MAILDIR_FIELD maildir

Next is configuring the authentication module to use the MySQL based authentication module. Edit the file ‘authdaemonrc‘ in the same directory ‘/usr/local/etc/authlib‘. We only are going to use the MySQL database for authentication so we need to remove the others:

# The authentication modules that are linked into authdaemond.
authmodulelist=”authmysql”
# This setting is used by Courier’s webadmin module,
# and should be left alone
authmodulelistorig=”authuserdb authpam authldap authmysql
      authcustom authpipe”
# The number of daemons running concurrently on the server
daemons=3
# authdaemonvar is here, but is not used directly by authdaemond.
# It’s used by various configuration and build scripts.
# So don’t touch it !
authdaemonvar=/usr/local/var/spool/authdaemon
# when testing set the level at 2
# when everything runs smoothly set it to 0.
DEBUG_LOGIN=2
# keeping the defaults for the rest for now.
DEFAULTOPTIONS=”"
LOGGEROPTS=”"

Next step: Configuring Courier IMAP with your maildir