ISPmail guide for Debian Stretch

christoph-haasThis guide will help you set up your own mail server while you learn how email transport and delivery works on the internet nowadays. I have maintained this guide since Debian Woody was released in 2002. Back then it took me weeks to get all the information I needed. Has that really been 16 years by now? Wow. Thank you all for your kind feedback and support – I would probably have discontinued this guide without you. And this is already the eigth edition.

BETA WARNING – I know that this tutorial for Debian Stretch is pretty late. My employer moved their office to a new location right after Debian Stretch was released and that took a lot of my time. The large amount of “fan mail” reminded me to keep writing though. 🙂 Usually I take the time to go through the guide from scratch, build a new mail server on a test domain and check if everything is working for a while before I let you waste your time. Let me be honest – this time I have not done that. If you find anything unclear, misleading or wrong then please add a comment and I promise to fix that as quickly as possible. There are also sections still in the making – about virus scanning, DKIM signing, mitigating brute force attacks and enforcing mail quotas. It will take a few days to get that done. Thanks for your patience.

Latest changes:

I am publishing this guide without any commercial interest. It just makes me happy to see more and more leisure sysadmins leave public freemail providers and operate their own servers. 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.

So what will the mail server cost you? The only recurring costs you may face are for running your mail server and for renting a domain. Cheap virtual servers are usually available at around $5 / 5€ per month and have enough power to run a mail server for your friends and family. 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? Go with this guide.

What your mail server can do

  • Receive emails on your domain(s).
  • Filter out spam and malware.
  • Send emails out to any other servers/domains on the internet. Connections will be encrypted when possible.
  • Add cryptographic signatures (DKIM) to outgoing emails.
  • Store as many emails for as many email addresses as you have disk space. Set limits (“quotas”) 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.
  • Mitigate brute force attacks.

What you will need

  • Linux experience. Preferably a Debian-derivative. 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. 2 hours to 2 days depending on your skills.
  • server that runs with Debian Stretch. 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. Other Linux distributions likely come with other versions of the software and have different default configuration – so your mileage may 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. 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.
  • Patience. We will proceed slowly and after every step ensure that you made no mistakes. Don’t hurry and skip parts even if they appear confusing 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.

What this is not about

If you are lazy or in a hurry or just don’t want to learn about mail servers then this guide is not for you. There are ready solutions like iRedMail that you may want to consider. 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 40 years. 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. Or as one of the first long-haired nerds put it…

Everything should be made as simple as possible, but no simpler.
(Albert Einstein)


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.

8 thoughts on “ISPmail guide for Debian Stretch

  • 2018-01-21 at 19:02

    Thanks so much for your hard work putting this together!

  • 2018-01-22 at 19:26

    Yep big thanks for all those clear and clean explanations..
    In my case I will try to adapt this tutorial using docker containers instead..
    But since I’m a newbie, it will be hard..
    Any further lectures are welcome..

  • 2018-01-23 at 08:17

    Nice, good work. I’ll wait until you have completed the guide with the other sections and then setup a new server.

    love your work

  • 2018-01-25 at 01:09

    Using your clean, well curated, and explained guides since Debian Sarge, first time I configured a mail server, thanks to you.

    I really want to thank you for all these years maintaining this valuable contribution. Not only useful but amazingly educative too!

  • 2018-02-02 at 06:55

    Hi, does this support soft quota? I can’t seem to find it anywhere in the guide.
    Love the docu though, i learned a lot.. I’m thinking of migrating from courier to dovecot, any thoughts?


    • 2018-02-02 at 09:27

      It will. I have a few pages still in the making. The next two pages will be about virus scanning and DKIM signatures though.

  • 2018-02-02 at 17:40

    Thank you for your hard work.

    Kimsufi servers KS-1 just available, I think it’s time to migrate my old (wheezy…) mail server.

    Now I know what I will do this Week-End 😉


  • 2018-02-16 at 19:36

    Nice work!
    I think you could register a free domain instead of using
    This will be much clearer.

    Just my opinion!


Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.