Mail Server - Courier Installation


Following from the previous article, we have the base Postfix and MySQL installed. As such, we can move on to installing Courier which will allow us to access the mail server with POP and IMAP access (as well as secure POP and IMAP).

Contents

Installation

Installation of the various packages is very simple using the aptitude package manager. Remember we already have many packages installed when we looked at Postfix, MySQL and saslauthd.

let's go ahead and install Courier:

sudo aptitude install courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl

During the installation you will be asked if you wish to create directories for web based administration:

courier_install.jpg

Select 'No' as the answer (no is the default anyway, so you should just need to press Enter/Return).

The next page requires a simple press of the Enter/Return key. We will configure Courier to use our self-signed certificate.

Configuring Courier to use the MySQL database

Now we need to configure Courier to access the MySQL 'mail' database for authorisation.

First thing is to edit the following file:

sudo nano /etc/courier/authdaemonrc

Find the following option:

authmodulelist="authpam"

And change it to read:

authmodulelist="authmysql"

Save the changes.

MySQL

The next courier file contains the details of the MySQL database:

sudo nano /etc/courier/authmysqlrc

You have two options on how to approach editing this file.

Firstly, you can delete all the contents and replace them with the details shown below.

Or, secondly, you can find each setting and replace it will the ones shown below.

Personally, I delete the contents and use the details as shown below - but as the file is quite lengthy, you may want to keep a backup for the comments for any future tweaking you do.

Either way, the following details need to be entered into the file:

MYSQL_SERVER localhost
MYSQL_USERNAME mailadmin
MYSQL_PASSWORD newpassword
MYSQL_PORT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')

Note the USERNAME and PASSWORD will need changing to the details you set when creating the MySQL mail database.

Restart

We have made some significant changes to the Courier setup so we need to restart Courier.

Note there are 5 different daemons that are running:

One main authorisation daemon and 4 others relating to POP, POPS, IMAP and IMAPS:

sudo /etc/init.d/courier-authdaemon restart
sudo /etc/init.d/courier-imap restart
sudo /etc/init.d/courier-imap-ssl restart
sudo /etc/init.d/courier-pop restart
sudo /etc/init.d/courier-pop-ssl restart

Summary

Installing and configuring Courier to use our MySQL 'mail' database is fairly easy with the editing of just two files.

This now allows us POP, secure POP, IMAP, and secure IMAP access to our mail server.

However, unless we open some ports in our firewall no one will be able to access to the services. We'll look at that in the next article.

Previous Article
Next Article



Was this content helpful?




© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER