docker.recipes

Mailu Email Server

advanced

Simple but full-featured mail server with spam filtering, antivirus, and webmail.

Overview

Mailu is a comprehensive email server solution that emerged as a modern, Docker-native alternative to traditional mail server configurations. Built on proven open-source components, Mailu wraps Postfix, Dovecot, Rspamd, ClamAV, and Roundcube into a cohesive system with centralized administration through its custom admin interface. Unlike complex manual mail server setups that require deep expertise in multiple technologies, Mailu provides a unified configuration layer that handles the intricate interactions between SMTP delivery, IMAP storage, spam filtering, and webmail access. This stack combines Postfix as the SMTP server for mail routing and delivery, Dovecot for IMAP/POP3 mailbox access, Rspamd for intelligent spam and malware detection, ClamAV for virus scanning, and Roundcube for browser-based email access. The Mailu admin component acts as the orchestrator, managing user accounts, domains, aliases, and security policies across all services while maintaining consistent configuration through a Redis backend. Each component communicates through a dedicated network, with the Nginx frontend handling SSL termination and protocol routing. This configuration suits organizations requiring full control over their email infrastructure, compliance-conscious businesses needing on-premises mail handling, and privacy-focused users wanting to escape third-party email providers. System administrators appreciate Mailu's balance of enterprise-grade features with simplified deployment, while security teams value the integrated anti-spam and antivirus protection that processes all mail through multiple filtering layers before delivery.

Key Features

  • Integrated DKIM key generation and management for email authentication and deliverability
  • Rspamd machine learning spam detection with customizable scoring rules and blacklists
  • ClamAV real-time virus scanning of all incoming and outgoing email attachments
  • Roundcube webmail interface with calendar, contacts, and mobile-responsive design
  • Postfix SMTP server with support for encryption, relay controls, and delivery receipts
  • Dovecot IMAP/POP3 server with full-text search and mailbox sharing capabilities
  • Multi-domain hosting with per-domain administrators and custom security policies
  • Rate limiting and connection throttling to prevent abuse and resource exhaustion

Common Use Cases

  • 1Small to medium businesses replacing hosted email services with on-premises infrastructure
  • 2Educational institutions requiring student and faculty email with administrative oversight
  • 3Healthcare organizations needing HIPAA-compliant email with audit trails and encryption
  • 4Privacy-conscious individuals wanting complete control over personal email data
  • 5Development teams needing reliable email delivery for application notifications and alerts
  • 6Remote organizations requiring webmail access with offline synchronization capabilities
  • 7Compliance-heavy industries needing email archiving and retention policy enforcement

Prerequisites

  • Minimum 4GB RAM and 20GB storage for base installation plus mail volume growth
  • Public static IP address with reverse DNS configured for proper mail delivery
  • Domain ownership with ability to configure MX, SPF, DKIM, and DMARC DNS records
  • SSL certificate for the mail domain (Let's Encrypt integration available)
  • Firewall configuration allowing ports 25, 80, 143, 443, 465, 587, and 993
  • Understanding of email authentication protocols and anti-spam best practices

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 redis:
3 image: redis:alpine
4 volumes:
5 - redis:/data
6 networks:
7 - mailu-net
8 restart: unless-stopped
9
10 front:
11 image: ghcr.io/mailu/nginx:latest
12 ports:
13 - "80:80"
14 - "443:443"
15 - "25:25"
16 - "465:465"
17 - "587:587"
18 - "143:143"
19 - "993:993"
20 volumes:
21 - certs:/certs
22 - overrides:/overrides:ro
23 environment:
24 LOG_LEVEL: INFO
25 TZ: ${TZ}
26 networks:
27 - mailu-net
28 restart: unless-stopped
29
30 admin:
31 image: ghcr.io/mailu/admin:latest
32 volumes:
33 - data:/data
34 - dkim:/dkim
35 environment:
36 SECRET_KEY: ${SECRET_KEY}
37 DOMAIN: ${DOMAIN}
38 HOSTNAMES: ${HOSTNAMES}
39 POSTMASTER: ${POSTMASTER}
40 depends_on:
41 - redis
42 networks:
43 - mailu-net
44 restart: unless-stopped
45
46 imap:
47 image: ghcr.io/mailu/dovecot:latest
48 volumes:
49 - mail:/mail
50 - overrides:/overrides:ro
51 depends_on:
52 - front
53 networks:
54 - mailu-net
55 restart: unless-stopped
56
57 smtp:
58 image: ghcr.io/mailu/postfix:latest
59 volumes:
60 - mailqueue:/queue
61 - overrides:/overrides:ro
62 depends_on:
63 - front
64 networks:
65 - mailu-net
66 restart: unless-stopped
67
68 antispam:
69 image: ghcr.io/mailu/rspamd:latest
70 volumes:
71 - filter:/var/lib/rspamd
72 - overrides:/overrides:ro
73 depends_on:
74 - front
75 networks:
76 - mailu-net
77 restart: unless-stopped
78
79 antivirus:
80 image: ghcr.io/mailu/clamav:latest
81 volumes:
82 - filter:/data
83 networks:
84 - mailu-net
85 restart: unless-stopped
86
87 webmail:
88 image: ghcr.io/mailu/roundcube:latest
89 volumes:
90 - webmail:/data
91 - overrides:/overrides:ro
92 depends_on:
93 - imap
94 networks:
95 - mailu-net
96 restart: unless-stopped
97
98volumes:
99 redis:
100 data:
101 dkim:
102 mail:
103 mailqueue:
104 filter:
105 certs:
106 overrides:
107 webmail:
108
109networks:
110 mailu-net:
111 driver: bridge

.env Template

.env
1# Domain Configuration
2DOMAIN=example.com
3HOSTNAMES=mail.example.com
4POSTMASTER=admin
5
6# Secret Key (generate with: openssl rand -hex 32)
7SECRET_KEY=your_random_secret_key_here
8
9# Timezone
10TZ=UTC

Usage Notes

  1. 1Admin panel at https://mail.example.com/admin
  2. 2Webmail at https://mail.example.com/webmail
  3. 3Configure DNS records for SPF, DKIM, DMARC
  4. 4First admin created via: docker compose exec admin flask mailu admin

Individual Services(8 services)

Copy individual services to mix and match with your existing compose files.

redis
redis:
  image: redis:alpine
  volumes:
    - redis:/data
  networks:
    - mailu-net
  restart: unless-stopped
front
front:
  image: ghcr.io/mailu/nginx:latest
  ports:
    - "80:80"
    - "443:443"
    - "25:25"
    - "465:465"
    - "587:587"
    - "143:143"
    - "993:993"
  volumes:
    - certs:/certs
    - overrides:/overrides:ro
  environment:
    LOG_LEVEL: INFO
    TZ: ${TZ}
  networks:
    - mailu-net
  restart: unless-stopped
admin
admin:
  image: ghcr.io/mailu/admin:latest
  volumes:
    - data:/data
    - dkim:/dkim
  environment:
    SECRET_KEY: ${SECRET_KEY}
    DOMAIN: ${DOMAIN}
    HOSTNAMES: ${HOSTNAMES}
    POSTMASTER: ${POSTMASTER}
  depends_on:
    - redis
  networks:
    - mailu-net
  restart: unless-stopped
imap
imap:
  image: ghcr.io/mailu/dovecot:latest
  volumes:
    - mail:/mail
    - overrides:/overrides:ro
  depends_on:
    - front
  networks:
    - mailu-net
  restart: unless-stopped
smtp
smtp:
  image: ghcr.io/mailu/postfix:latest
  volumes:
    - mailqueue:/queue
    - overrides:/overrides:ro
  depends_on:
    - front
  networks:
    - mailu-net
  restart: unless-stopped
antispam
antispam:
  image: ghcr.io/mailu/rspamd:latest
  volumes:
    - filter:/var/lib/rspamd
    - overrides:/overrides:ro
  depends_on:
    - front
  networks:
    - mailu-net
  restart: unless-stopped
antivirus
antivirus:
  image: ghcr.io/mailu/clamav:latest
  volumes:
    - filter:/data
  networks:
    - mailu-net
  restart: unless-stopped
webmail
webmail:
  image: ghcr.io/mailu/roundcube:latest
  volumes:
    - webmail:/data
    - overrides:/overrides:ro
  depends_on:
    - imap
  networks:
    - mailu-net
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 redis:
5 image: redis:alpine
6 volumes:
7 - redis:/data
8 networks:
9 - mailu-net
10 restart: unless-stopped
11
12 front:
13 image: ghcr.io/mailu/nginx:latest
14 ports:
15 - "80:80"
16 - "443:443"
17 - "25:25"
18 - "465:465"
19 - "587:587"
20 - "143:143"
21 - "993:993"
22 volumes:
23 - certs:/certs
24 - overrides:/overrides:ro
25 environment:
26 LOG_LEVEL: INFO
27 TZ: ${TZ}
28 networks:
29 - mailu-net
30 restart: unless-stopped
31
32 admin:
33 image: ghcr.io/mailu/admin:latest
34 volumes:
35 - data:/data
36 - dkim:/dkim
37 environment:
38 SECRET_KEY: ${SECRET_KEY}
39 DOMAIN: ${DOMAIN}
40 HOSTNAMES: ${HOSTNAMES}
41 POSTMASTER: ${POSTMASTER}
42 depends_on:
43 - redis
44 networks:
45 - mailu-net
46 restart: unless-stopped
47
48 imap:
49 image: ghcr.io/mailu/dovecot:latest
50 volumes:
51 - mail:/mail
52 - overrides:/overrides:ro
53 depends_on:
54 - front
55 networks:
56 - mailu-net
57 restart: unless-stopped
58
59 smtp:
60 image: ghcr.io/mailu/postfix:latest
61 volumes:
62 - mailqueue:/queue
63 - overrides:/overrides:ro
64 depends_on:
65 - front
66 networks:
67 - mailu-net
68 restart: unless-stopped
69
70 antispam:
71 image: ghcr.io/mailu/rspamd:latest
72 volumes:
73 - filter:/var/lib/rspamd
74 - overrides:/overrides:ro
75 depends_on:
76 - front
77 networks:
78 - mailu-net
79 restart: unless-stopped
80
81 antivirus:
82 image: ghcr.io/mailu/clamav:latest
83 volumes:
84 - filter:/data
85 networks:
86 - mailu-net
87 restart: unless-stopped
88
89 webmail:
90 image: ghcr.io/mailu/roundcube:latest
91 volumes:
92 - webmail:/data
93 - overrides:/overrides:ro
94 depends_on:
95 - imap
96 networks:
97 - mailu-net
98 restart: unless-stopped
99
100volumes:
101 redis:
102 data:
103 dkim:
104 mail:
105 mailqueue:
106 filter:
107 certs:
108 overrides:
109 webmail:
110
111networks:
112 mailu-net:
113 driver: bridge
114EOF
115
116# 2. Create the .env file
117cat > .env << 'EOF'
118# Domain Configuration
119DOMAIN=example.com
120HOSTNAMES=mail.example.com
121POSTMASTER=admin
122
123# Secret Key (generate with: openssl rand -hex 32)
124SECRET_KEY=your_random_secret_key_here
125
126# Timezone
127TZ=UTC
128EOF
129
130# 3. Start the services
131docker compose up -d
132
133# 4. View logs
134docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/mailu-email-stack/run | bash

Troubleshooting

  • Admin interface shows 'Internal Server Error': Check SECRET_KEY environment variable is set and Redis container is running
  • Emails marked as spam by recipients: Verify SPF, DKIM, and DMARC DNS records are properly configured and propagated
  • Cannot send emails to Gmail/Outlook: Ensure reverse DNS is configured and IP address is not on blacklists
  • Roundcube login fails with correct credentials: Restart dovecot container and check mail volume permissions
  • ClamAV consuming excessive memory: Increase container memory limits or disable real-time scanning for large attachments
  • Postfix queue backing up: Check disk space in mailqueue volume and verify recipient domain connectivity

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space