This tutorial is for the former stable version "Debian Lenny". If you are using "Debian Squeeze" then please follow the new tutorial.
A spanish translation of this tutorial is also available - courtesy of José Ramón Magán Iglesias.
What this tutorial is about
You surely know the internet service providers that allow you to rent a domain and use it to receive emails. If you have a computer running Debian which is connected to the internet permanently you can do that yourself. You do not even need to have a fixed IP address thanks to dynamic DNS services like dyndns.org. All you need is this document, a cup of tea and a little time. When you are done your server will be able to...
- receive and store emails for your users from other mail servers
- let your users retrieve the email through IMAP and POP3 - even with SSL to encrypt to connection
- receive and forward ("relay") email for your users if they are authenticated
- offer a webmail interface to read emails in a web browser
- detect most spam emails and filter them out or tag them
This tutorial book is copyrighted 2009 Christoph Haas (email@example.com). It can be used freely under the terms of the GNU General Public License. Don't forget to refer to this URL when using it. Thank you.
- 17.6.09: Lenny tutorial gets published.
- 19.6.09: The page on SPF checks is temporarily offline. A new page on spam/virus/phishing fighting is currently prepared.
Things you will need
The server setup described here is totally standard work for a professional system administrator. Depending on your level of knowledge and experience you may walk through this document easily or curse the author and fail miserably. You will need to know or learn about different topics regarding basic system administration (e.g. how do I edit a text file, where are my log files), DNS, SMTP, MySQL and POP3/IMAP. You also need root access to an existing Debian Lenny server or be able to install one. Also you will likely have to change DNS records for your domain. If your server is protected by the firewall make sure you can change its rules. Going through this setup takes you between 2 hours (for a professional) and a week (if you are a beginner who will inevitably make mistakes). So make sure you are not in a hurry.
About this document
Many years ago I wanted to turn my Debian server into a mail server with virus scanning, spam detection, email forwarding ("aliasing"), POP3 and IMAP access and a webmail service. All the components were there but it took a while until they worked properly together. So I summed up my desk full of scrawly notes into a tutorial that has become pretty famous. According to my web server statistics it's the main reason why people visit workaround.org.
This document is not a simple copy-and-paste tutorial where you just copy the commands from the web site and run it on your server. Instead it will make you understand the different components that you are setting up. In the end you will be skilled enough to debug problems yourself. If you feel you need help with your setup then try the hints in the Troubleshooting section or ask on the mailing list. The setup in this tutorial has been tested very thoroughly by many readers. Unlike many other Postfix tutorials on the internet this is already the fifth edition. Writing this tutorial took a lot of work so these are not just quick draft notes thrown together but a consistent document guiding you.
The whole tutorial is split into several chapters. Please use the links on the right side or below to navigate through the tutorial. If you prefer all content on a single page (e.g. for printing the tutorial) then use the "printer-friendly" link below. You are also invited to comment on the pages - just click on the "Add new comment" link at the bottom.