Complete Virtual Mail Server/System Setup and Packages

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 could run on a different system, as could the spam checker and database server.

Also, because I am hosting multiple domains my Apache install supports name based virtual domains (instructions for that are here Apache2 and here PHP).

Installed Packages
Other then apache/php as mentioned above, the following packages are required. Only install packages that you want to use of course where there is choice. E.g. don't install both mysql and postgres (unless you use them for different purposes of course, both dba's can live happily together). Some packages may be pulled in as per useflag from other packages.

Also, as packages get updated and configuration options change, please update this document where changes where needed in the specific sections.



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  and  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:

Since IPv6 is marginally deployed yet, it's hard to test. Turn it on after testing it works with regular IPv4, and make additions to this document where needed.

If you use mysql over postgresql enable this one and disable postgres.

The database to store our virtual user information.

Support for Secure Socket Layer connections

Include support for the Simple Authentication and Security Layer.

Adds support for virtual delivery agent quota enforcing.

I chose the maildir format supported by Postfix (one of the reasons for choosing Postfix).

Absolutly do not use mbox.

Support for IMAP, one of the main interfaces offerd by this HOWTO.

Support virtual hosts.

Enable decompression for our virusscanner.

Used by cyrus-sasl.

Authdaemond is used by courier-imap.

Crypt functions for PHP.

Spell checking for PHP.

IP to Location mapping for spamassasin etc.

Use spamassassin.

If you have a heavy load on your mailserver due to clamav running alot, clamdtop can help a lot debugging it.

With the correct useflags set, emerging just postfix will pull in most, if not all useflags in. If you have a slow system you could jump the gun, and all ready install nearly all packages via postfix.