Mailu Email Server
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:alpine4 volumes: 5 - redis:/data6 networks: 7 - mailu-net8 restart: unless-stopped910 front: 11 image: ghcr.io/mailu/nginx:latest12 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:/certs22 - overrides:/overrides:ro23 environment: 24 LOG_LEVEL: INFO25 TZ: ${TZ}26 networks: 27 - mailu-net28 restart: unless-stopped2930 admin: 31 image: ghcr.io/mailu/admin:latest32 volumes: 33 - data:/data34 - dkim:/dkim35 environment: 36 SECRET_KEY: ${SECRET_KEY}37 DOMAIN: ${DOMAIN}38 HOSTNAMES: ${HOSTNAMES}39 POSTMASTER: ${POSTMASTER}40 depends_on: 41 - redis42 networks: 43 - mailu-net44 restart: unless-stopped4546 imap: 47 image: ghcr.io/mailu/dovecot:latest48 volumes: 49 - mail:/mail50 - overrides:/overrides:ro51 depends_on: 52 - front53 networks: 54 - mailu-net55 restart: unless-stopped5657 smtp: 58 image: ghcr.io/mailu/postfix:latest59 volumes: 60 - mailqueue:/queue61 - overrides:/overrides:ro62 depends_on: 63 - front64 networks: 65 - mailu-net66 restart: unless-stopped6768 antispam: 69 image: ghcr.io/mailu/rspamd:latest70 volumes: 71 - filter:/var/lib/rspamd72 - overrides:/overrides:ro73 depends_on: 74 - front75 networks: 76 - mailu-net77 restart: unless-stopped7879 antivirus: 80 image: ghcr.io/mailu/clamav:latest81 volumes: 82 - filter:/data83 networks: 84 - mailu-net85 restart: unless-stopped8687 webmail: 88 image: ghcr.io/mailu/roundcube:latest89 volumes: 90 - webmail:/data91 - overrides:/overrides:ro92 depends_on: 93 - imap94 networks: 95 - mailu-net96 restart: unless-stopped9798volumes: 99 redis: 100 data: 101 dkim: 102 mail: 103 mailqueue: 104 filter: 105 certs: 106 overrides: 107 webmail: 108109networks: 110 mailu-net: 111 driver: bridge.env Template
.env
1# Domain Configuration2DOMAIN=example.com3HOSTNAMES=mail.example.com4POSTMASTER=admin56# Secret Key (generate with: openssl rand -hex 32)7SECRET_KEY=your_random_secret_key_here89# Timezone10TZ=UTCUsage Notes
- 1Admin panel at https://mail.example.com/admin
- 2Webmail at https://mail.example.com/webmail
- 3Configure DNS records for SPF, DKIM, DMARC
- 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 file2cat > docker-compose.yml << 'EOF'3services:4 redis:5 image: redis:alpine6 volumes:7 - redis:/data8 networks:9 - mailu-net10 restart: unless-stopped1112 front:13 image: ghcr.io/mailu/nginx:latest14 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:/certs24 - overrides:/overrides:ro25 environment:26 LOG_LEVEL: INFO27 TZ: ${TZ}28 networks:29 - mailu-net30 restart: unless-stopped3132 admin:33 image: ghcr.io/mailu/admin:latest34 volumes:35 - data:/data36 - dkim:/dkim37 environment:38 SECRET_KEY: ${SECRET_KEY}39 DOMAIN: ${DOMAIN}40 HOSTNAMES: ${HOSTNAMES}41 POSTMASTER: ${POSTMASTER}42 depends_on:43 - redis44 networks:45 - mailu-net46 restart: unless-stopped4748 imap:49 image: ghcr.io/mailu/dovecot:latest50 volumes:51 - mail:/mail52 - overrides:/overrides:ro53 depends_on:54 - front55 networks:56 - mailu-net57 restart: unless-stopped5859 smtp:60 image: ghcr.io/mailu/postfix:latest61 volumes:62 - mailqueue:/queue63 - overrides:/overrides:ro64 depends_on:65 - front66 networks:67 - mailu-net68 restart: unless-stopped6970 antispam:71 image: ghcr.io/mailu/rspamd:latest72 volumes:73 - filter:/var/lib/rspamd74 - overrides:/overrides:ro75 depends_on:76 - front77 networks:78 - mailu-net79 restart: unless-stopped8081 antivirus:82 image: ghcr.io/mailu/clamav:latest83 volumes:84 - filter:/data85 networks:86 - mailu-net87 restart: unless-stopped8889 webmail:90 image: ghcr.io/mailu/roundcube:latest91 volumes:92 - webmail:/data93 - overrides:/overrides:ro94 depends_on:95 - imap96 networks:97 - mailu-net98 restart: unless-stopped99100volumes:101 redis:102 data:103 dkim:104 mail:105 mailqueue:106 filter:107 certs:108 overrides:109 webmail:110111networks:112 mailu-net:113 driver: bridge114EOF115116# 2. Create the .env file117cat > .env << 'EOF'118# Domain Configuration119DOMAIN=example.com120HOSTNAMES=mail.example.com121POSTMASTER=admin122123# Secret Key (generate with: openssl rand -hex 32)124SECRET_KEY=your_random_secret_key_here125126# Timezone127TZ=UTC128EOF129130# 3. Start the services131docker compose up -d132133# 4. View logs134docker compose logs -fOne-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 | bashTroubleshooting
- 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
Components
mailu-adminpostfixdovecotrspamdclamavroundcube
Tags
#email#mailu#postfix#dovecot#webmail
Category
Productivity & CollaborationAd Space
Shortcuts: C CopyF FavoriteD Download