Would you like to have your own mail server? Are you familiar with Linux? Then this guide will help you set it up. All it takes is a little time and effort, the monthly costs of a cheap virtual server (starting at around 5€) and a domain at your favorite hosting provider. The software being used is completely free and open-source. You can even make money with it. After all it is called “ISPmail” (ISP = internet service provider). Are you a sysadmin and your employer needs a mail server for their 500 employees? Or do you just want to get rid of freemail services for yourself? Then go with this guide. It has been battle-tested by thousands of other readers.
The setup is based on open-source software. There is no catch. I don’t charge for this guide. If you learn something and end up with a working mail server this makes me happy. Yes, I’m a bit weird, I know. If you feel you would like to return the favor you can easily make me happy by clicking on the donation link at the bottom of this page. And please respect the copyright. I have seen literal copies of my work on the internet by people even making money with it. That’s annoying.
This guide is different from most other because you will learn how email transport and delivery works. You will obtain the skills needed to install, reliably run and troubleshoot your mail server. I firmly believe that those skills are necessary because what good is a broken server with a sysadmin who doesn’t even know where to find the log files.
I have maintained this guide since Debian Woody was released in 2002. It has taken me entire holidays to write and maintain it. So thank you all for your kind feedback and support – I would probably have discontinued this guide without you. And this is already the ninth edition. Un… fucking… believable. 🙂
What your mail server will be able to do…
- Receive emails for your own domain.
- Filter out most of the spam and malware.
- Send emails out to any other servers/domains on the internet.
- Encrypt all connections (if the other mail servers have encryption enabled, too).
- Add cryptographic DKIM signatures to outgoing emails automatically to help others verify your emails as authentic.
- Store as many emails for as many email addresses as you have disk space.
- Optionally encrypt emails on the server.
- Set quotas (mailbox size limits) per user.
- Let your users fetch email using IMAP or POP3 and send email through your servers using SMTP.
- Allow users to manage server-based filter rules. Distribute incoming emails to different folders. Forward copies. Or send out-of-office notifications.
- Provide a webmail interface so users can access their emails securely from any location using just a web browser.
- Mitigate brute force attacks.
- Have firewall rules to protect the server.
What you will need
- Linux experience. Preferably using a Debian-derivative like Debian, Ubuntu or Mint. No godlike skills required. But know your basics: navigating through the file system, editing files, watching log files and having basic understanding of DNS and SQL (SELECT, INSERT, rows, columns).
- Time and patience. You will need 2 hours to 2 days depending on your skills. We will proceed slowly and after every step ensure that no mistakes were made. Don’t hurry and skip parts even if they appear confusing or boring at first. If you get lost just submit your question at the bottom of any page throughout this guide and help is on the way.
- A server that runs with Debian Buster. (Support for other Debian-derivatives is considered.) 1 GB of RAM and a 20 GB disk is fine for your friends and family. Rent a cheap virtual server. Or use a decommissioned laptop or old PC. Other Linux distributions likely come with other versions of the software and have different default configuration – so your mileage will vary if you use anything else than Debian.
- A public IP address that does not belong to a range of typical ISP customers. You usually can’t operate the mail server from a dialup IP address at home because those IP ranges are globally blacklisted as mail servers. Make sure that your IP address is not blacklisted before you start.
- An internet domain (or more) to receive emails for. You need to be able to set A, MX and TXT records for that domain.
Why this guide may not be for your
You don’t care about learning anything? You just need a working mail server quickly? There are ready solutions like iRedMail that you may want to consider. Preparing and running a mail server requires a certain technical understanding. And that’s what the ISPmail guide is for. Experience from giving support to other sysadmins shows that most problems appear because some detail in a complex setup goes wrong and they have no idea how to track it down. Email has evolved a lot over the past 35 years and has become a complex matter. 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.
The whole tutorial is split into several pages. Please use the links on the right side to navigate through the pages. Make sure you have the server, a non-blacklisted IP and a domain ready. Let’s go.