Setting up a self-hosted mail server can be complex, but with MailCow, the process becomes more manageable. In this guide, we’ll walk you through the installation and configuration of MailCow, an open-source mailing script based on Dovecot, Postfix, and SoGo. By the end of this tutorial, you’ll have a fully functional self-hosted mail server running on Docker.
Requirements:
- Domain name
- VPS or Cloud server with minimum 6 GB RAM
- Recommended OS: Ubuntu 20.04
Initial DNS Setup:
Before installation, set up the following DNS records:
| Type | Host | Value |
|---|---|---|
| A | Your IP address | |
| CNAME | autodiscover | mail.yourdomain.com |
| CNAME | autoconfig | mail.yourdomain.com |
| MX | @ | mail.yourdomain.com 10 |
Installation of MailCow:
- Set hostname:
hostnamectl set-hostname mail.yourdomain.com - Install Git:
apt install git -y - Install Docker:
curl -sSL https://get.docker.com/ | CHANNEL=stable sh systemctl enable --now docker - Install Docker Compose:
apt update apt install docker-compose-plugin - Install Git:
apt install git -y - Clone MailCow repository:
cd /opt && git clone https://github.com/mailcow/mailcow-dockerized - Navigate to the cloned directory:
cd mailcow-dockerized - Generate the configuration:
./generate_config.sh - Pull MailCow Docker images:
docker-compose pull - Run Docker Compose:
docker-compose up -d - Open required ports in firewall:
sudo ufw allow 25,80,443,110,143,465,587,993,995/tcp - Access MailCow: Open
https://mail.yourdomain.comin your browser and log in with admin/password (moohoo).
Congratulations! You have successfully installed and configured MailCow as a Docker container on your server. Enjoy the benefits of a feature-rich mail server while maintaining control over your data.
Note: Ensure proper security and maintenance practices for your mail server.
That’s it! You now have a comprehensive guide on installing and configuring MailCow as a Docker container. Enjoy your self-hosted mail server experience!