Qmail

qmail is a fast, popular Mail Transfer Agent (MTA).

Pre-installation
As only one MTA can be installed at the same time on a system, you might be required to unmerge an installed MTA. The package manager will report a block when another MTA is still installed. You can resolve this block by manually unmerging the old mail server. For example you can remove (which might have been installed as the default when a program requested a mail server to be installed) with this command:

Installation
has several USE flags that may be desired for certain bigger setups. As this article aims at installing and configuring a basic netqmail setup, we'll add qmail plugin support with qmail-spp and ucspi-tcp support.

Configuration
The default 16MB of memory for qmail is a little sparse, so let's update the memory to 32MB to avoid memory related errors.

Setting up non-root account for mail
The design of qmail has been completely around the focus of security. To this end, e-mail is never sent to the user 'root'. So now you have to select a user on your machine to receive mail that would normally be destined for 'root'. From now on in this guide, I will refer to that user as I have it in my setup, 'myusername'.

Or if you'd like this email to be sent elsewhere, simply put the full address in:

Fully Qualified Domain Name (FQDN)
Though not entirely related, for a MTA to function properly, it is imperative that its hostname is set up correctly. Under Gentoo /etc/conf.d/hostname and /etc/conf.d/net are the files responsible for this. In this example, the mail server is named foo on the domain example.com.

Verifying that the FQDN is setup properly for the domain.

Creating Properly Signed Certificates
Move to the qmail control directory:

Upgrade the Cert Info to create a 2048bit key:

Update the Cert Info with information pertinent to you. CN is your fully qualified domain name ie. foo.domain.com

create the pem files and key

Get the contents of the request pem file:

Send req.pem to your CA(ie godaddy/Starfield, Versign, etc.) to obtain signed_req.pem and do:

Start qmail and add it to the default run level
Run the init scripts and setup supervisor links for qmail:

start and add netqmail to the default run level

vpopmail
vpopmail will handle virtual domains, adding, deleting mail domains, accounts, storing passwords etc. vpopmail uses mysql in this setup, so if you don't have it running please install it.

First we need to tell qmail to use vpopmail when checking smtp passwords:

Let's install and setup :

Create the vpopmail database

Edit /etc/vpopmail.conf and update the mysql password for the vpopmail user:

dovecot
Finally we'll add to talk to our email clients:

Add vpopmail uid info to the default dovecot config:

Edit dovecot ssl configs to pass our ssl certificate to email clients when the login to get mail securely:

}}

Start dovecot and add to the default runlevel: