Self-Hosted Mail Server with Mailcow on Docker

Complete mail server solution running on 18 Docker containers.

Deploying a Self-Hosted Mail Server with Mailcow on Docker

I recently completed the setup of a comprehensive self-hosted mail server using Mailcow, a full-featured mail server suite based on Docker containers. This project involved deploying and configuring 18 interconnected containers to provide a robust, secure, and scalable email infrastructure.

Mailcow Mail Server Overview

Project Overview

The goal was to establish a private email server that offers full control over data, enhanced security, and cost savings compared to commercial email providers. Mailcow was chosen for its comprehensive feature set, including webmail, antivirus scanning, spam filtering, and administrative tools—all packaged in a Docker-based architecture for easy deployment and management.

The setup runs on 18 Docker containers, each handling specific services such as:

  • Postfix for SMTP services
  • Dovecot for IMAP/POP3
  • Roundcube webmail interface
  • ClamAV and SpamAssassin for security
  • Redis for caching
  • MySQL for database management
  • And more supporting services for logging, monitoring, and backups
Mailcow Docker Containers

Key Components and Configuration

The Mailcow stack leverages Docker Compose for orchestration, ensuring all containers work seamlessly together. Key configurations included:

  • Mail Transfer Agent (MTA): Postfix configured for secure SMTP with TLS encryption
  • Mail Delivery Agent (MDA): Dovecot for reliable mail storage and retrieval
  • Web Interface: Roundcube for user-friendly webmail access
  • Security Layer: Integrated antivirus and antispam solutions
  • Database: MySQL for storing user data, domains, and configurations
  • Reverse Proxy: Nginx for handling HTTPS and load balancing

Persistent volumes were set up for data storage, ensuring mail data remains intact across container updates and restarts.

Mailcow Configuration Dashboard

Security and Compliance

Security was paramount in this deployment:

  • Full TLS/SSL encryption for all mail protocols
  • DKIM, SPF, and DMARC for email authentication
  • Regular updates and vulnerability scanning
  • Firewall rules and access controls

The setup complies with modern email security standards, protecting against common threats like phishing and malware.

Mailcow Security Features

Benefits and Outcomes

  • Complete data sovereignty and privacy control
  • Cost-effective alternative to paid email services
  • Scalable architecture supporting multiple domains and users
  • Integrated tools for administration and monitoring
  • Reliable uptime with Docker's containerization benefits

Conclusion

This Mailcow deployment showcases the power of containerized solutions for building enterprise-grade email infrastructure. By running on 18 specialized containers, the system achieves high modularity, ease of maintenance, and robust performance—providing a self-hosted email solution that rivals commercial offerings.

Back to Projects