How to‎ > ‎

FreeBSD 9 Mail server setup: Postfix, Dovecot 2, Virtual Users, MySQL, SASL, Postfixadmin and others

FreeBSD is my favourite server operating system since 2000. I like it because every time it performs as expected, it is well documented, not to mention how easy is to keep it up to date.
For long time I used FreeBSD to serve email to corporate customers or other tasks. Now I will show how I did package installation and configuration for an email server with virtual email users, using the following components:

- Postfix version 2.8, to handle SMTP mail reception, with SASL authentication enabled. For local mail delivery I choose dovecot local delivery agent (LDA) Dovecot-LDA instead of Postfix-VDA (virtual delivery agent), due to Postfix VDA's lack of quota warnings.
- Dovecot version 2.1, for local delivery, POP3 and IMAP access to mailboxes. It is also providing an authentication socket for the SMTP process, to enable SASL authentication for roaming users. The dovecot local delivery agent and the IMAP protocol support quota enforcing and reporting to IMAP clients. Also, dovecot LDA is able to send quota warnings.
- A MySQL database to store information about email accounts (passwords, descriptions) and anti-spam preferences for amavisd-new
Other features will be covered later, I'm referring to TLS/SSL support.
- Postfixadmin - a nice frontend to the database used to store email accounts and manage user's vacation auto-response.
- Amavisd-new version 2.8, an advanced content filtering service. This service is able to reduce SPAM and can be instructed to scan mail for viruses using multiple antivirus processes. At this time, amavisd-new is able to make use of SpamAssassin's SPAM detection features and check and/or verify DKIM signatures.
- postgrey - an implementation of Greylisting policy daemon, the most effective anti-spam mechanism I've used until now
- SquirrelMail version 1.4.22, a classic webmail interface. I've selected this frontend because our email clients are using it since 5 years ago, a change to Roundcube is taken into account. SquirrelMail is able to interoperate with PostfixAdmin, making it possible to change auto-response and/or password from one frontend instead of two, if a specific plugin is used.

On this example I didn't covered/enabled (yet) SSL/TLS support for SMTP, POP3, IMAP and webmail access. The disk layout should include a dedicated partition/volume for mail storage (this will be mounted under /mail on this example), a dedicated partition for mysql database and a dedicated partition/volume for /var. The partitioning and mysql database relocation to another partition is not covered by this guide.
Another important thing to remember: this How-To is made by copying the steps I took while I installed a mail server. There may be some steps I didn't mention, if there is a failure starting a process, checking /var/log/maillog, /var/log/amavisd.log and /var/log/all.log will help.
If there are any errors in this guide, please use the comment form below to let me know about it.

This how-to covers a server installation, from scratch.  Below are the steps I followed