Building a mail server on Debian 6.0

Goran Jurić

This is version 0.6.0 of Building a mail server on Debian.

Legal Notices

This document is released under the Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) licence.

You are free to Share (copy, distribute and transmit the work) and to Remix (to adapt the work) under the following conditions:

  • You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

  • You may not use this work for commercial purposes.

  • If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

Any of the above conditions can be waived if you get permission from the copyright holder. The full licence can be found here.

Revision History
Revision 0.7.02011-04-27
Added "caching DNS server", "SPF" and "Errors" chapters
Revision 0.6.02011-03-14
Added a chapter on moving Amavisd-new configuration to MySQL
Revision 0.5.02011-02-21
Moved Bayes and AWL data info MySQL

Table of Contents

1. Introduction
1.1. Why Postfix
1.2. Why Debian
1.3. Sofware used
1.4. Required knowledge
2. Preparation
2.1. Debian installation
2.2. Tracking configuration changes
2.3. Essential software
2.4. Setting a static IP address
2.5. DNS settings
2.5.1. Caching only nameserver
2.6. NTP - time synchronization
2.7. Apache, MySQL and PHP
3. Security
3.1. Server certificates
3.2. Firewall
3.3. Limiting SSH access
3.4. Intrusion detection
4. Postfix
4.1. Initial settings
4.2. Virtual users and domains
4.3. MySQL
4.4. Saslauthd
4.5. Preventing unwanted access
4.6. TLS
4.7. Submission port
4.8. Blocking certain attachments
4.9. Maximum message size
4.10. Commit your changes
4.11. Important commands
4.12. Quota support
5. Courier
5.1. Installation
5.2. Use certificates
5.3. Firewall rules
5.4. Commit your changes
6. Fighting spam
6.1. ClamAV
6.2. SpamAssassin
6.2.1. Training SpamAssassin
6.2.2. Move Bayes and AWL data to MySQL
6.3. Amavisd-new
6.3.1. Store configuration in a database
6.3.2. Maintenance
6.3.3. Utilities
6.4. DKIM
6.4.1. DKIM check for incoming emails
6.4.2. Signing your outgoing mail
6.5. RBL lists
6.6. Greylisting
6.7. SPF
7. Utilities
7.1. Maildrop
7.1.1. Per user filtering
7.2. Vacation
7.3. Webmail
8. Errors
8.1. "auxpropfunc error no mechanism available"
8.2. error (network unreachable) resolving '': ::::#53
8.3. managed-keys-zone ./IN: loading from master file managed-keys.bind failed: file not found
8.4. Filesystem notification initialization error -- contact your mail administrator (check for configuration errors with the FAM/Gamin library)
8.5. amavis[1414]: (01414-07) NOTICE: reconnecting in response to: err=2006, HY000, DBD::mysql::st execute failed: MySQL server has gone away at (eval 114) line 166, <GEN156> line 5