Previous TOC Next

Technical document: Linux Mail Server Howto
Chapter 2 - Introduction

Purpose and scope

The aim of this document is to build a mail server, basically from scratch (i.e with no mail related software or services present or running on your system) that has the following functionality:

  • Relays mail from authorised users (SMTP relay)
  • Delivers incoming mail to appropriate mailboxes
  • Provides an IMAP interface to mailboxes for external mail clients
  • Hosts both system and non-system mail accounts (virtual user hosting)
  • Hosts mailboxes for multiple domains (virtual domain hosting)

This HOWTO describes setting up these mail services on a Linux machine. This machine is not intended as a dedicated mail server, and the install described will not effect other services or utilities that the machine may be hosting. However there is no reason why the set-up described here could not be used for dedicated mail hosting.

This document is broadly split into chapters as follows:

  • Installing and configuring the mail transport and delivery agent postfix. Postfix handles the relaying (transport) of mail from one domain to another. The postfix package also includes it's own delivery agents for local mailbox delivery.
  • Installing and configuring the courier-imap authentication daemon authdaemond. This service authenticates mail access for both system and non-system users, providing access details such as the location of a mailbox to courier-imap.
  • Installing and configuring courier-imap itself. This is the imap daemon which listens for connections from external clients, providing an (IMAP) interface to a hosted mailbox.
  • Accessing your mailboxes over IMAP, and configuring an IMAP client such as Mozilla Thunderbird.
  • Creating virtual users and domains for hosting many users and multiple domains.

Postfix vs sendmail

There are many ways that one could conceivably set-up a mail server, what works for you (or what's best for you) obviously depends on your requirements. The biggest choice really concerns what mail transport agent (MTA) and delivery agent (MDA) to use. The traditional choice is probably sendmail as the MTA, and procmail, or simply mail, as the delivery agent. However, procmail, although a very powerful and flexible MTA, is not the best solution for delivery to virtual mailboxes, which is a requirement here. At best it is extremely fiddly, and not guaranteed reliable (see the many discussions on why you can't trust email headers). Postfix however comes bundled with its own delivery agent, and makes the setting up of virtual mailboxes extremely easy.

Email - a crash course

In brief: an MTA such as postfix is a service which is wholly concerned with the transportation (relaying) of mail from one host to another, per the Simple Mail Transport Protocol (SMTP). Postfix listens for connections on port 25, and will relay mail either to the remote host specified, or, if the destination is local, will pass to the MDA. It is the MDA which is responsible for actually delivering mail to the appropriate mailbox. Configuring how mail is delivered to mailboxes is thus down to configuring your MDA correctly.

The purpose of the imap daemon is to provide an interface through which remote clients may access their mailboxes, as opposed to having to run pine (or similar) locally. Most modern email clients support the IMAP protocol.

Here we discuss installing courier-imap, which requires installing two seperate packages: courier-imap itself, plus the authentication package authdaemond.

In this document we describe using postfix for SMTP relaying and local delivery, and courier-imap for remote access over IMAP.

Note: If you are intending on using IMAP over SSL (strongly recommended), then you must make sure you have a development version of OpenSSL or GnuTLS installed on your system before proceeding. "Development" means the source code, not just the binaries.

Previous: Chapter 1 - Preamble TOC Next: Chapter 3 - Installing Postfix