Mailcow Setup and Docker Panel (Portainer): Easily Manage Your Own Mail Server!
Having a business email address is no longer a luxury—it’s a must-have for almost every organization. But is it possible to run a fast, secure, and open-source mail infrastructure without relying on third parties?
Our answer: Yes, absolutely!
In this guide, I’ll walk you through Mailcow setup and Docker panel (Portainer) so you can easily manage your own mail server—step by step, in clear and approachable language. Let’s get started!
What is Mailcow? Who Is It For?
Mailcow is a robust, modern, and open-source mail server solution. No need for expensive, complex alternatives like Zimbra or Microsoft Exchange—Mailcow is perfect for anyone who wants full control and freedom.
- Modern, user-friendly (and multilingual) web UI
- Integrated antispam & antivirus
- Calendar, contacts, file sharing (via SOGo)
- Automatic or manual SSL support (with Let’s Encrypt)
- Multi-domain and easy user management
- Docker based, so it’s easily upgradeable and portable
Before You Start: What Do You Need?
- A Ubuntu 22.04 LTS server (virtual or physical) with at least 2 GB RAM
- A static and publicly accessible IPv4 address
- Your own domain and DNS control (e.g., for mail.yourcompany.com)
- SSH root (or sudo) access to the server
Mailcow Dockerized Installation (Step-by-Step)
- Update your server and install required packages:
sudo apt update && sudo apt upgrade -y sudo apt install -y git curl docker.io docker-compose sudo systemctl enable --now docker
- Download Mailcow and configure basic settings:
cd /opt sudo git clone https://github.com/mailcow/mailcow-dockerized cd mailcow-dockerized sudo cp mailcow.conf.example mailcow.conf sudo nano mailcow.conf
MAILCOW_HOSTNAME=mail.yourcompany.com
→ Replace with your actual domainTZ=Europe/Istanbul
→ Set your time zoneACME=y
→ For automatic SSL (Let’s Encrypt)
- Start the installation:
sudo ./generate_config.sh sudo docker compose pull sudo docker compose up -d
- Open the necessary firewall ports (UFW):
sudo ufw allow 22,80,443,25,587,993,995/tcp sudo ufw enable
- Set your DNS records:
- A record: mail.yourcompany.com → your server’s IP address
- MX record: yourcompany.com → mail.yourcompany.com
- SPF:
v=spf1 mx ~all
- DKIM & DMARC: Generate these in Mailcow’s admin panel and add to your DNS
- Accessing the web panel & resetting the admin password:
- Mailcow web admin: https://mail.yourcompany.com
- If you have any trouble with the admin password, just reset it easily:
cd /opt/mailcow-dockerized sudo ./mailcow-reset-adminpw.sh
Managing SSL Certificates in Mailcow
- Automatic SSL with Let’s Encrypt: As long as
ACME=y
is set inmailcow.conf
, Mailcow will automatically obtain and renew your SSL certificates. - To use your own SSL certificate:
- Upload your certificate and key files to
/opt/mailcow-dockerized/data/assets/ssl/
- Filenames:
cert.pem
(certificate),key.pem
(private key) - Then restart the nginx service with:
sudo docker compose restart nginx-mailcow
- Upload your certificate and key files to
Docker Panel (Portainer): Manage Everything Visually
If you’d rather not use the command line for Docker management, Portainer is a fantastic solution. Start, stop, and monitor all your Mailcow containers in a beautiful web UI—just a click away!
- Create a volume for Portainer:
docker volume create portainer_data
- Start Portainer:
docker run -d -p 9443:9443 --name=portainer \ --restart=always \ -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data \ portainer/portainer-ce:latest
- Access Portainer: Go to https://your_server_ip:9443 in your browser and log in.
Now you can monitor, start, stop, and review logs of all Docker containers—Mailcow included—without touching the command line.
Frequently Asked Questions
- Is Mailcow free? – Yes, it’s 100% open source and free to use.
- Can I install Mailcow without Docker? – No, Mailcow is Docker-only.
- I forgot my admin password. What do I do? – Use
mailcow-reset-adminpw.sh
to set a new one in seconds. - Can Mailcow replace Zimbra or Exchange? – Absolutely! It’s a modern, cost-effective, and flexible alternative for businesses and teams.
- Is Portainer secure? – Yes. It supports user authentication and SSL out of the box.