Setting up your own mail server can seem overwhelming, but with Modoboa and Ubuntu 22.04, it’s easier than you might think. Modoboa is an open-source mail hosting and management platform that integrates seamlessly with Postfix and Dovecot, offering a web-based interface to manage domains, mailboxes, and more. In this complete guide, we’ll walk you through every step to set up a Modoboa mail server on Ubuntu 22.04, optimized for SEO with keywords like Modoboa mail server, Ubuntu 22.04 setup, and email hosting. Whether you’re an individual or a business, this guide will help you create a secure, reliable mail server.
What is Modoboa?
Modoboa is a free, open-source mail server solution built in Python. It simplifies email hosting by providing:
- A web-based admin panel for managing domains, mailboxes, and aliases.
- Unlimited mailboxes and domains.
- Built-in spam and virus protection (via Amavis, SpamAssassin, and ClamAV).
- Support for Let’s Encrypt SSL certificates.
- DKIM and DMARC for email reputation.
- Calendar and address book integration.
It’s an ideal choice for anyone seeking a customizable, self-hosted email solution on Ubuntu 22.04, a Long Term Support (LTS) release known for its stability.
Why Choose Modoboa on Ubuntu 22.04?
Ubuntu 22.04 (Jammy Jellyfish) offers five years of updates and security patches, making it perfect for long-term server projects like email hosting. Modoboa’s automated installer and compatibility with Ubuntu 22.04 ensure a smooth setup, even for users new to Linux or mail servers.
Prerequisites for Modoboa Setup
Before starting, ensure you have:
- A VPS or dedicated server with a fresh Ubuntu 22.04 installation (minimum 3GB RAM recommended).
- A registered domain name (e.g., example.com).
- Root access to the server.
- Basic Linux command-line knowledge.
- Port 25 open for SMTP (check with your VPS provider, as some block it by default).
Step-by-Step Guide to Install Modoboa on Ubuntu 22.04
List of VPS Hosting Providers Offering Open Port 25
- Vps Provider With Port 25 Open
- rarecloud
- Contabo.
- dartnode
- Ultahost
- Servebyte.
- OVH.
- Alexhost
- Knownhost
- Racknerd
- Turnkey internet.
- Vpsbg
- Hostwinds
Step 1: Prepare Your Ubuntu Server
Proper server setup ensures a smooth installation. Follow these steps:
- Update Packages: Open a terminal and update your system:
sudo apt update
sudo apt upgrade -y
- Set the Hostname: Use a fully qualified domain name (FQDN) like mail.example.com:
sudo hostnamectl set-hostname mail.example.com
- Install Dependencies: Modoboa requires Python and other tools:
sudo apt install python3-virtualenv python3-pip git curl gnupg2 -y
Step 2: Configure DNS Records
Correct DNS settings are critical for email deliverability. Set up these records for your domain:
- A Record: mail.example.com A your_server_ip
- MX Record: example.com MX 10 mail.example.com
- PTR Record (Reverse DNS): Maps your IP back to mail.example.com (set by your VPS provider).
These ensure emails are routed correctly and avoid spam filters.
Step 3: Install Modoboa
Modoboa’s installer automates most of the setup process. Here’s how:
- Clone the Installer:
git clone https://github.com/modoboa/modoboa-installer
cd modoboa-installer
- Generate Configuration: Run the installer in check mode to create a config file:
sudo ./run.py --stop-after-configfile-check example.com
Replace example.com with your domain.
Edit the Configuration File: Open installer.cfg
sudo nano installer.cfg
[certificate]
generate = true
type = letsencrypt
[letsencrypt]
email = [email protected]
[database]
engine = mysql
host = 127.0.0.1
install = true
Run the Installer: Start the installation:
sudo ./run.py example.com
Confirm when prompted. The process takes a few minutes and installs Postfix, Dovecot, and other components.
Post-Installation: You’ll get an admin URL (e.g., https://mail.example.com) and default credentials (admin/password). Change the password after logging in.
Step 4: Configure Domains and Mailboxes
- Access the Admin Panel: Visit https://mail.example.com and log in.
- Change the Admin Password: Go to Admin > Settings > Profile and update it.
- Add a Domain:
- Navigate to Domains > Add.
- Enter example.com.
- Enable DKIM signing (selector: modoboa, 2048-bit key).
- Create Mailboxes:
- Under your domain, go to Mailboxes > Add > Account.
- Select Simple user, then set the email and password (e.g., [email protected]).
- Set Up Aliases (Optional):
- In Domains, select your domain, then Aliases > Add.
- Create aliases like [email protected].
Step 5: Test Your Mail Server
- Send a Test Email: Log in to the webmail at https://mail.example.com and send an email to an external address.
- Check Inbound Email: Send an email from an external account to your new mailbox. Delays may occur due to greylisting (see troubleshooting).
- Verify DKIM and SPF: Use Mail Tester to check your email’s spam score and DNS settings.
Step 6: Troubleshoot Common Issues
- Emails Not Delivered:
- Verify DNS records (MX, SPF, DKIM).
- Ensure port 25 is unblocked.
- Login Fails in Email Clients:
- Double-check credentials.
- Review Dovecot logs (sudo journalctl -u dovecot).
- Greylisting Delays:
- Disable greylisting in /etc/postfix/main.cf:
sudo nano /etc/postfix/main.cf
# Recipient restriction rules
smtpd_recipient_restrictions =
# check_policy_service inet:127.0.0.1:9999
- Comment out postscreen lines, then restart:
sudo systemctl restart postfix
Conclusion
Congratulations! You’ve successfully set up a Modoboa mail server on Ubuntu 22.04. This guide covered preparation, installation, configuration, and testing, giving you a secure, self-hosted email solution. Keep your server updated and monitor deliverability to maintain performance. For advanced features, check the Modoboa documentation.
With this Ubuntu 22.04 Modoboa setup guide, you’re now in control of your email hosting—perfect for personal use or small businesses!