Choosing the right Mail Transfer Agent (MTA) is one of the most critical decisions when building a self-hosted email server. The MTA handles all incoming and outgoing mail — routing, queuing, delivery, and relay — making it the backbone of your email infrastructure.
Two projects dominate the MTA landscape: Postfix and Exim. Together they power the vast majority of mail servers on the internet. Postfix is the default on Red Hat, CentOS, and many enterprise distributions. Exim is the default on Debian and Ubuntu, and powers all shared hosting servers via cPanel.
In this guide, we compare both MTAs side-by-side, provide Docker deployment configurations, and help you decide which one fits your self-hosted setup.
Why Self-Host Your Mail Transfer Agent
Running your own MTA gives you full control over email routing, filtering, and delivery policies. Instead of relying on third-party SMTP relays or hosted email services, you manage the entire mail pipeline locally.
Key benefits of self-hosting your MTA include:
- Complete control over mail routing, DKIM signing, SPF policies, and DMARC enforcement
- No per-email costs — process unlimited messages without paying per-message fees
- Privacy — mail never passes through third-party servers
- Custom filtering — integrate with Rspamd, SpamAssassin, or custom sieve rules
- Reliability — your mail queue survives network outages and retries delivery automatically
For related reading, see our complete self-hosted email server guide and lightweight SMTP server comparison.
Postfix vs Exim: Overview Comparison
| Feature | Postfix | Exim |
|---|---|---|
| First Release | 1998 (by Wietse Venema) | 1995 (by Philip Hazel) |
| Default On | RHEL, CentOS, Fedora, SUSE, macOS | Debian, Ubuntu, cPanel servers |
| Architecture | Modular, process-based | Monolithic, single-daemon |
| Configuration | Simple main.cf + master.cf | Single exim4.conf (complex) |
| Routing Flexibility | Good (transport maps, virtual maps) | Excellent (ACLs, routers, transports) |
| Performance | Excellent (designed for speed) | Very Good (handles high volume well) |
| Security Model | Least-privilege processes | Root daemon with privilege dropping |
| Learning Curve | Moderate | Steep |
| Docker Image | linuxserver/mailserver, juanluisbaptiste/postfix | devture/exim, martinrue/exim4 |
| License | IBM Public License (open source) | GPL |
| Active Development | Yes (regular security patches) | Yes (active maintainer team) |
| GitHub Stars | N/A (source on GitHub mirrors) | ~400 (mirror repos) |
Architecture: How They Differ Under the Hood
Postfix: Modular Design
Postfix uses a modular architecture with separate processes for each function. The master daemon spawns child processes for specific tasks:
smtpd— handles incoming SMTP connectionssmtp— handles outgoing SMTP deliverypickup— reads mail from the local queuecleanup— canonicalizes and rewrites message headersqmgr— manages the mail queue and delivery schedulinglocal— delivers mail to local mailboxesvirtual— delivers to virtual domains
This design means that if one component crashes, others continue running. It also enforces a least-privilege security model — each process runs with only the permissions it needs.
Exim: Monolithic Design
Exim uses a single-daemon architecture where one process handles all stages of mail processing. It uses a pipeline of routers, transports, and access control lists (ACLs) to process each message:
- ACLs — decide whether to accept, reject, or defer a message
- Routers — determine where to send the message (local, remote, alias)
- Transports — actually deliver the message (SMTP, local file, pipe)
This monolithic approach makes Exim incredibly flexible for complex routing scenarios but means a bug in any component can affect the entire daemon.
Installation and Setup
Installing Postfix on Debian/Ubuntu
| |
During installation, select “Internet Site” and enter your domain name.
Installing Exim on Debian/Ubuntu
| |
Choose “internet site; mail is sent and received directly using SMTP” and configure your domain.
Docker Deployment
Postfix with Docker Compose
Using the popular juanluisbaptiste/postfix image, you can deploy a fully functional Postfix server in minutes:
| |
For a full self-hosted mail server with Dovecot and Rspamd, use the LinuxServer.io mailserver image:
| |
Exim with Docker Compose
Exim can be deployed using the devture/exim-relay image for relay setups or built from source for full MTA functionality:
| |
For a full Exim MTA, you can build a custom Docker image:
| |
Configuration Comparison
Postfix Configuration
Postfix uses two main configuration files:
/etc/postfix/main.cf — General settings:
| |
/etc/postfix/master.cf — Service definitions:
| |
Exim Configuration
Exim uses a single configuration file with sections for ACLs, routers, and transports:
| |
Performance and Reliability
Queue Management
Both MTAs handle mail queuing well, but with different approaches:
- Postfix uses a highly optimized queue manager (
qmgr) that schedules deliveries based on destination, retry intervals, and concurrency limits. It handles millions of messages per day on commodity hardware. - Exim uses a single queue directory with files representing individual messages. Its
exim -qcommand processes the queue, and retry rules are configured in theretrysection of the config.
Concurrency
Postfix supports configurable concurrency per destination (default 20 simultaneous deliveries to the same domain). Exim can be configured for parallel deliveries but requires manual tuning of the queue_run_max and remote_max_parallel settings.
Resource Usage
| Metric | Postfix | Exim |
|---|---|---|
| Idle Memory | ~15-30 MB (master + minimal children) | ~10-20 MB (single daemon) |
| Peak Memory | Scales with active connections | Scales with message complexity |
| CPU Usage | Low (efficient process model) | Moderate (regex-heavy ACL processing) |
| Disk I/O | Optimized for queue operations | Standard file-based queue |
Security Features
Postfix Security
- Least-privilege processes — each daemon runs as a non-root user
- Chroot support — SMTP processes can be chrooted for isolation
- Built-in rate limiting —
smtpd_client_connection_rate_limit,anvilservice - Header rewriting — removes sensitive headers before forwarding
- SASL integration — supports Dovecot, Cyrus SASL for authentication
- Postscreen — blocks spam bots before they reach the SMTP daemon
Example Postscreen configuration:
| |
Exim Security
- Privilege dropping — daemon drops root privileges after binding to port 25
- ACL-based filtering — fine-grained control at each SMTP stage
- TLS support — STARTTLS on all SMTP ports
- Rate limiting —
ratelimitACL condition for per-user/per-IP throttling - SPF/DKIM/DMARC — supported via
spfanddkimACL conditions
Example Exim rate limiting:
| |
Integration Ecosystem
Postfix Integrations
Postfix integrates seamlessly with the broader self-hosted email stack:
- Dovecot — IMAP/POP3 server with LDA (Local Delivery Agent) support
- Rspamd — Modern spam filtering with Redis backend
- Amavis — Content filtering and antivirus scanning
- OpenDKIM — DKIM signing and verification
- PostfixAdmin — Web-based virtual domain management
- Mailman — Mailing list management
For spam filtering integration, see our SpamAssassin vs Rspamd comparison.
Exim Integrations
Exim has similar integration capabilities:
- Dovecot — via Dovecot SASL authentication and LDA
- Rspamd — via milter or rspamd ACL integration
- ClamAV — antivirus scanning via
clamdACL - SpamAssassin — via
spamassassinACL condition - Mailman — built-in Mailman router support
- cPanel/WHM — deeply integrated (all cPanel servers use Exim)
When to Choose Postfix
Choose Postfix if:
- You want the default, battle-tested MTA on most enterprise Linux distributions
- You prefer a modular architecture where components can fail independently
- You need excellent performance out of the box with minimal tuning
- You want a simpler configuration that is easier to audit and maintain
- You value the least-privilege security model with chroot support
- You are building a standard mail server with Dovecot + Rspamd
When to Choose Exim
Choose Exim if:
- You are on Debian/Ubuntu and want the native, well-integrated MTA
- You need complex mail routing with per-domain, per-user, or per-regex rules
- You run cPanel/WHM and need the supported MTA
- You want fine-grained ACL control at every SMTP stage
- You need advanced queue management with custom retry and bounce rules
- You prefer a single configuration file (even if complex) for all mail processing
Alternative Lightweight MTAs
If neither Postfix nor Exim fits your needs, consider these lightweight alternatives:
- Maddy — All-in-one mail server written in Go, combines MTA, IMAP, and spam filtering in a single binary
- chasquid — Modern SMTP server written in Go, designed for simplicity and security
- OpenSMTPD — Clean, simple MTA from the OpenBSD project, with an easy-to-read configuration syntax
For a detailed comparison of these lightweight options, see our lightweight SMTP server guide.
FAQ
Which is more secure: Postfix or Exim?
Both MTAs are highly secure when properly configured. Postfix has a structural advantage with its least-privilege process model — each component runs with minimal permissions. Exim relies on privilege dropping after startup. Both have strong track records, and security often depends more on the administrator’s configuration than the software itself.
Can I switch from Exim to Postfix (or vice versa)?
Yes, but it requires careful migration. Both MTAs use different configuration formats and queue structures. The mail queue must be drained or re-queued during the switch. On Debian, you can use dpkg-reconfigure exim4-config to switch the system MTA. Always test the new configuration in a staging environment first.
Do Postfix and Exim support virtual domains?
Yes, both support virtual domains. Postfix uses virtual_mailbox_domains and virtual_mailbox_maps for domain routing. Exim uses routers with local_domains and domain lists to handle multiple domains. Both can integrate with MySQL, PostgreSQL, or LDAP for virtual domain lookups.
Which MTA handles high-volume email better?
Postfix is generally considered faster for high-volume scenarios due to its modular architecture and optimized queue manager. It is the default choice for large-scale mail systems. However, Exim can also handle millions of messages per day with proper tuning — it powers all cPanel servers worldwide, many of which process very high mail volumes.
How do I add DKIM signing to Postfix or Exim?
For Postfix, use OpenDKIM or Rspamd as a milter. Install OpenDKIM, generate keys, configure smtpd_milters in main.cf, and add DNS TXT records. For Exim, use the built-in DKIM support — add dkim_domain, dkim_selector, and dkim_private_key to your configuration. Both methods sign outgoing mail automatically.
Which MTA is easier to configure for beginners?
Postfix is generally easier for beginners. Its main.cf uses simple key-value pairs with clear documentation. Exim’s single configuration file is more powerful but significantly more complex, with routers, transports, and ACLs that interact in non-obvious ways. For a quick start, Postfix’s postconf command-line tool also makes configuration changes straightforward.