One internet-facing SMTP server, mail.healthchecks.io, runs maddy on a single machine: it accepts mail from authenticated senders, signs it, queues and retries delivery from one fixed IP, and reports failures and bounces to a webhook handler. Each app server runs a local maddy instance that takes mail from local clients only and hands it to that server.
Section: Maddy | Section: Local Relay-Only MTAs for Reliability
Components
Component
Role
Where
mail.healthchecks.io
The internet-facing maddy server: accepts mail on port 465 from authenticated users, rewrites the envelope sender, signs with DKIM, queues and retries with exponential backoff, delivers from a single IP, and listens on port 25 for incoming bounce messages.
Section: Maddy
Local relay-only maddy instances
One on each app server; accepts outgoing mail from local clients only and passes it to the main mail server, queuing and retrying when that server is unavailable.
Section: Local Relay-Only MTAs for Reliability
Bounce webhook handler
Receives delivery failures and bounce messages from maddy; on a permanent failure it can unsubscribe a user from email reports or mark an email integration as disabled.
Section: Maddy
Figures, as the source states them
Figure
As stated
Note
Where
Transactional emails sent
300,000 emails per month
Approximate monthly total; all transactional email of the service
Near: transactional email (~300'000 emails per month)
Send transactional email through a self-hosted maddy server instead of a third-party SMTP relay
healthchecks-2023-self-hosted-email#d1at corpus version 26a1b3a7e3dd
Chosen
After several weeks in May 2023 of researching and trying six self-hosted SMTP servers (maddy, OpenSMTPD, mox, Haraka, Postal and Zone MTA), the author picked maddy, wrote provisioning scripts for it, set up SPF and DKIM records and built a webhook handler for bounces.
Section: The Self-Hosting Options | Section: Maddy
Rejected
Brevo (formerly Sendinblue). Open and click tracking is on by default, and the company would not disable it until it had seen live production traffic. The author calls that a non-starter.
Near: Brevo (formerly Sendinblue): the most prominent EU
SMTPeter. Fine on functionality and pricing, but it had a major outage while being tested, which the author allows was probably bad timing; he also notes it is a small shop.
Near: SMTPeter: OK in terms of functionality and
EmailLabs. Fine on functionality and pricing, but its interface and documentation seemed aimed mainly at the Polish market.
Near: EmailLabs: OK in terms of functionality and
OpenSMTPD as the self-hosted server.
Near: After experimenting with and strongly considering OpenSMTPD,
Reasoning
The author's main reason for looking beyond Elastic Email was GDPR compliance, a provider based in the EU being better than one in a country with an adequacy decision; the second was its poor communication during outages. None of the EU relays he tested seemed an upgrade on what he had.
Section: The Before | Near: None of the options seemed like an
What worked before
Email went through third-party SMTP relays: AWS SES, then Elastic Email, chosen for GDPR reasons. The author was happy overall with Elastic Email's functionality and pricing and says it fixed outages reasonably quickly, but some outages went unacknowledged and no post-mortems were published.
Section: The Before
Cost
The author lists as downsides: one more service to maintain out of limited time and attention, and, with maddy, no ready-made graphical dashboard for management and monitoring. He also notes that he now owns any deliverability problems, none of significance having appeared so far.
Near: Cons of going self-hosted:
Outcome
The self-hosted server had handled all of the service's transactional email for over two months, with no significant deliverability issues so far, by the author's account. He watches bounce notifications, the outbound queue size and blocklists.
Shift outgoing mail to the new server's IP gradually over several weeks
healthchecks-2023-self-hosted-email#d2at corpus version 26a1b3a7e3dd
Chosen
The author spent several weeks gradually moving outgoing email traffic from Elastic Email to the self-hosted server.
Section: IP Warm-Up
Reasoning
A gradual warm-up builds the sending IP's reputation, whereas moving the whole volume to a new IP at once risks being blocked by receiving servers. It also lets delivery be tested in production with fewer consequences when something is wrong.
Section: IP Warm-Up
Outcome
During the warm-up the author found that the brand-new mail server had minute-long network hiccups a couple of times a day, and replaced it with another server, keeping the warmed-up address by means of a failover IP.
Cancelling the old mail server also cancelled the failover IP that carried the sender reputation
healthchecks-2023-self-hosted-email#f1at corpus version 26a1b3a7e3dd
Trigger
After moving the failover IP to a replacement server and testing for a few days, the author cancelled the original machine.
Section: The Failover IP Oopsie
How it failed
A failover IP belongs to a specific server, so cancelling that server cancelled the address along with its sender reputation. A few days after the cancellation, around 2 AM local time, email delivery broke.
Near: the failover IP is owned by a | Near: email delivery was broken
Why defences did not hold
The author had assumed a failover IP was more or less what other providers call a floating IP. Delivery had been tested on the replacement machine for a few days before the cancellation, while the address still depended on the original server.
Near: I had assumed that | Near: after a few days of testing, no
Impact
Email delivery through the self-hosted server was broken until the author, alerted by monitoring, switched sending back to the relay service. The warmed-up address was out of his account until the next morning.
Section: The Failover IP Oopsie
Fix
The web servers were temporarily switched back to Elastic Email as the SMTP relay. The author asked Hetzner support for the released address, and the next morning Hetzner added the failover IP back to his account.
Put a relay-only mail agent on every app server so mail queues locally when the mail server is down
healthchecks-2023-self-hosted-email#d3at corpus version 26a1b3a7e3dd
Chosen
Each app server runs a local maddy instance that accepts outgoing messages from local clients only and hands them to mail.healthchecks.io.
Section: Local Relay-Only MTAs for Reliability
Reasoning
The internet-facing mail server is a single machine. If it is unavailable, for example during a restart, the local instances queue the messages and retry later.