Most modern mail tooling is two binaries with a UI on top
Configuring a multi-tenant mail server from scratch with Postfix and Dovecot, now handling 200k+ emails a day.
2 min read
Recently I configured a multi-tenant mail server from scratch for OmniDimension. It now handles 200k+ emails a day in production.
What’s wild about Postfix: it was written at IBM in 1998 by Wietse Venema, who still maintains it at Google. It still ships with Linux distributions and remains a common choice for mail infrastructure.
Architecturally, it is a pipeline of more than twenty small daemons. Each has one narrow responsibility: SMTP intake, queue management, address rewriting, or local delivery. Most run with reduced privileges, shut down when idle, and are restarted by a master process on failure. I picked it because it was the obvious tool.
The stack#
Outbound is the easy half. AWS SES handles warm IPs, DKIM signing, deliverability, the whole bulk-sender stack. Publish a few DNS records and you’re sending.
Inbound is where the real work was. Two open-source daemons, each doing one job:
- Postfix sits on port 25 accepting SMTP from the internet. When Gmail replies to one of our campaigns, it hits our box. Postfix matches the recipient to a customer domain, then writes the email as a file to that customer’s mailbox on disk.
- Dovecot sits on port 143 serving IMAP. It doesn’t receive mail. It just reads the files Postfix wrote and exposes them cleanly to anything that wants to read the mailbox.
Our backend connects to Dovecot, pulls new replies, and threads them back to the original campaign. Multi-tenant from day one: per-domain virtual mailboxes, catch-all routing, isolated maildirs per customer.
What it taught me#
The genuinely new thing for me was understanding how mail delivery works at a lower level. SMTP hands the message off on port 25, the MTA writes it to disk, and IMAP picks it up from there. Two separate protocols, glued together by the filesystem.
The other thing that hit me: most “modern” mail tooling is really just these two binaries with a UI bolted on top. And running your own mail server is far less intimidating than you’d think.
You can read more about the Postfix architecture in its overview. Thank you, Wietse Venema, for building it.
This started as a post on LinkedIn.