Mailu is a lightweight, secure, and easy-to-configure mail server based on Docker. It provides a full-featured mail solution with support for SMTP, IMAP, POP3, and webmail. This guide covers the complete setup of Mailu on a Linux server, including installation, configuration, and security.
Prerequisites
Ensure you have the following before starting:
- A Linux server (Ubuntu 20.04/22.04 or CentOS 8 recommended)
- Docker and Docker Compose installed
- A registered domain (e.g.,
yourdomain.com
) - Root or sudo access
Step 1: Prepare Your System
1. Update System Packages
Ensure your system is updated:
sudo apt update && sudo apt upgrade -y # For Ubuntu sudo yum update -y # For CentOS
2. Set the Hostname
sudo hostnamectl set-hostname mail.yourdomain.com
Add the hostname to /etc/hosts
:
sudo nano /etc/hosts
Add this line:
127.0.0.1 mail.yourdomain.com mail localhost
Step 2: Install Docker and Docker Compose
1. Install Docker (Ubuntu):
sudo apt install docker.io -y
2. Install Docker Compose:
sudo apt install docker-compose -y
3. Enable Docker to Start on Boot:
sudo systemctl enable docker sudo systemctl start docker
Step 3: Download and Configure Mailu
1. Create Mailu Directory:
mkdir /mailu && cd /mailu
2. Generate Mailu Configuration Files:
Use the Mailu configuration tool: https://setup.mailu.io/1.9/
Download the generated docker-compose.yml
and .env
files to the /mailu
directory.
Or manually create them:
wget https://setup.mailu.io/1.9/docker-compose.yml wget https://setup.mailu.io/1.9/mailu.env -O .env
Step 4: Customize the Mailu Configuration
- Edit the
.env
file:
sudo nano .env
Ensure the following variables are set correctly:
DOMAIN=yourdomain.com HOSTNAME=mail TLS_FLAVOR=letsencrypt ADMIN=admin@yourdomain.com PASSWORD=yourpassword
- Save and exit the file.
Step 5: Start Mailu Services
Navigate to the /mailu
directory and start Mailu using Docker Compose:
cd /mailu sudo docker-compose up -d
Check if Mailu containers are running:
sudo docker ps
Step 6: Set Up DNS Records
Ensure the following DNS records are added to your domain registrar:
Record Type | Name | Value |
---|---|---|
A | mail.yourdomain.com | Your server’s IP address |
MX | yourdomain.com | mail.yourdomain.com (Priority 10) |
TXT | yourdomain.com | v=spf1 mx ~all |
TXT | _dmarc.yourdomain.com | v=DMARC1; p=none |
TXT | default._domainkey.yourdomain.com | (DKIM Key) |
Step 7: Access Mailu Admin Interface
Open your browser and visit:
https://mail.yourdomain.com/admin
Login with:
- Username: admin@yourdomain.com
- Password: (as set in
.env
file)
Step 8: Add Email Users
- Go to “Users” in the Mailu admin panel.
- Create new email accounts.
Example command to create a user manually:
sudo docker-compose exec admin flask mailu admin admin@yourdomain.com yourpassword
Step 9: Secure Mailu with Fail2Ban
- Install Fail2Ban (Ubuntu):
sudo apt install fail2ban -y
- Enable Fail2Ban to start on boot:
sudo systemctl enable fail2ban sudo systemctl start fail2ban
Step 10: Monitor Mailu Services
- Check Docker Logs:
sudo docker-compose logs -f
- Restart Mailu Services:
sudo docker-compose restart
Step 11: Backup and Restore Mailu
- Create a Backup:
sudo docker-compose stop sudo tar -czvf mailu-backup.tar.gz /mailu sudo docker-compose start
- Restore from Backup:
sudo docker-compose stop sudo tar -xzvf mailu-backup.tar.gz -C / sudo docker-compose start
Recommended Services for Mailu
- ClamAV – Virus protection
- SpamAssassin – Spam filtering
- Fail2Ban – Protection against brute-force attacks
- Postgrey – Greylisting for improved spam control
Final Thoughts
You have successfully set up and secured a Mailu mail server on your Linux system. Regular maintenance and monitoring will ensure optimal performance and security.
Keywords: Mailu mail server setup, configure Mailu Docker, install Mailu on Ubuntu, secure Mailu email server, Docker mail server tutorial
Related Searches:
- How to install Mailu mail server
- Mailu email server Docker setup
- Mailu vs Postfix vs Exim
- Securing Mailu with SSL
- Adding users to Mailu mail server
Tags:
- Mailu Mail Server
- Docker Mail Server
- Email Server Setup
- Secure Mail Server
- Mailu Installation Guide