How to Setup Your Own Mailserver with Mailcow


December 22, 2023 / Tobias Mildenberger / TutorialsHow to Setup Your Own Mailserver with Mailcow (Head Image)

Mailcow is an open-source email server solution, designed for Docker, that simplifies the setup of email services on Linux. It integrates essential components like a mail transfer agent, a webmail client, and security features into one system, making it ideal for those who seek a straightforward and robust email server. Let us start with How to Setup Your Own Mailserver with Mailcow!

Why Choose Mailcow for Email Server on Linux 

Mailcow’s open-source framework ensures regular updates and security enhancements. Its Docker compatibility eases installation and management across different Linux distributions. The platform is user-friendly, featuring a web-based interface for easy configuration and maintenance. This combination of accessibility, security, and ease of use makes Mailcow a prime choice for setting up a reliable email server on Linux. 

Understanding Mailcow

Features

of Mailcow 

Mailcow stands out as a comprehensive email server solution, offering a blend of features that cater to both novice users and seasoned system administrators. Understanding these features and their advantages is key to appreciating what makes Mailcow a preferred choice for email server deployment. 

Advantages of Mailcow

In summary, Mailcow’s combination of an integrated suite of tools, user-friendly management interface, robust security features, Docker compatibility, customization options, active community support, and cost-effectiveness makes it a powerful and versatile choice for anyone looking to deploy an email server on Linux. 

Mailcow Requirements 

Before diving into the installation of Mailcow, it is crucial to understand and prepare the necessary hardware and software components, as well as to set up your Linux server correctly. This chapter will guide you through these prerequisites to ensure a smooth and successful Mailcow deployment. 

Hardware Requirements

Software Requirements

Installing Mailcow 

This chapter provides a detailed guide on installing Mailcow on Debian 11, including DNS settings. It is important to follow these steps carefully to ensure a successful installation. 

Full Step-by-Step Installation Guide on Debian 11 

Preparing the System 

Update System Packages

sudo apt update 
sudo apt upgrade

Install Required Dependencies

sudo apt install curl git

Installing Docker and Docker Compose 

Install Docker

curl -fsSL https://get.docker.com -o get-docker.sh 
sudo sh get-docker.sh

Install Docker Compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 
sudo chmod +x /usr/local/bin/docker-compose 

Configuring DNS Settings 

Before installing Mailcow, configure DNS settings for your domain. The full and detailed DNS Setup can be found in Mailcow’s Official Documentation

Installing Mailcow 

Clone the Mailcow Repository

git clone https://github.com/mailcow/mailcow-dockerized 
cd mailcow-dockerized

Generate Configuration File

./generate_config.sh

When prompted, enter your domain (e.g., mail.example.com). 

Start Mailcow

sudo docker-compose up -d

Verifying the Installation 

Check if all containers are running: 

sudo docker-compose ps 

Initial Configuration Settings 

After the installation, you need to perform initial configuration: 

Access Mailcow UI: Open a web browser and go to https://mail.example.com. You will be greeted by the Mailcow UI. 

Log in to Admin Panel

Default credentials are usually admin for username and moohoo for password. 

Change Admin Password

Go to ‘Configuration’ -> ‘Mail setup’ and change the admin password. 

Configure DKIM and DMARC

In Mailcow UI, navigate to ‘Configuration’ -> ‘ARC/DKIM keys’. 

Generate a new key and add the displayed DKIM record to your DNS settings. 

For DMARC, add a DMARC TXT record in your DNS settings (e.g., v=DMARC1; p=none; rua=mailto:postmaster@mail.example.com). 

Create Mailboxes

Use the Mailcow UI to create user mailboxes as needed. 

Test Email Functionality

Send and receive test emails to ensure everything is working correctly. 

Configuring Mailcow 

Once Mailcow is installed, the next step is to configure it for your specific needs. This chapter focuses on setting up domains and mailboxes, which are crucial for personalizing and operationalizing your email server. 

Setting Up Domains 

To begin sending and receiving emails, you need to add your domain(s) to Mailcow. Here is how to do it: 

Access Mailcow UI: Navigate to your Mailcow UI by entering https://mail.example.com in your web browser. 

Log in: Use your admin credentials to log in. 

Navigate to Domain Section

In the Mailcow UI, go to the ‘Configuration’ tab. 

Under ‘Mail setup’, select ‘Domains’. 

Add a New Domain

Click on ‘Add domain’. 

Enter your domain name (e.g., example.com). 

Configure additional settings like Quota, Backup MX, and Active status as per your requirements. 

Save Changes: Click ‘Add domain’ to save the configuration. 

Verify the Domain

Ensure that your DNS settings are correctly pointing to your Mailcow server (as configured in the previous chapter). 

Mailcow might perform some checks to verify domain ownership. 

Setting Up Mailboxes 

After adding your domain, the next step is to create mailboxes for individual users or purposes. 

Navigate to Mailbox Section

Under the ‘Mail setup’ tab, select ‘Mailboxes’. 

Create a New Mailbox

Click on ‘Add mailbox’. 

Fill in the required details: 

Local Part: The part of the email before the @ (e.g., user for user@example.com). 

Domain: Select the domain you added earlier. 

Password: Set a strong password for the mailbox. 

Full Name: The name of the user or purpose of the mailbox. 

Quota: Set the storage limit for the mailbox. 

Save the Mailbox: Click ‘Add mailbox’ to create the mailbox. 

Repeat for Additional Mailboxes: Follow the same steps to create more mailboxes as needed. 

Accessing Mailboxes

Users can access their mailboxes through the webmail interface or by configuring their email client with the newly created email credentials. 

Testing

It is important to test the new mailboxes by sending and receiving emails to ensure everything is functioning correctly. 

With these steps, you have successfully configured domains and mailboxes in Mailcow. This configuration is the heart of your email server, allowing you and others to start using it for daily email communication. Remember to periodically review and update these settings as your needs evolve. 

Conclusion

Recap of Setting Up Mailcow 

We have covered a comprehensive journey in setting up Mailcow as an email server on a Linux platform, specifically Debian 11. This guide has taken you through various critical stages: 

Best Practices 

As you continue to manage and use your Mailcow server, keep in mind the following best practices to ensure its optimal performance and security: 

By following these steps and best practices, you have equipped yourself with the knowledge to successfully manage a Mailcow email server. This setup not only provides you with control over your email communication but also offers a robust, secure, and flexible platform tailored to your specific needs.