home Tutorial The Ultimate Guide to Setting up MailCow – Best Self-Hosted Mail Server

The Ultimate Guide to Setting up MailCow – Best Self-Hosted Mail Server

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.


  • 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 mail Your IP address
CNAME autodiscover mail.yourdomain.com
CNAME autoconfig mail.yourdomain.com
MX @ mail.yourdomain.com 10

Installation of MailCow:

  1. Set hostname:
    hostnamectl set-hostname mail.yourdomain.com
  2. Install Git:
    apt install git -y
  3. Install Docker:
    curl -sSL https://get.docker.com/ | CHANNEL=stable sh
    systemctl enable --now docker
  4. Install Docker Compose:
    apt update
    apt install docker-compose-plugin
  5. Install Git:
    apt install git -y
  6. Clone MailCow repository:
    cd /opt && git clone https://github.com/mailcow/mailcow-dockerized
  7. Navigate to the cloned directory:
    cd mailcow-dockerized
  8. Generate the configuration:
  9. Pull MailCow Docker images:
    docker-compose pull
  10. Run Docker Compose:
    docker-compose up -d
  11. Open required ports in firewall:
    sudo ufw allow 25,80,443,110,143,465,587,993,995/tcp
  12. Access MailCow: Open https://mail.yourdomain.com in 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!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.