This guide covers how to set up and configure maddy on a Linux VPS. Whether you're running a production environment or a development setup, these instructions will help you get started quickly and securely.
Prerequisites
- Valid PTR (reverse DNS) record configured
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
- A clean IP address not on any blacklists
- A registered domain name (for public-facing services)
Server Installation
The maddy configuration requires careful attention to resource limits and security settings. On a VPS with limited resources, it's important to tune these parameters according to your available RAM and CPU cores.
# Install Postfix and Dovecot
sudo apt update
sudo apt install -y postfix dovecot-core dovecot-imapd dovecot-lmtpd
# Configure Postfix main.cf
sudo postconf -e 'myhostname = mail.example.com'
sudo postconf -e 'mydomain = example.com'
sudo postconf -e 'smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem'
sudo postconf -e 'smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem'
These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.
Authentication Setup (SPF/DKIM)
Regular maintenance is essential for keeping your maddy installation running smoothly. Schedule periodic reviews of log files, disk usage, and security updates to prevent issues before they occur.
# Generate DKIM key
sudo apt install -y opendkim opendkim-tools
sudo mkdir -p /etc/opendkim/keys/example.com
sudo opendkim-genkey -b 2048 -d example.com -D /etc/opendkim/keys/example.com -s default -v
# Add the DNS TXT record from:
cat /etc/opendkim/keys/example.com/default.txt
Note that file paths may vary depending on your Linux distribution. The examples here are for Debian/Ubuntu; adjust paths accordingly for RHEL/CentOS-based systems.
Performance Considerations
If you encounter issues during setup, check the system logs first. Most problems can be diagnosed by examining the output of journalctl or the application-specific log files in /var/log/.
Client Configuration
Performance benchmarks show that properly tuned maddy can handle significantly more concurrent connections than the default configuration. The key improvements come from adjusting worker processes and connection pooling.
# Install Postfix and Dovecot
sudo apt update
sudo apt install -y postfix dovecot-core dovecot-imapd dovecot-lmtpd
# Configure Postfix main.cf
sudo postconf -e 'myhostname = mail.example.com'
sudo postconf -e 'mydomain = example.com'
sudo postconf -e 'smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem'
sudo postconf -e 'smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem'
Note that file paths may vary depending on your Linux distribution. The examples here are for Debian/Ubuntu; adjust paths accordingly for RHEL/CentOS-based systems.
Common Issues and Solutions
- Connection timeout: Verify your firewall rules allow traffic on the required ports. Use
ss -tlnpto confirm the service is listening on the expected port. - High memory usage: Review the configuration for memory-related settings. Reduce worker counts or buffer sizes if running on a low-RAM VPS.
Wrapping Up
Following this guide, your maddy setup should be production-ready. Keep an eye on resource usage as your traffic grows and don't forget to test your backup and recovery procedures periodically.