iRedMail: Full-Featured Mail Server
Enterprise-grade email server for homelabs. Postfix, Dovecot, and anti-spam with web admin.
Introduction
iRedMail is a powerful, open-source mail server solution that provides enterprise-level email hosting with support for multiple database backends, advanced security features, and comprehensive webmail integration. It’s designed for organizations that need flexibility, scalability, and professional-grade email infrastructure.
Why Choose iRedMail?
Multiple Backend Support: Unlike most mail servers, iRedMail supports multiple authentication backends: OpenLDAP, MySQL/MariaDB, or PostgreSQL. Choose the backend that fits your infrastructure.
Enterprise Features: Built-in support for domain delegation, mailbox quota management, mail filtering, content inspection, and comprehensive logging make iRedMail suitable for organizations of any size.
Professional Administration: iRedMail Admin Panel (iRedAdmin) provides intuitive web-based management for domains, users, aliases, and mail policies. The Pro version adds advanced features for multi-tenant environments.
Security First: Includes comprehensive security features like SPF, DKIM, DMARC, greylisting, SSL/TLS encryption, spam filtering (SpamAssassin or Rspamd), and ClamAV antivirus scanning.
Well-Documented: Extensive official documentation, active community forums, and professional support options make iRedMail accessible to both beginners and experts.
What You’ll Get
- Full Mail Stack: Postfix (SMTP), Dovecot (IMAP/POP3), webmail (SOGo or Roundcube)
- Spam/Virus Protection: SpamAssassin or Rspamd spam filtering, ClamAV antivirus
- Security Features: DKIM signing, SPF/DMARC validation, greylisting, TLS encryption
- Web Administration: iRedAdmin panel for domain and user management
- Groupware: SOGo for calendars, contacts, and ActiveSync (mobile sync)
- Database Choice: Pick OpenLDAP, MariaDB/MySQL, or PostgreSQL backend
- Monitoring Tools: Built-in logging, statistics, and monitoring capabilities
Use Cases
Corporate Email: Full-featured email infrastructure for businesses with 10-1000+ users
Multi-Tenant Hosting: Host email for multiple organizations with domain delegation
LDAP Integration: Integrate with existing Active Directory or LDAP infrastructure
High-Security Environments: Organizations requiring strict email security and compliance
ISP/Hosting Provider: Email services for shared hosting or VPS customers
iRedMail vs. Alternatives
vs. Mail-in-a-Box:
- iRedMail offers more backend choices (LDAP, MySQL, PostgreSQL)
- More complex installation but greater flexibility
- Better multi-domain and multi-tenant support
vs. Mailcow:
- iRedMail is not containerized (installed directly on system)
- Better LDAP integration and Active Directory compatibility
- Mailcow offers easier updates and isolation
Prerequisites
Hardware Requirements
Minimum Configuration:
- CPU: 2 cores
- RAM: 2GB (4GB recommended)
- Storage: 20GB free space minimum
- Network: Static public IP address
Recommended Configuration:
- CPU: 4+ cores (better spam/virus scanning performance)
- RAM: 8GB (comfortable for 50+ users with spam/virus scanning)
- Storage: 100GB+ SSD
- Network: Gigabit connection with clean IP reputation
Production Configuration:
- CPU: 8+ cores
- RAM: 16GB+ (for high-volume mail and full-text search)
- Storage: 500GB+ SSD or NVMe (fast I/O critical for mail performance)
- Network: Dedicated server with clean IP block
Storage Planning:
- System and iRedMail: 10GB
- Per-user mailbox: 2-10GB average (depends on usage)
- Spam/virus databases: 2-5GB
- Logs: 5-10GB
- Full-text search indexes: 1.5× mailbox size (if using Solr)
Software Requirements
Operating Systems (Fresh installation required):
- Ubuntu 22.04 LTS Server (recommended)
- Debian 11 or 12
- CentOS Stream 9
- Rocky Linux 9
- OpenBSD 7.3+
Important: iRedMail must be installed on a FRESH operating system installation. Do not install on existing servers with other services.
Required Information Before Installation
Domain Configuration:
- Fully qualified domain name (FQDN) for mail server:
mail.yourdomain.com - Primary email domain:
yourdomain.com - DNS control for creating MX, A, TXT records
Backend Selection: Choose one database backend:
- OpenLDAP: Best for LDAP/Active Directory integration, complex organizational structures
- MariaDB/MySQL: Popular choice, good balance of features and simplicity
- PostgreSQL: Best performance and reliability, preferred for large deployments
Webmail Choice:
- SOGo: Modern groupware with calendars, contacts, ActiveSync (recommended)
- Roundcube: Simpler webmail interface, lighter resource usage
IP Requirements:
- Clean IP address (not on spam blacklists)
- Reverse DNS (PTR) record capability
- Open ports: 25, 80, 110, 143, 443, 465, 587, 993, 995
Pre-Installation Checks
# Check OS version
cat /etc/os-release
# Verify hostname is FQDN
hostname -f
# Should return: mail.yourdomain.com
# Check available RAM
free -h
# Should show at least 2GB
# Check available disk space
df -h
# Should show at least 20GB free
# Verify server has public IP
curl -4 ifconfig.co
# Note this IP for DNS configuration
# Check if ports are available (should return empty)
sudo ss -tlnp | grep -E ':25|:80|:110|:143|:443|:465|:587|:993|:995' All checks must pass before proceeding.
DNS Configuration
Configure DNS records before installation. iRedMail setup will verify these.
Required DNS Records
Replace yourdomain.com with your domain and YOUR-SERVER-IP with your server’s public IP.
A Record (Mail Server):
mail.yourdomain.com. 300 IN A YOUR-SERVER-IP MX Record (Mail Exchanger):
yourdomain.com. 300 IN MX 10 mail.yourdomain.com. TXT Record (SPF - Sender Policy Framework):
yourdomain.com. 300 IN TXT "v=spf1 mx ~all" TXT Record (DMARC - Domain Message Authentication):
_dmarc.yourdomain.com. 300 IN TXT "v=DMARC1; p=quarantine; rua=mailto:[email protected]" Reverse DNS (PTR Record): Contact hosting provider to configure:
PTR record for YOUR-SERVER-IP → mail.yourdomain.com Post-Installation DNS (DKIM)
DKIM public key is generated during installation. After setup, retrieve and publish:
DKIM TXT Record (location provided after installation):
dkim._domainkey.yourdomain.com. 300 IN TXT "v=DKIM1; k=rsa; p=YOUR-PUBLIC-KEY-HERE" The installer will show the DKIM public key location and content.
DNS Verification
# Verify A record
dig mail.yourdomain.com +short
# Should return: YOUR-SERVER-IP
# Verify MX record
dig yourdomain.com MX +short
# Should return: 10 mail.yourdomain.com.
# Verify SPF record
dig yourdomain.com TXT +short | grep spf
# Should return: "v=spf1 mx ~all"
# Verify reverse DNS
dig -x YOUR-SERVER-IP +short
# Should return: mail.yourdomain.com. Installation
Step 1: Prepare the System
Update System and Set Hostname:
# Update package lists and upgrade
sudo apt update && sudo apt upgrade -y
# Set hostname to mail server FQDN
sudo hostnamectl set-hostname mail.yourdomain.com
# Verify hostname
hostname -f
# Should output: mail.yourdomain.com
# Update /etc/hosts
echo "YOUR-SERVER-IP mail.yourdomain.com mail" | sudo tee -a /etc/hosts
# Reboot to apply hostname changes
sudo reboot After reboot, verify hostname again:
hostname -f
# Must show: mail.yourdomain.com Step 2: Download iRedMail
# Download latest iRedMail
cd /tmp
wget https://github.com/iredmail/iRedMail/archive/refs/tags/1.6.8.tar.gz
# Extract archive
tar xzf 1.6.8.tar.gz
cd iRedMail-1.6.8/
# Check for newer version at: https://github.com/iredmail/iRedMail/releases Step 3: Run Installation Script
# Start interactive installer
sudo bash iRedMail.sh The installer presents a text-based interface with several configuration screens.
Step 4: Installation Wizard
Welcome Screen: Press Enter to continue.
Mail Storage Path:
- Default:
/var/vmail - Press Enter to accept (or specify custom path)
Web Server:
- Select
Nginx(recommended) orApache - Use arrow keys and Space to select, Enter to continue
Backend for Storing Accounts:
Choose one of three backends:
OpenLDAP:
- Best for: LDAP/AD integration, organizational hierarchies
- Complexity: Medium-High
- Recommended for: Enterprises with existing LDAP
MySQL/MariaDB:
- Best for: Most common use cases
- Complexity: Low-Medium
- Recommended for: Small to medium deployments
PostgreSQL:
- Best for: Large deployments, best performance
- Complexity: Low-Medium
- Recommended for: Production environments
For this guide, we’ll select MariaDB (most popular choice).
MySQL Root Password: Enter strong password for MySQL root user.
First Mail Domain: Enter your primary domain: yourdomain.com
Domain Administrator Password:
- Username will be:
[email protected] - Enter strong password for admin account
Optional Components:
Select components to install (use Space to toggle, Enter to continue):
- Roundcube: Webmail (recommended)
- SOGo: Groupware with calendars/contacts (recommended if you need groupware)
- netdata: System monitoring (optional)
- iRedAdmin: Web admin panel (strongly recommended)
- Fail2ban: Intrusion prevention (strongly recommended)
Recommended selection: Enable all except netdata (unless you want monitoring).
Review Configuration: Review summary screen, press Y to continue.
Installation Process: Installer downloads packages and configures services. This takes 10-30 minutes depending on server speed.
Step 5: Post-Installation Steps
After installation completes, the installer displays:
Important Information Screen:
- Mail domain:
yourdomain.com - Admin user:
[email protected] - Admin password: (what you entered)
- Web access URLs
- DKIM public key location
Copy this information to a secure location!
DKIM Public Key Location:
/var/lib/dkim/yourdomain.com.txt View DKIM public key:
sudo cat /var/lib/dkim/yourdomain.com.txt Copy the key and create DNS TXT record (see DNS Configuration section).
Firewall Configuration: iRedMail configures firewall automatically.
Verify firewall rules:
sudo iptables -L -n
# Or for systems using firewalld:
sudo firewall-cmd --list-all Reboot Server:
sudo reboot Step 6: Access Web Interface
After reboot, access web interfaces:
iRedAdmin (Administration Panel):
https://mail.yourdomain.com/iredadmin Webmail (Roundcube):
https://mail.yourdomain.com/mail SOGo Groupware (if installed):
https://mail.yourdomain.com/SOGo Login Credentials:
- Username:
[email protected] - Password: (password you set during installation)
Step 7: SSL Certificate Configuration
iRedMail uses self-signed SSL certificates by default. Replace with Let’s Encrypt certificates:
Install Certbot:
# Ubuntu/Debian
sudo apt install certbot python3-certbot-nginx -y Obtain SSL Certificate:
# Stop nginx temporarily
sudo systemctl stop nginx
# Obtain certificate
sudo certbot certonly --standalone -d mail.yourdomain.com
# Restart nginx
sudo systemctl start nginx Configure iRedMail to Use Let’s Encrypt Certificate:
# Edit Postfix configuration
sudo nano /etc/postfix/main.cf Update certificate paths:
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.yourdomain.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.yourdomain.com/privkey.pem # Edit Dovecot configuration
sudo nano /etc/dovecot/dovecot.conf Update certificate paths:
ssl_cert = </etc/letsencrypt/live/mail.yourdomain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.yourdomain.com/privkey.pem # Edit Nginx configuration
sudo nano /etc/nginx/templates/ssl.tmpl Update certificate paths:
ssl_certificate /etc/letsencrypt/live/mail.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mail.yourdomain.com/privkey.pem; Restart Services:
sudo systemctl restart postfix dovecot nginx Auto-Renewal:
# Test renewal
sudo certbot renew --dry-run
# Certbot automatically configures renewal cron job
# Verify:
sudo systemctl status certbot.timer Create Renewal Hook to restart services after renewal:
sudo nano /etc/letsencrypt/renewal-hooks/deploy/iredmail-restart.sh Add content:
#!/bin/bash
systemctl restart postfix dovecot nginx Make executable:
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/iredmail-restart.sh Configuration
Add Email Domains
Add additional domains to host email for multiple organizations:
Via iRedAdmin Web Interface:
- Log into
https://mail.yourdomain.com/iredadmin - Navigate to Domains > Add
- Enter domain details:
- Domain name:
newdomain.com - Description: Company or organization name
- Default quota per user: 2048 MB (or desired quota)
- Max number of users: 100 (or desired limit)
- Domain name:
- Click Add
Via Command Line (for MariaDB backend):
# Connect to MySQL
sudo mysql
# Add domain
USE vmail;
INSERT INTO domain (domain, description, maxquota, transport)
VALUES ('newdomain.com', 'New Domain Inc', 2048, 'dovecot');
# Exit MySQL
EXIT; Configure DNS: Add MX, SPF, DKIM, DMARC records for new domain.
Create Mailboxes
Via iRedAdmin Web Interface:
- Navigate to Users > Add User
- Select domain from dropdown
- Enter user details:
- Email:
[email protected] - Password: Generate strong password
- Display name: John Doe
- Quota: 2048 MB (or custom)
- Employee ID: Optional
- Email:
- Click Add
Via Command Line (for MariaDB backend):
# Generate password hash
doveadm pw -s SSHA512 -p 'password'
# Copy the generated hash
# Connect to MySQL
sudo mysql vmail
# Add mailbox
INSERT INTO mailbox (username, password, name, storagebasedirectory,
storagenode, maildir, quota, domain)
VALUES ('[email protected]', 'HASHED-PASSWORD', 'John Doe',
'/var/vmail', 'vmail1', 'yourdomain.com/user/', 2048, 'yourdomain.com');
EXIT; Create Email Aliases
Via iRedAdmin:
- Navigate to Aliases > Add Alias
- Enter alias details:
- Email:
[email protected] - Destination:
[email protected] - Or multiple destinations (comma-separated)
- Email:
- Click Add
Common Alias Examples:
[email protected]→[email protected][email protected]→[email protected][email protected]→[email protected],[email protected]
Catch-All Alias: Forward all unmatched emails to one mailbox:
- Alias:
@yourdomain.com - Destination:
[email protected]
Configure Spam Filter
iRedMail uses SpamAssassin or Rspamd (depending on installation choice).
SpamAssassin Configuration:
# Edit SpamAssassin local rules
sudo nano /etc/spamassassin/local.cf Adjust settings:
# Spam threshold (lower = stricter, default 5.0)
required_score 5.0
# Whitelist trusted senders
whitelist_from *@trusted-domain.com
whitelist_from [email protected]
# Blacklist known spammers
blacklist_from *@spam-domain.com
# Enable Bayes learning (improves accuracy over time)
use_bayes 1
bayes_auto_learn 1 Restart SpamAssassin:
sudo systemctl restart amavis Rspamd Configuration (if using Rspamd):
# Edit local configuration
sudo nano /etc/rspamd/local.d/actions.conf Adjust thresholds:
actions {
reject = 15; # Reject emails with score >= 15
add_header = 6; # Add spam header if score >= 6
greylist = 4; # Greylist if score >= 4
} Restart Rspamd:
sudo systemctl restart rspamd Configure Mail Quotas
Set Default Quota for Domain:
- Navigate to Domains in iRedAdmin
- Click domain name
- Click Edit
- Set Default quota per user: 2048 MB
- Click Update
Set Individual User Quota:
- Navigate to Users
- Click username
- Click Edit
- Set Mailbox quota: 5120 MB (or desired quota)
- Click Update
Unlimited Quota: Set quota to 0 for unlimited storage.
View Quota Usage:
# Check user quota usage
sudo doveadm quota get -u [email protected] Configure Greylisting
Greylisting temporarily rejects email from unknown senders, reducing spam.
For Greylisting with Postgrey (if installed):
# Edit Postgrey settings
sudo nano /etc/default/postgrey Modify delay:
POSTGREY_OPTS="--delay=300 --max-age=35"
# Delay: 300 seconds (5 minutes)
# Max age: 35 days Restart Postgrey:
sudo systemctl restart postgrey Whitelist Domains (bypass greylisting):
sudo nano /etc/postgrey/whitelist_clients.local Add domains:
gmail.com
outlook.com
yahoo.com
trusted-domain.com DKIM, SPF, and DMARC Verification
Verify DKIM Signing:
# Check DKIM keys
sudo amavisd-new showkeys
# Or view directly
sudo cat /var/lib/dkim/yourdomain.com.txt Test DKIM Record:
dig dkim._domainkey.yourdomain.com TXT +short
# Should return DKIM public key Test Email Authentication: Send test email to mail-tester.com and verify SPF, DKIM, DMARC all pass.
Email Client Configuration
Automatic Configuration
iRedMail supports autodiscover/autoconfig protocols.
Configure Autodiscover DNS (optional but recommended):
# CNAME records
autodiscover.yourdomain.com. 300 IN CNAME mail.yourdomain.com.
autoconfig.yourdomain.com. 300 IN CNAME mail.yourdomain.com. Email clients will automatically detect settings when entering email and password.
Manual Configuration
IMAP (Recommended for Receiving):
- Server:
mail.yourdomain.com - Port:
993 - Security: SSL/TLS
- Username: Full email address (
[email protected]) - Password: Mailbox password
POP3 (Alternative):
- Server:
mail.yourdomain.com - Port:
995 - Security: SSL/TLS
- Username: Full email address
- Password: Mailbox password
SMTP (Sending):
- Server:
mail.yourdomain.com - Port:
587(recommended) or465 - Security: STARTTLS (port 587) or SSL/TLS (port 465)
- Authentication: Required
- Username: Full email address
- Password: Mailbox password
Webmail Access
Roundcube Webmail:
https://mail.yourdomain.com/mail SOGo Groupware (if installed):
https://mail.yourdomain.com/SOGo SOGo provides:
- Webmail interface
- Calendar with event management
- Contacts with CardDAV
- ActiveSync for mobile devices
- Task management
Mobile Device Setup
iOS (iPhone/iPad):
- Settings > Mail > Accounts > Add Account
- Select “Other”
- Enter email and password
- iOS auto-configures if autodiscover is set up
Android:
- Open mail app
- Add account > Other
- Enter email and password
- Android auto-configures if autoconfig is set up
ActiveSync (for SOGo):
- Server:
mail.yourdomain.com - Domain: Leave blank
- Username: Full email address
- Password: Mailbox password
- Use SSL: Yes
Security Hardening
Firewall Configuration
iRedMail configures firewall during installation. Verify configuration:
UFW (Ubuntu/Debian):
sudo ufw status verbose Ensure these ports are open:
- 22/tcp (SSH)
- 25/tcp (SMTP)
- 80/tcp (HTTP)
- 110/tcp (POP3)
- 143/tcp (IMAP)
- 443/tcp (HTTPS)
- 465/tcp (SMTPS)
- 587/tcp (Submission)
- 993/tcp (IMAPS)
- 995/tcp (POP3S)
Block Unnecessary Ports: All other ports should be denied.
Fail2Ban Configuration
iRedMail includes Fail2Ban for brute-force protection.
Check Banned IPs:
# View all jails
sudo fail2ban-client status
# View specific jail
sudo fail2ban-client status postfix-pregreet
sudo fail2ban-client status dovecot Unban IP:
sudo fail2ban-client set postfix-pregreet unbanip IP-ADDRESS
sudo fail2ban-client set dovecot unbanip IP-ADDRESS Whitelist Trusted IPs:
sudo nano /etc/fail2ban/jail.local Add to [DEFAULT] section:
[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 YOUR-HOME-IP YOUR-OFFICE-IP Restart Fail2Ban:
sudo systemctl restart fail2ban TLS/SSL Configuration
Enforce Strong TLS:
# Edit Postfix TLS settings
sudo nano /etc/postfix/main.cf Ensure these settings:
# TLS protocols
smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
# Strong ciphers only
smtpd_tls_ciphers = high
smtpd_tls_mandatory_ciphers = high Restart Postfix:
sudo systemctl restart postfix Regular Security Updates
Update iRedMail:
iRedMail doesn’t have a built-in update command. Instead, update individual components:
# Update system packages
sudo apt update && sudo apt upgrade -y
# Update spam filters
sudo sa-update # SpamAssassin
sudo freshclam # ClamAV virus definitions Subscribe to Security Announcements: Join iRedMail mailing list for security updates.
Backup Configuration
Manual Backup Script:
iRedMail includes backup scripts:
# Backup all mailboxes and settings
sudo bash /var/vmail/backup/backup_mysql.sh
# Backup location
ls -lh /var/vmail/backup/mysql/ Automated Backups with Cron:
# Edit root crontab
sudo crontab -e Add daily backup at 2 AM:
0 2 * * * bash /var/vmail/backup/backup_mysql.sh Backup to Remote Location:
# Install rsync
sudo apt install rsync -y
# Create backup script
sudo nano /usr/local/bin/iredmail-remote-backup.sh Add content:
#!/bin/bash
# Run iRedMail backup
bash /var/vmail/backup/backup_mysql.sh
# Sync to remote server
rsync -avz /var/vmail/backup/ user@backup-server:/backups/iredmail/
# Or sync to S3
# s3cmd sync /var/vmail/backup/ s3://your-bucket/iredmail-backups/ Make executable and schedule:
sudo chmod +x /usr/local/bin/iredmail-remote-backup.sh
sudo crontab -e Add:
0 2 * * * /usr/local/bin/iredmail-remote-backup.sh >> /var/log/iredmail-backup.log 2>&1 Restore from Backup:
# Restore MySQL/MariaDB backup
sudo bash /var/vmail/backup/restore_mysql.sh /var/vmail/backup/mysql/BACKUP-FILE.sql.bz2 Troubleshooting
Cannot Send or Receive Email
Check Service Status:
sudo systemctl status postfix
sudo systemctl status dovecot
sudo systemctl status amavis
sudo systemctl status nginx
# Restart services if needed
sudo systemctl restart postfix dovecot amavis nginx Check Mail Logs:
# View mail log
sudo tail -f /var/log/mail.log
# Search for errors
sudo grep -i error /var/log/mail.log | tail -20
# View specific user's mail activity
sudo grep [email protected] /var/log/mail.log | tail -20 Check Mail Queue:
# View queued messages
sudo postqueue -p
# View detailed queue info
sudo postcat -q QUEUE-ID Check DNS:
dig yourdomain.com MX +short
dig mail.yourdomain.com +short
dig -x YOUR-SERVER-IP +short Emails Going to Spam
Test Email Authentication:
Send test email to mail-tester.com and check score.
Common Issues:
- Missing DKIM: Check DKIM DNS record
- SPF Fail: Verify SPF TXT record
- No Reverse DNS: Contact hosting provider
- IP Blacklisted: Check at MXToolbox
View Email Headers of delivered email to see authentication results.
High Memory Usage
Check Resource Usage:
# View memory usage
free -h
# Top memory consumers
ps aux --sort=-%mem | head -10 Common Memory Consumers:
- ClamAV (500MB-1GB)
- SpamAssassin/Rspamd (200-500MB)
- MySQL/MariaDB (200-500MB)
- SOGo (if installed, 200-400MB)
Reduce Memory Usage:
Disable ClamAV if not critical:
sudo systemctl stop clamav-daemon
sudo systemctl disable clamav-daemon
# Comment out ClamAV in Amavis
sudo nano /etc/amavis/conf.d/15-content_filter_mode
# Comment: @bypass_virus_checks_maps = (1);
sudo systemctl restart amavis Database Connection Errors
MySQL/MariaDB Connection Issues:
# Check MySQL status
sudo systemctl status mysql
# Restart MySQL
sudo systemctl restart mysql
# Check MySQL logs
sudo tail -f /var/log/mysql/error.log Reset MySQL Root Password (if lost):
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password';
FLUSH PRIVILEGES;
EXIT; SSL Certificate Issues
Certificate Not Valid:
# Check certificate expiration
sudo certbot certificates
# Force renewal
sudo certbot renew --force-renewal
# Restart services
sudo systemctl restart postfix dovecot nginx Disk Space Full
Check Disk Usage:
df -h
# Find large directories
sudo du -sh /var/* | sort -h | tail -10 Clean Up Space:
# Delete old logs
sudo find /var/log -name "*.log" -mtime +30 -delete
sudo find /var/log -name "*.gz" -mtime +30 -delete
# Clean old mail logs
sudo find /var/log -name "mail.log.*" -mtime +7 -delete
# Clean package cache
sudo apt clean
# Remove old backups (keep latest 7)
cd /var/vmail/backup/mysql/
ls -t | tail -n +8 | xargs sudo rm -f Password Reset
Reset User Password:
# Generate new password hash
doveadm pw -s SSHA512 -p 'newpassword'
# Update in database
sudo mysql vmail
UPDATE mailbox SET password='NEW-HASHED-PASSWORD' WHERE username='[email protected]';
EXIT; Or via iRedAdmin: Navigate to Users > Edit User > Change password.
Advanced Configuration
LDAP Integration
Connect to Existing Active Directory:
# Edit LDAP configuration
sudo nano /etc/postfix/ldap/ Configure LDAP parameters:
- LDAP server URI
- Base DN
- Bind DN and password
- Search filters
See iRedMail documentation for detailed LDAP integration: https://docs.iredmail.org/
Mail Forwarding and BCC
Configure Domain-Level BCC (copy all email):
sudo nano /etc/postfix/main.cf Add:
always_bcc = [email protected] Restart Postfix:
sudo systemctl restart postfix Per-User Forwarding: Users configure forwarding via webmail or iRedAdmin.
Sieve Filters
Users can create server-side email filters using Sieve:
Enable Sieve Management:
iRedMail includes ManageSieve protocol on port 4190.
Configure Filters via Webmail:
- Log into Roundcube webmail
- Navigate to Settings > Filters
- Create filter rules
Example Sieve Filter (via command line):
# Create Sieve script
sudo nano /var/vmail/sieve/yourdomain.com/user/dovecot.sieve Add filter:
require ["fileinto", "reject"];
# Move spam to Spam folder
if header :contains "X-Spam-Flag" "YES" {
fileinto "Spam";
stop;
}
# Move newsletters to folder
if header :contains "From" "[email protected]" {
fileinto "Newsletters";
stop;
} Compile and reload:
sudo sievec /var/vmail/sieve/yourdomain.com/user/dovecot.sieve
sudo doveadm reload API Access
iRedAdmin Pro API (requires Pro license):
iRedAdmin Pro includes RESTful API for automation.
Example API Calls:
# Add mailbox via API
curl -X POST https://mail.yourdomain.com/iredadmin/api/user -u "[email protected]:password" -d "domain=yourdomain.com" -d "username=newuser" -d "password=SecurePass123" -d "quota=2048" See iRedAdmin Pro documentation for full API reference.
Multi-Tenant Setup
Domain Delegation: Allow domain admins to manage their own domains:
- Navigate to iRedAdmin > Admins > Add Admin
- Create domain admin account:
- Email:
[email protected] - Managed domains:
clientdomain.com - Privileges: Domain admin (not global admin)
- Email:
- Domain admin can now manage users/aliases for their domain only
Monitoring and Maintenance
View Logs
Mail Logs:
# Real-time mail log
sudo tail -f /var/log/mail.log
# Search for specific user
sudo grep [email protected] /var/log/mail.log | tail -20
# Search for errors
sudo grep -i error /var/log/mail.log | tail -20 Service Logs:
# Postfix
sudo tail -f /var/log/mail.log | grep postfix
# Dovecot
sudo tail -f /var/log/mail.log | grep dovecot
# Amavis (spam/virus filtering)
sudo tail -f /var/log/mail.log | grep amavis Mail Queue Management
View Queue:
sudo postqueue -p Flush Queue (attempt immediate delivery):
sudo postqueue -f Delete Specific Message:
# Get message ID from postqueue -p
sudo postsuper -d MESSAGE-ID Delete All Queued Mail:
sudo postsuper -d ALL Performance Monitoring
Check Resource Usage:
# CPU and memory
htop
# Disk I/O
iostat -x 1
# Network connections
sudo ss -tunap | grep -E ':25|:587|:993' Database Performance:
# MySQL slow queries
sudo tail -f /var/log/mysql/mysql-slow.log
# Optimize database tables
sudo mysqlcheck -u root -p --optimize --all-databases Statistics
Mail Statistics (if using iRedAPD):
# View top senders
sudo grep 'from=' /var/log/mail.log | awk '{print $7}' | sort | uniq -c | sort -rn | head -20
# View top recipients
sudo grep 'to=' /var/log/mail.log | awk '{print $7}' | sort | uniq -c | sort -rn | head -20
# Count sent messages today
sudo grep "$(date +%b %d)" /var/log/mail.log | grep 'status=sent' | wc -l
# Count received messages today
sudo grep "$(date +%b %d)" /var/log/mail.log | grep 'to=' | wc -l Next Steps
Recommended Enhancements
- Set Up Monitoring: Integrate with Grafana or similar for performance monitoring
- Configure Advanced Spam Rules: Train SpamAssassin or Rspamd with user feedback
- Implement Mail Archiving: Set up long-term email archival for compliance
- Add Secondary MX: Configure backup mail server for redundancy
- Automate Backups: Schedule encrypted backups to remote location
Related Guides
- Mailcow Email Server: Containerized alternative
- Mail-in-a-Box: Simpler email solution
- Backups with Restic: Advanced backup strategies
- Grafana Monitoring: Server monitoring and alerting
Conclusion
You now have a fully functional iRedMail server with:
- Complete email infrastructure (SMTP, IMAP, POP3)
- Webmail and groupware (Roundcube/SOGo)
- Spam filtering and virus scanning
- DKIM, SPF, and DMARC authentication
- Web-based administration
- Backup automation
- Security hardening
Key Success Metrics:
- Email deliverability to major providers without spam classification
- All DNS records properly configured
- SSL/TLS certificates valid and auto-renewing
- Spam filter catching 90%+ of spam
- Automated backups completing successfully
- Users able to send/receive on all devices
iRedMail provides enterprise-grade email hosting with flexibility for various deployment scenarios. With proper configuration and maintenance, your mail server will provide reliable email service for years.
Community Resources:
Welcome to professional-grade self-hosted email!