The Big Picture
The Software we will use
The configuration described here uses these software components (the versions are Debian Lenny's default versions):
- Postfix (2.5.5) for receiving incoming emails from the internet and doing basic checks
- Dovecot (1.0.15) to store emails on hard disk and allow users to access their emails using POP3 and IMAP
- Squirrelmail (1.4.15) as a webmail interface so users can read their emails using a web browser
- MySQL (5.0.51a) as the database backend storing information about domains, user accounts and email forwardings
- AMaViS (2.6.1) for content scanning incoming emails using ClamAV and SpamAssassin
- Clam Antivirus (0.94) for virus checking
- SpamAssassin (3.2.5) for spam checking
The wonderous Ways of an Email
Before going into the details let's see the big picture:

- An email is sent to your server via the SMTP protocol on TCP port 25. Postfix accepts the connection, reads the email and does some basic checks. Is the sender blacklisted on a realtime blacklist? Is the email from an authenticated user so we bypass relay checks? Or is the recipient of the email a valid user on our system? If we don't trust the remote system yet we apply greylisting. At this stage Postfix can reject the email or accept it.
- Postfix forwards the email via the SMTP protocol on the TCP port 10024 to AMaViS for content checking. Notice that at this stage the email can't be rejected any more. So AMaVis can either accept it or throw it away. Commonly AMaViS is configured to add a certain email header so the user can see that AMaViS thinks it is spam.
- AMaViS lets SpamAssassin check the email for spam. SpamAssassin will be taught which emails are spam to increase its detection accuracy.
- AMaViS also runs the email through ClamAV to see if it contains any viruses.
- After these checks AMaViS returns the email to the Postfix process but on TCP port 10025. Postfix is configured to trust emails sent to this port so further content checks are skipped.
- Postfix forwards the email to Dovecot. Dovecot can optionally apply per-user filters so that emails can be stored in certain email folders automatically if desired.
- Dovecot writes the email to the hard disk in maildir format.
- The user's email client can now fetch the new emails from Dovecot using the POP3 or IMAP protocol.
Comments
Qmail on Debian Lenny 5.0
Qmail on Debian Lenny 5.0 with courier http://qmailrocks.thibs.com/
Qmail?
Why are you advertising Qmail+Courier on a Postfix+Dovecot tutorial. More to point, why are you advocating Qmail in 2010?
why qmail
Postfix+dovecot is an alternative ... qmail with courier is another one.
I don't want to launch a flame about MTA ... but Qmail is still an excellent MTA used by the biggest Internet Companies (Yahoo, ...)
Autoreply/Autoresponder
Hi, the place to add an autoresponder probably would be after alias expansion/storage. A short search resulted in http://www.postfix.org/addon.html#autoreply but before I dig in deeper, I was hoping someone might have some experience and is willing to share a few hints. Ideally, a single web form can be used to configure the autoreply. Must not reply to e-mail tagged as spam.. Thanks!