This article describes how to set up a complete virtual user mail system on an Arch Linux system in the simplest manner possible. However, since a mail system consists of many complex components, quite a bit of configuration will still be necessary. Roughly, the components used in this article are Postfix, Cyrus, Courier, PAM, PostfixAdmin and Roundcube.

In the end, the provided solution will allow you to use the best currently available security mechanisms, you will be able to send mails using SMTP and SMTPS and receive mails using POP3, POP3S, IMAP and IMAPS. Additionally, configuration will be easy thanks to PostfixAdmin and users will be able to login using Roundcube. What a deal!

This article assumes that you have a working LAMP setup as we will need a working Apache2 as well as MYSQL database. Of course, with a few changes to these instructions you could easily use another httpd and database. For the purposes of this tutorial, however, the choice made above will be used. Additionally, the article assumes all-default settings for every package installed below. No changes except for those mentioned will be required.

Should any unforeseen problems occur, feel free to use the discussion page to voice your problems and I will try to answer.

Configuration

User

A gid and uid of 5000 is used in both cases so that we do not run into conflicts with regular users. All your mail will then be stored in /home/vmail. You could change the home dir to something like /var/mail/vmail but careful to change this in any configuration below as well.

Database

You will need to create an empty database and corresponding user. We will be using PostfixAdmin's tables to fill the database later on. In this article, postfix_user will have read/write access to postfix_db using hunter2 for a password. You are expected to create your database and user yourself. Make sure to assign proper permissions.

Postfix

There are basically 2 ways for of doing SMTPS.

One is using the wrapper mode which enables even old/odd clients like Outlook to use TLS. The wrapper mode uses the system service "smtps" which is a non-standard service and runs on port 465.

The other, more proper method is to use a port that simply enforces TLS without any wrapping. The system service for this is "submission" which is standard and uses port 587.

Cyrus

If you use submission, you do not have to do add anything. You can run both services at the same time, though, in which case you will still need to add the smtps system service or postfix will refuse to start.

PostfixAdmin

To install PostfixAdmin, we need to manually get its upstream package and extract it to our web root (or other desired directory). You should use the most recent version available at the time. This article will use the most recent version at the time of writing.

Next, PostfixAdmin needs to be configured. Assuming localhost is the hostname of the machine you are installing this on, navigate to http://localhost/postfixadmin-2.3.2/setup.php. The setup will guide you through the remaining steps to set up PostfixAdmin.

Roundcube

As with PostfixAdmin, this article will use the most recent version as of the time of writing. You should always use the most recent version available.

Assuming that localhost is your current host, navigate a browser to http://localhost/roundcubemail-0.4/installer/ and follow the instructions. You could use the same database for Roundcube that you already used for PostfixAdmin though you shouldn't. For a proper setup, create a second database "roundcube_db" and a "roundcube_user" for use with Roundcube.

While running the installer, make sure to address the IMAP host with tls://localhost/ instead of just localhost. Use port 993. Likewise with SMTP, make sure to provide ssl://localhost/ on port 465 if you used the wrapper mode and tls://localhost/ on port 587 if you used the proper TLS mode. See here for an explanation on that.

rc.conf

The services should be restarted in the correct order on system restart. Make sure your DAEMONS array in /etc/rc.conf contains:

The order in which the daemons are started up is actually important here.

As a final bit of configuration, Postfix needs to be able to write to saslauth. Thus:

chown postfix:postfix /var/run/saslauthd

Now for testing purposes, create a domain and mail account in PostfixAdmin. Try to login to this account using Roundcube. Now send yourself a mail.

Troubleshooting

If you get errors like your imap/pop3 client failing to receive mails, take a look into your /var/log/mail.log file. Make sure your saslauth daemon is running:

# rc.d restart saslauthd

If imapd-ssl tells you that it want to chdir into a specific directory but that directory is not available, just send one email to the account and try again.
It turned out that the maildir /home/vmail/mail@domain.tld is just being created if there is at least one email waiting. Otherwise there wouldn't be any need for the directory.