Lesson 7 of 14 · 14m
What Your Inbound MTA Checks
Inbound filtering is a pipeline ordered cheap-to-expensive — DNSBL and greylisting at connection time, milter scoring at DATA, Sieve at delivery — and most verdicts never read the text.
What Actually Happens
An inbound MTA does not read your message and then decide it looks spammy. It runs a staged pipeline that kills most bad mail before content exists:
Connection time. DNSBL lookups against the peer IP (reversed octets into zen.spamhaus.org and friends). Rate limits per IP and per sender. Then greylisting: the first time a triplet (client IP, MAIL FROM, RCPT TO) arrives, answer 451 4.7.1 try again later. A real MTA queues and retries in minutes — the retry succeeds because the triplet is now known. A spam cannon firing once and moving on never comes back. Greylisting costs you delivery delay on first contact from new correspondents and nothing else — which is why operators whitelist big providers' published IP ranges rather than greylisting Gmail's relays and making every first email from a new correspondent take five extra minutes.
DATA time. Content filters run as milters — the sendmail mail-filter protocol — wired into the transaction: rspamd (the standard modern choice; Stalwart has its own equivalent engine) scores the message across hundreds of symbols: DNSBL hits on URLs in the body, Bayesian classifier output, fuzzy-hash matches against known spam, HTML structure anomalies, header oddities. Each symbol adds to a composite score; thresholds map to reject / mark-as-spam / accept. The score model matters: no single symbol convicts a message — FORGED_RECIPIENTS plus URIBL_BLOCKED plus a Bayes probability of 0.97 adds up to reject, while a lone weird header is noise. Bayes itself is trained, not configured: feed it spam and ham via learn_spam/learn_ham or your engine's equivalent, or the classifier stays at coin-flip confidence forever.
Delivery time. Sieve (RFC 5228) runs per-user rules: fileinto "Junk", reject, vacation, header tests on anything the earlier stages left readable. This is also where Return-Path: gets stamped from the envelope — the header forensics lessons lean on.
The Wrong Mental Model
"Spam filters read the text." Content analysis is the expensive stage and most verdicts happen before it. IP reputation and greylisting decide the majority of outcomes — the body scan mostly exists to catch what cheap checks missed and to feed the Bayes trainer. This is also why "make the content less spammy" almost never fixes deliverability: the mail is usually losing at connection time, not in the classifier. Rewriting the newsletter's subject line does nothing when the connecting IP is on a PBL.
Evidence From Production
Self-hosted filters bite their own operators. A Stalwart container behind nginx and an SSH tunnel sees every inbound connection arriving from the docker gateway 172.28.0.1 — because docker's port publish rewrites the source address. Its auto-ban watched what looked like one IP hammering the server and banned it within minutes, which is to say it banned everyone's mail and the admin console simultaneously. The fix was two settings: AllowedIp 172.28.0.1 so the gateway is never banned, and Http clientIpSource=xForwardedFor so the real client IP is recovered from the proxy header. If you lock yourself out entirely: STALWART_RECOVERY_MODE: "1" in the compose env, up -d, fix via stalwart-cli, remove the flag. Every rate-limit or auto-ban feature on a proxied service has this shape — decide what the trusted proxy is before you turn it on.
Correct Practice
Order checks cheap-to-expensive — connection tests before milter before Sieve — and whitelist your own infrastructure IPs before enabling auto-ban. Keep Bayes trained (rspamd's learn_spam/learn_ham or your filter's equivalent) instead of tuning thresholds blind. And treat 451 deferrals as normal: a healthy MTA's log is full of first-attempt defers that succeed on retry — a log that shows none at all usually means greylisting isn't running.
Keep reading
Related articles from the SudoSecurity blog.
Self-Hosted Email in 2026: Mailcow vs Mailu vs Stalwart — Which Mail Server Should You Trust?
Self-hosted email in 2026 comes with more choices than ever. This guide compares Mailcow, Mailu, and Stalwart across security, performance, resource usage, scalability, administration, and deliverability to help you choose the right mail server for your needs.
Stalwart 1.0 Says It's the Fastest Mail Server on the Planet. Here Are the Numbers.
After five years, Stalwart hit its first stable release on October 26 with benchmarks claiming it beats Postfix and Dovecot in 35 of 38 head-to-head tests. Every one of those numbers was produced by the vendor.
How to Self-Host Your Own Email Server With Mailcow in 2026 — Complete Setup Guide
How to Self-Host Your Own Email Server With Mailcow in 2026 — Complete Setup Guide Meta Description: Stop letting Google and Microsoft read your email. This guide sets up a complete private email server with Mailcow on a NetCup VPS — DNS, SPF, DKIM, DMARC, TLS, webmail, and mobile clients.
What Self-Hosters Are Ripping Out of Their Stacks in 2026
Self-hosted email is losing to Gmail's hard SMTP rejections. Self-hosted password managers are split down the middle. And self-hosted music is doing the opposite of what you'd expect.