What Happens to an Email Before It Reaches Your Inbox
You click send. A few seconds later, the message appears in someone's inbox. It looks instant, but between those two moments, the email passes through a chain of servers, checks, and decisions that determine whether it arrives at all.
Most people never think about this chain. But understanding it explains why spam gets through, why legitimate email sometimes vanishes, and why the right filtering setup makes all the difference.
Step 1: The sending server
When you send an email, your mail client hands it to your outbound mail server (SMTP server). That server looks up the recipient's domain in DNS to find the MX (Mail Exchanger) records — the servers authorized to receive email for that domain.
You compose email to contact@example.com
Your mail client → your SMTP server
Your SMTP server queries DNS: "Who handles mail for example.com?"
DNS returns MX records:
10 mx1.example.com
20 mx2.example.com
The sending server connects to the highest-priority MX server (lowest number) and delivers the message via SMTP. If that server is unavailable, it tries the next one. If all MX servers are down, the email queues for retry — typically for up to 5 days before bouncing.
Step 2: The receiving server accepts or rejects
The receiving MX server does not blindly accept every connection. Before it even looks at the message content, it checks:
- IP reputation — Is the sending server's IP address on any blacklists? Services like Spamhaus, Barracuda, and SpamCop maintain databases of known spam sources. A single blacklist hit can cause immediate rejection.
- Reverse DNS — Does the sending IP have a valid reverse DNS record? Legitimate mail servers almost always do. Missing rDNS is a strong spam indicator.
- HELO/EHLO validation — The sending server identifies itself with a hostname. Spammers often use fake or mismatched hostnames.
- Rate limiting — Is this IP sending an unusual volume of email? Sudden spikes suggest a compromised server or spam campaign.
If any of these checks fail badly enough, the receiving server rejects the connection before the message is even transmitted. This is called a pre-data rejection and accounts for a large percentage of all spam blocking — the email never enters the system at all.
Step 3: Authentication checks
Once the message is accepted for processing, the receiving server verifies the sender's identity through three protocols:
SPF (Sender Policy Framework)
SPF checks whether the sending server's IP is authorized to send email for the sender's domain. The domain owner publishes a DNS TXT record listing authorized IPs and services. If the sending IP is not on the list, SPF fails.
DKIM (DomainKeys Identified Mail)
DKIM adds a cryptographic signature to the email headers. The receiving server retrieves the sender's public key from DNS and verifies the signature. If the message was modified in transit, the signature breaks and DKIM fails.
DMARC (Domain-based Message Authentication)
DMARC ties SPF and DKIM together. It tells the receiving server what to do when authentication fails: accept the message anyway, quarantine it, or reject it outright. DMARC also requires alignment — the authenticated domain must match the visible From: address.
For a full explanation of these protocols, see The Complete Guide to Email Authentication: SPF, DKIM, and DMARC.
Step 4: Blacklist and reputation checks
After authentication, the receiving server checks the sender against DNS-based blacklists (DNSBLs). These are real-time databases of IP addresses and domains known to send spam.
| Blacklist | What it tracks | How it works |
|---|---|---|
| Spamhaus ZEN | Known spam sources, hijacked IPs, policy blocks | Combines SBL, XBL, PBL, and CSS lists into one lookup |
| Barracuda BRBL | IPs sending spam to Barracuda honeypots | Maintained by Barracuda Networks from their global network |
| SpamCop | IPs reported by SpamCop users | Community-driven reports, listings expire automatically |
| URIBL / SURBL | Domains found in spam message bodies | Checks URLs inside the email, not just the sender |
A single blacklist match does not always mean rejection. Most spam filters combine multiple blacklist results into an overall score. Being listed on Spamhaus and Barracuda simultaneously is far more damning than a single SpamCop listing. For more on how blacklists work, see How DNS Blacklists Work.
Step 5: Content scanning and spam scoring
Now the filter examines the actual message. Modern spam filters like Rspamd analyze dozens of signals simultaneously:
- Header analysis — Forged headers, missing headers, header order anomalies, timezone mismatches
- Body analysis — Spam phrases, hidden text (zero-font attacks), suspicious HTML patterns, URL reputation
- Bayesian classification — Statistical model trained on known spam and legitimate email, scoring word patterns and combinations
- Fuzzy hashing — Comparing the message against known spam campaigns using fuzzy hash matching, catching variants of the same spam template
- AI classification — Machine learning models that evaluate overall message intent, catching sophisticated spam that rule-based systems miss
Each signal produces a score. The scores are combined into a final spam score. If the score exceeds a threshold, the message is quarantined or rejected.
Step 6: Virus scanning
Attachments and embedded content are scanned against virus signature databases. ClamAV is the most widely used open-source scanner, checking against hundreds of thousands of known malware signatures. Some systems also use heuristic analysis to detect new, unknown threats based on behavior patterns.
If a virus is detected, the email is typically rejected outright — no quarantine, no second chances.
Step 7: Delivery decision
After all checks complete, the system makes a final decision:
| Result | What happens |
|---|---|
| Clean | Delivered to inbox |
| Suspicious | Delivered to spam/junk folder or quarantine |
| Spam | Quarantined for review or silently rejected |
| Malware | Rejected immediately |
| Authentication failure | Depends on DMARC policy: accept, quarantine, or reject |
Where most email setups fall short
If you use Gmail, Outlook, or another major provider, your email goes through most of these steps automatically. But there are significant gaps:
- No external blacklist checking — Gmail and Microsoft use their own reputation systems, but do not check Spamhaus, Barracuda, or SpamCop. This means senders blocked across the rest of the internet can still reach your inbox.
- No quarantine — Messages go to your spam folder (still accessible, still distracting) or get silently dropped. There is no review queue where you can inspect and release borderline messages.
- No per-sender or per-address controls — You cannot set different spam thresholds for different addresses or automatically deny specific senders before they reach your server.
- No virus scanning transparency — You do not know what was scanned, what was detected, or what was silently removed.
What an MX gateway adds to the chain
An MX gateway sits in front of your mail server as the first point of contact for all incoming email. Instead of your mail server being the MX record destination, the gateway is. It processes every message through the full filtering chain — blacklists, authentication, spam scoring, virus scanning — and only forwards clean email to your actual server.
This means:
- Your mail server never sees spam or malware — it is filtered before arrival
- You get a quarantine for borderline messages instead of a cluttered spam folder
- External blacklists (Spamhaus, Barracuda, SpamCop) are checked on every message
- You keep your existing email provider — nothing changes except adding a filtering layer in front
How Cleanbox Relay works in this chain
Cleanbox Relay is an MX gateway purpose-built for this role. You point your domain's MX records to Cleanbox, and every inbound email flows through the full filtering chain before being forwarded to your mail server via SMTP.
The filtering chain includes IP reputation checks against Spamhaus, Barracuda, and SpamCop, full SPF/DKIM/DMARC authentication with SRS rewriting for forwarding compatibility, Rspamd content analysis, ClamAV virus scanning, and AI classification. You control the spam thresholds, manage your own quarantine, and can set per-address filtering rules.
Your existing email setup stays exactly the same. The only change is the MX record. For setup details, see Setting Up Relay for Your Domain.
To see what your domain's current mail routing looks like, try the MX Lookup tool.
Ready to take control of your inbox?
Start protecting your email with Cleanbox — free plan available, no credit card required.
Get started free