Creating a Linux Email Server: Part 1

calendar

January 23, 2022

categories
Guides
tags
email router server setup

Content:

If you own your own domain, self hosting an email server can seem like an attractive option. However, the initial setup can be quite complex – a fully fledged mail server requires several software components to work together.

There are guides available which attempt to outline these steps, however, many of these are rather lacking. Issues range from being poorly written, having steps out of order to using software commands before the software is even installed, and failing to explain many of the steps undertaken.

This guide aims to make things easier, splitting up each part of the process, and testing our configuration along the way.

I’ll be using a Raspberry Pi running the latest version of Raspberry Pi OS – some of the commands (particularly for installing software) may be slightly different for the system you are using.

Why Create an Email Server?

While domain providers typically allow at least one email account to be set up, they lack the flexibility that you can achieve through self hosting.

It allows you to create any number of email addresses, all of which can be made easily accessible from one mailbox. This is ideal for splitting websites across multiple emails – for example, one for purchases, one for ebay sales, a throwaway for suspicious sites etc.

You could even set up an individual email for each site. And if any individual address becomes a target for spam, you can simply throw it away and use another one.

And for a prospective employer, it will certainly appear more impressive if you are able to set up and manage an email server yourself.

Checklist

To better understand the complete process, throughout this guide we’ll be referring to the following checklist.

  • Open ports on our router/configure ports on our web host
  • Add DNS records for our IP address
  • Add MX records for our IP address
  • Set up DKIM/SPF/DMARC records
  • Install Postfix
  • Configure Postfix for outgoing emails
  • Configure Postfix for incoming emails
  • Set up user mailboxes
  • Install Dovecot
  • Configure Dovecot/SASL

While this may look complex, this guide will break these steps down into manageable chunks. This will make the process easier to follow.

Before moving on to the next part of the guide, it is recommended to install a firewall on your machine. Take a look at our guide here for instructions on how to do this.

Instructions for configuring UFW will be included throughout this guide where appropriate.

On To Part Two

So far, we’ve looked into the reasons for hosting your own email server, and mapped out the steps that we’ll be taking through this guide.

Check out part two, where we’ll begin setting up our router.

If you like what we do, consider supporting us on Ko-fi