Welcome to the ISPmail tutorial for Debian Jessie. Since Debian Woody I have provided step-by-step-instructions for setting up and operating your own mail server. So this is already the seventh issue. Yay.
A personal note: I have been working on this issue for three weeks in my spare time. And I deliberately removed any advertisements from workaround.org because I’m opposed to that. So if this guide helps you in any way please consider donating. You can find the appropriate links at the very bottom of this page. Thank you. And of course your feedback or questions are welcome – comment on any page of the ISPmail guide that you find appropriate.
What this tutorial is about
This tutorial teaches you all the basics about running a mail server that is completely controlled by you, as secure as you like and fully powered by open-source software. And while you are setting up your mail server you will learn a lot about communication protocols like IMAP or SMTP. You will also learn how emails find their way through the internet using DNS records. You can use it to run a free mail server for your company, your familiy, your friends or just for yourself. You can put any number of accounts and domains on it. So screw “free” mail services and take control of your email communication again. Essentially all you need is a computer hooked to the internet, an installation medium of Debian Jessie and a little time. When you are done your mail server will be able to…
- receive and store email for your users from other mail servers on the internet
- let your users retrieve the email through IMAP and POP3 using TLS-encrypted connections
- let your users define rules what to do with incoming email – e.g. distribute them to their mail folders or reply automatically
- let your users send (“relay”) email to the internet using SMTP authentication
- offer a beautiful webmail interface so that your users can manage their email just using a web browser
- deal with spam effectively without losing emails
What this tutorial is not about
If you are lazy or in a hurry or just don’t want to learn anything about mail servers – then this guide is not for you. There are ready solutions like iRedMail that you may want to consider. But running a mail server requires a certain technical understanding. And that’s what the ISPmail guide is for. Experience from giving support in the #postfix channel on IRC shows that sysadmins 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.
Why is it called ISPmail?
The software components that are used in this guide are proven and powerful enough so that you could become an ISP (internet service provider) yourself and sell email services. You will need powerful servers, a backup solution, proper monitoring, staff and a bigger internet connection. But essentially the system will work for 10 or 10,000 users.
Does this guide work with other flavors of Linux?
The software components are available on most Linux distributions. However the versions will vary slightly and the installation paths in your filesystem will be different. So feel free to work through this guide to learn the basics. But be prepared if pieces do not work out of the box. I am considering to offer this tutorial for Ubuntu 14.04 LTS because it gets increasingly popular – but currently the priority is upon Debian Jessie.
Things you will need
The server setup described here is 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 get to grips with the basics. It works best if are familiar with basic system administration tasks like editing text files or starting/stopping services, DNS and MySQL. Make sure you have:
- One or more internet domains to receive email at. Either you manage the DNS yourself or you let domain providers do that for you. However you need to be able to change DNS records. If your ISP just offers “web sites” or “web redirects” then transfer your domain to a decent provider.
- A computer capable of running Debian Jessie. Unless you have special needs I would suggest you get a low-cost virtual server from your favorite hosting company. Those start at $5 for example at Vexxhost. Start with 10 GB of mailbox space per user, 1 GB of RAM and any CPU.
- A permanent internet connection and an IP address for your mail server that does not change. The IP address should not be blacklisted on the internet. Check the IP address at web sites like http://www.anti-abuse.org/multi-rbl-check/ or http://rbl-check.org/. If your IP address shows up on black lists then other mail servers on the internet will likely refuse your emails or consider them spam.
- Experience with operating a Linux system – preferably even a Debian/Ubuntu system.
- Basic understanding of DNS. You will need to set up DNS records of the domains that you like to receive email for. At least you need someone who can manage “MX” and “A” records for your domain.
- Enough skills to install and configure a basic MySQL database server. You will not need to tune the server. But you should understand the basics of relational databases (databases, tables, rows, fields/columns) and the meaning of simple SQL queries.
- Control over the firewall that connects your server to the internet. You will need to allow certain TCP ports through to your mail server. Also make sure that your internet provider does not block any ports. Professional ISPs are usually not a problem. But cheap home ISPs often block ports like TCP/25 which is used for the SMTP protocol.
- Time. 2 hours of time if you are a seasoned Linux administrator. Or 2 days if running your own Linux server on the internet is a new topic for you.
Although the tutorial is complete as it is I am working on these additional sections:
- Automatic deployment with Ansible
- Automatic signing of outgoing email using domain keys (DKIM)
- A Ruby-on-Rails web application that helps you manage your mail server
Please respect the copyright
Please ask if you would like to use parts on your own web site. Feel free to contact me if you have any questions or leave a donation if you found the tutorial useful. I am maintaining these tutorials in my spare time and am not making any money with it. It annoys me to find copies of this tutorial or parts of it on other web sites. I think you will understand that.
About this tutorial
Over a decade 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 me quite 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 over ten years ago. 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 and hope they will work. 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 pages. Please use the links on the right side to navigate through the pages. You are also invited to comment on the pages or ask questions. Just use the comment feature at the bottom of each page.