Dovecot Postfix Virtual

This article aims to guide you through the process of setting up a virtual mailserver using postfix and dovecot. Its goals are to provide virtual mail hosting, SSL encryption for IMAP and SMTP, and plain text files for user databases and configuration.

It is meant for experienced users who understand email and know what they want from their servers. It does not go into depth about options and alternatives, but does aim to provide configuration files in their entirety.

The article Mail server using Postfix and Dovecot describes these two programs and the configuration process in more detail.

This article differs from existing articles in that it does not use PostfixAdmin nor SQL databases. It is meant to be easy to convert to a high availability email setup using filesystem-level distribution (eg glusterfs).

User Names
IMAP and SMTP users have email addresses as well as usernames. The article uses the email address as that IMAP account's username, but this is not required.

Installation, Versions and USE
Be sure to inspect the use flags set on your system before performing the merge. This configuration used the versions and requires the USE flags following: Postfix 2.5.7 dovecot-sasl pam sasl ssl

Dovecot 1.1.7-r1 berkdb pam ssl

Add a vmail user
Mailboxes must be owned by a real account on the mail server. This confiugration uses one account for all mailboxes, rather than defining different user accounts for different mailboxes. The following command creates a vmail user with appropriate home directory, nologin shell, and uid.

dovecot.conf
Let's jump right into /etc/dovecot/dovecot.conf. Many configuration parameters are left at their defaults.

The Dovecot passwd database
The passwd database stores IMAP and SASL user names and passwords. The file's syntax is more or less self explanitory.

Once new users are added, changes to this file will be picked up by dovecot automatically.

To generate a password, the easiest way is to use dovecotpw:

You should now have a passwd file that looks something like this (the password in this case is "foobar"):

Postfix
Postfix configuration is not trivial! Be careful.

Resources
These pages were useful to me in the creation of this document.

Postfix
http://www.postfix.org/SASL_README.html#server_dovecot

Dovecot
http://wiki.dovecot.org/HowTo/SimpleVirtualInstall#Simple_Virtual_User_Installation