Setting Up A Self-Hosted Mail Server With iRedMail On Debian Bookworm

Email remains one of the most critical communication tools for individuals and businesses. To ensure a secure and efficient email infrastructure, many opt for a self-hosted mail server. In this post, I will guide you through the process of installing and configuring iRedMail on Debian Bookworm to serve the a registered domain. iRedMail is a robust, open-source email server solution that simplifies the task of setting up a mail server while maintaining high security standards.

If you want to discuss the topic with other technology-minded people, join my Discord: https://discord.gg/YbSYGsQYES

Now we have an IRC channel as well: irc.libera.chat / #tomsitcafe

Prerequisites

Before we start, make sure you have the following prerequisites in place:

  1. A VPS or dedicated server (running Debian Bookworm in this presentation). Currently iRedMail is not supported to run in containers in production environment.
  2. A fully registered domain (like tomsitcafe.com) with DNS records pointing to your server’s IP address.
  3. SSH access to your server.
  4. Basic knowledge of the Linux command line.

The fully qualified domain name (FQDN) must be set properly!

sudo hostname mail.<domain>.com

Set the FQDN in the /etc/hosts file as well!

Update your system

Start by logging into your server via SSH and ensuring your system is up to date. Run the following commands:

sudo apt update
sudo apt upgrade

Installing iRedMail

iRedMail simplifies the installation of various mail server components.

To install it, run the following commands:

# Download the latest archive
wget https://github.com/iredmail/iRedMail/archive/1.6.8.tar.gz

# Extract the files
tar xvf 1.6.8.tar.gz

# Change to the iRedMail directory
cd iRedMail-1.6.8/

# Start the installer
sudo bash iRedMail.sh

Follow the on-screen instructions to configure iRedMail. When prompted, provide the necessary information, including your domain (tomsitcafe.com), the admin password, and the database backend. Make sure to choose suitable options for your setup.

Configuring DNS records

After the installation, you’ll need to configure your DNS records. Add the following records to your domain’s DNS zone:

  • MX Record: Point this record to your server’s hostname (e.g., mail.tomsitcafe.com).
  • A Record: Create an A record for your mail server’s hostname.
  • SPF Record: Set up a Sender Policy Framework (SPF) record to specify which servers are authorized to send emails on behalf of your domain.
  • DKIM Record: Configure DomainKeys Identified Mail (DKIM) to add a layer of email authentication.

Configuring SSL/TLS

Securing your email communication is essential. Use Let’s Encrypt to obtain SSL/TLS certificates for your mail server. Install Certbot and obtain certificates for your domain:

sudo apt install certbot
sudo certbot --nginx -d mail.tomsitcafe.com

Configuring email clients

Now that your iRedMail server is up and running, configure your email clients (Outlook, Thunderbird, etc.) to connect to your new mail server. Use the following settings:

  • Incoming Server: mail.tomsitcafe.com
  • Outgoing Server: mail.tomsitcafe.com
  • Username: Your email address (e.g., user@tomsitcafe.com)

Ensure that your email clients use SSL/TLS for both incoming and outgoing servers.

Setting up a mail server with iRedMail on Debian Bookworm is a robust solution for maintaining control over your email communication. By following these steps, you can have a secure and fully functional mail server for your domain. Always stay updated with security patches and regularly back up your data to maintain the reliability of your mail server. Enjoy your self-hosted email solution!

If you want to discuss the topic with other technology-minded people, join my Discord: https://discord.gg/YbSYGsQYES

Leave a comment