Welcome back to another issue of the ISPmail tutorial. You are interested in learning all the basics about running your own mail server on a Debian server? Be my guest. All you need is a computer running Debian “Wheezy” and an internet connection. This tutorial explains step-by-step how to set up such a server and give you lots of background information in the process. Depending on your internet connection and server hardware you will be able to run a reliable mail service for thousands of domains and users. Soon you will be a proud operator of a mail server that can:
- receive and store email for your users from other mail servers on the internet
- let your users retrieve the email through IMAP and POP3 – even using SSL-encrypted connections
- let your users define rules what to do with incoming email – e.g. distribute them to their mail folders or reply automatically. These rules are server-based and work automatically.
- receive and forward (“relay”) email for your users using SMTP authentication
- offer a beautiful webmail interface so that your users can manage their email just using a web browser
- reject a lot of spam emails automatically
- store your emails where secret services do not look
What this tutorial is *NOT* about
If you just need a no-cost mail server quickly and don’t care about the technical mumbo-jumbo then this is the wrong place for you. There are ready solutions like iRedMail if you are in a hurry. But running a mail server requires a minimal technical understanding. I personally recommend that you understand what you are doing. And that’s what the ISPmail guides are for. Experience from giving support in the #postfix channel on IRC shows that leisure sysadmins often fail because some detail in a complex setup goes wrong and they have no idea how to track it down. Go with ready solutions if you like. But I have a feeling that we meet again. And you will probably not save time either taking the easy route.
Does this guide work with other flavors of Linux?
Most of it does, yes. However certain paths in your file system may be different. And some software components like Dovecot may behave differently if you are not using the version that Debian Wheezy uses. So feel free to work through this guide to learn the basics. But be prepared if pieces do not work out of the box.
Maintaining such a complex tutorial is a lot of work. And I keep maintaining it in my spare time. So please respect the copyright. This document is copyrighted 2013 Christoph Haas (firstname.lastname@example.org). Feel free to use it under the terms of the GNU General Public License. Don’t forget to refer to this URL and name me as an author when using parts of it. Feel free to contact me if you have any questions of leave a donation if you found the tutorial useful.
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 need more patience to learn how to manage Linux systems. You will need to know about basic system administration tasks, DNS, SMTP, MySQL and POP3/IMAP. Make sure you have:
- a computer to run Debian on (a cheap virtual server at your favorite ISP or a decommissioned desktop computer)
- an installation medium if you don’t have a working Debian installation yet
- an internet connection
- basic knowledge on how to operate a Linux system
- basic understanding of DNS, your own (sub-)domain and arbitrary control of the A and MX records of your domain
- enough skills to install and configure a basic MySQL database server
- control over the firewall that connects your server to the internet
- a workstation running a mail client that speaks POP3, IMAP and SMTP (e.g. Mozilla Thunderbird, kmail or evolution)
- a static IP address that is not a dial-up address because most internet providers will refuse emails from dynamic IP addresses – not sure? Go to http://rbl-check.org/ and make sure that your IP address is not shown on any black-list.)
- If your internet connection has a dynamic IP address then you will need an SMTP relay (most decent ISPs offer that) because you usually can’t send out emails directly to other mail servers.
- 2 hours of time if you are a seasoned Linux administrator / 2 days if running your own Linux server on the internet is a new topic for you
About this tutorial
Many years ago I wanted to turn my Debian server into a mail server with virus scanning, spam detection, email forwarding, POP3 and IMAP access and a webmail service. All the components were available 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 still the most frequently read article at 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. Unlike many other Postfix tutorials on the internet this is already the seventh 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.
Changes from the previous “Squeeze” tutorial
- Sieve filters are now much simpler to use. Dovecot 2.0 and Roundcube are an easy combination to let your users manage server-based email rules.