Gentoo Wiki


Complete Virtual Mail Server

Getting Started

  • System Setup and Packages

Basic Mail Setup

Enhanced Mail Services

Anti-Spam Configuration

Anti-Virus Configuration

Log Analyzer

Wrapping it Up


System Deployment

Just to make things a little more interesting, I decided it would be fun to spice up the configuration a bit by doing a multi-system installation. Currently I have a Gentoo server that is hosting a web page. Seeing as I already have an Apache install, I don’t want to create another one, so I will use what I have for all of my web-based admin tools. The mail server and its supporting elements will run on a different system.

The diagram below will show you the two machines and what lives where. Also, because I am hosting multiple domains my Apache install supports name based virtual domains (instructions for that are here Apache2 Install).

Mail ServerWeb Server
Courier IMAPApache
Courier authlibPHP
Cyrus SASLWebmin

Now before people go flaming me for how I have distributed things on my servers, I just want to say “get over it”. My configuration choices are not what this guide is about, I am just showing what configuration changes are needed to span multiple boxes. You can make all your own decisions about what is right for your specific situation. I have selected what is right for mine.

(2006-10-07, by mknappe) Only differences are:


Installed Packages

I have included a complete list of packages for those of you who do not have broadband internet access and want to pre-fetch the source packages. Of course, if you don’t have broadband access, I will assume that you are only installing this on your home machine for testing purposes and will eventually roll this out to a proper server. Like I said, this is an industrial strength solution and not something you would even begin to bother setting up to run out of your basement on a dial-up connection.

I have included the version numbers so that you know exactly what I used. This is my way of saying that if you use any other versions, then there may be difference in the configuration details which unfortunately you will need to figure out for yourself.

Of course there will also be a mitt-full of dependent packages that will also need to be loaded, but no worries, portage will take care of them.

(2006-10-07, by mknappe) I started out with a Gentoo 2006.1 install, please refer to the installation docs on how to achive this. I emerged these packages:


Before you Start

I know that at this point you just want to get to the good stuff. Before digging into this, I strongly suggest the following:

  1. READ THIS DOCUMENT. This is a long document and there are many opportunities to go off the rails. If you take the time to become familiar with all of the steps and understand the role each of the packages play, recovery from mistakes will be much quicker. Trust me on this one; I had to find out the hard way.
  2. Not all of the packages included in this HOWTO are required to get the basic mail server working. SMTP Authorization, Web Administration Tools, SPAM filtering, etc. are not absolute necessities to offer mail services, just really good things to have. By reading through this first, you can figure out which ones you do not want or need and save yourself the work of installing them to begin with.
  3. While I have done my best to be accurate here, there is no doubt, like all HOWTOs, this one pretty well assumes that everything in your system is going to be where it should be and that everything will go right at each step. In reality, things will go wrong, at which time the web will prove to be an invaluable resource in resolving whatever issues you may hit.
  4. A key to testing all of this is having at least one domain (and two would be better if you want to test virtual domains), with the appropriate MX records setup. There are many DNS options out there so a couple of domains and supporting DNS services shouldn’t cost more then $40 for the year. This is not the time to go cheap. Invest the money and make your life a whole lot simpler.
  5. Pay close attention to the messages displayed after you emerge any packages. Depending on the state of your machine when you started all of this, the installation of these packages may result in the need to update some of your configuration files. You will be prompted and can use etc-update to handle the process. There are no instructions in this HOWTO covering this as what you face will be different for each machine.
  6. Be sure your system is up to date. Complete an rsync and emerge –u world before starting this. I ran into a number of problems as a result of old applications with new utilities, etc. Once I updated things, these went away only leaving the standard integration problems

Finally, to avoid a lot of rework on this, check your USE variables in your /etc/make.conf file before you start compiling anything. If the wrong flags are set, you will most likely need to recompile things later to ensure the support needed to make this work is compiled in. Some of the key flags settings I used are:

-ipv6Adds support for IP version 6. Many HOWTOs suggest this should be turned on, but I am not using it, not setup to use it so have switched it off so that I don’t get all kinds of errors in my messages log about not finding files, etc.
-mysqlAs I am not using this database, I do not want to carry around the baggage of adding this support.
postgresOn the other hand, I am using Postgres, so ensure that this is set.
sslSupport for Secure Socket Layer connections.
saslInclude support for the Simple Authentication and Security Layer. [[Note. This is correct, but unless you want LDAP on your system, you currently need to build dev-lang/php-5 with -sasl. The sasl USE flag is currently interpreted incorrectly by the PHP ebuild, and upcoming versions will have a local "ldap sasl" USE flag. sasl support is not required for PHP. Add dev-lang/php-5 -sasl to /etc/portage/package.use]]
vdaAdds support for virtual delivery agent quota enforcing.
maildirI chose the maildir format supported by Postfix (one of the reasons for choosing Postfix).
-mboxI am absolutely not using mbox and don’t particularly want it anywhere near my system.
libwwwSupport for the libwww general purpose web API.
imapSupport for IMAP, one of the interfaces offered by this HOWTO.
Retrieved from ""

Last modified: Sun, 08 Jun 2008 07:46:00 +0000 Hits: 18,932