Loading balancing SMTP (Simple Mail Transfer Protocol) is more complex than load balancing HTTP because SMTP is stateful and stores data (emails) on disk. You cannot simply round-robin traffic to multiple servers without a shared storage strategy, or emails will end up scattered across different servers, making management impossible.
| Issue | Inbound | Outbound | |-------|---------|----------| | TLS termination | LB can terminate (easier) or pass through | Must pass through (signing keys stay on sender) | | Source IP loss | Broke greylisting | Broke SPF / reputation tracking | | Health check | EHLO , MAIL FROM:<> , RCPT TO:<test> | Same (or check queue depth) | | Sticky sessions | Not normally needed | Not needed |
Example HAProxy health check with custom script:
It supports the PROXY protocol , which allows the backend server to "see" the original client’s IP address even after proxying—a vital feature for logging and spam filtering. Key Configuration Steps
Here’s a practical guide to load balancing SMTP traffic, focusing on both inbound (receiving) and outbound (sending) scenarios.