How spam filters work: from word lists to neural networks
A spam filter decides what happens to a message: inbox, spam folder or rejection at the door. Filters run at mailbox providers, on corporate gateways and inside mail apps, and one message often passes through several of them.
From word lists to machine learning
Early filters relied on banned-word lists and IP blocklists, and spammers got around them quickly by changing spellings and renting new servers. In 2002 Paul Graham published "A Plan for Spam" and proposed a Bayesian approach, where the filter stops hunting for specific words and instead estimates the probability of spam from many features it learns from the user's own mail.
Large providers now rely on machine learning. Google wrote in 2019 that its models, together with other protections, keep more than 99.9% of spam, phishing and malware out of Gmail inboxes, and that TensorFlow added around 100 million blocked messages a day. Among the categories it got better at, Google named image-based messages, emails with hidden embedded content, and new domains hiding a little spam inside legitimate traffic.
In 2023 Gmail replaced the text vectorizer in its spam classifier with RETVec, which resists homoglyphs, invisible characters and keyword stuffing. Google reports a 38% better spam detection rate over the baseline and 19.4% fewer false positives.
How a spam filter is built
A modern filter is not one rule but a chain of checks. Each adds its own signal, and the decision comes from all of them together.
The connection and the sender
Before reading anything, the server looks at the sending IP: is it on a blocklist, and what is its history? An address on a Spamhaus list can be refused outright before the content matters. Greylisting also happens here, when an unfamiliar sender gets a temporary refusal and the server waits for a retry.
Authentication
The server checks SPF, DKIM and DMARC: is the IP allowed for the domain, is the signature intact, does the From domain match the authenticated one. Gmail requires SPF or DKIM from every sender, and since November 2025 it penalizes bulk senders without SPF, DKIM and DMARC up to outright rejection. The setup guide walks through the records.
Reputation and the message itself
The filter weighs the history of the domain and IP, meaning complaints, bounces, trap hits and volume spikes (see the guide to sender reputation). The message gets its own assessment too: subject, text, HTML, links and attachments. More on this layer below.
Recipient reactions
The provider sees what people do with a sender's mail. They open it, reply, rescue it from spam, or complain and delete it unread. Google advises keeping the complaint rate below 0.1% and never reaching 0.3%. "Not spam" is a signal too, telling the filter the recipient wants the message.
Email content filtering: what gets checked
Content filtering examines the message and gives it a score, the spam score. One suspicious word decides nothing; a combination of features does. The glossary entry on email content filtering goes into how the score is built.
- Text and subject. Pushy calls to action, all caps, strings of exclamation marks, a subject that does not match the body. Google specifically asks senders not to start subjects with "Re:" or "Fwd:" unless the message is a real reply or forward.
- HTML. Hidden text is risky. Google says outright that hiding content with HTML and CSS can get messages marked as spam. A single image leaves a filter almost nothing to read, and image-based mail is one of the categories Gmail says it catches better.
- Links. Link domains are matched against domain blocklists such as Spamhaus DBL. Google asks for links that are visible and easy to understand. URL shorteners hide the destination, and filters distrust them.
- Headers. Consistency between From, Reply-To and Return-Path, a single address in From, and the SPF, DKIM and DMARC results.
- Attachments. Gmail does not let executable files through at all (.exe, .bat, .js and dozens more), nor documents with malicious macros or password-protected archives containing archives.
SpamAssassin and point scores
Open-source filters such as SpamAssassin and Rspamd run at hosting companies and on corporate servers. SpamAssassin passes the message through weighted rules and adds up the points. By default a message is spam at 5 points, and the documentation calls that quite aggressive, suggesting 8 or 10 for ISPs. Testing services like mail-tester show which rules fired on your message.
Providers, gateways and mail apps
- Mailbox providers. Gmail, Outlook.com and Yahoo run their own systems and do not reveal the score. Gmail exposes spam rate and compliance in Postmaster Tools, Microsoft offers per-IP data in SNDS, and Yahoo runs a Complaint Feedback Loop.
- Corporate gateways. Proofpoint, Mimecast and Microsoft Defender for Office 365 sit in front of a company's mail server. Admins can block attachment types or whole domains, and the rules are often stricter than at public providers.
- Mail apps. Thunderbird and other clients learn from one user's choices. If that person keeps moving your mail to spam, the client starts doing it on its own.
Gmail also has tabs. Promotions is not spam; the message is still in the inbox, just in a separate category. Marketing mail usually lands there. If a recipient drags a message to a different tab, Google's help says this teaches Gmail their preferences over time.
How to get past spam filters
Filters and spammers learn from each other, so evasion tricks go stale faster than you can roll them out. What works is what filters already treat as signs of an honest sender.
- Set up SPF, DKIM and DMARC and recheck them after every DNS change in the domain health check.
- Clean the list. Dead addresses cause bounces, and abandoned ones turn into traps.
- Add one-click unsubscribe per RFC 8058 and a visible link in the body. Someone who cannot find the way out clicks "Report spam".
- Mail people who read. Long-silent subscribers get re-engagement first, then a decision.
- Warm up new domains and IPs without sudden volume jumps.
- Before a big send, run the pre-send checks with your own Gmail, Outlook and Yahoo mailboxes.
If mail is already landing in spam, the steps are in why emails go to spam.
Sources
Filters remember bounces and trap hits for a long time, so dead addresses are better removed before you send. uChecker checks your first 100 addresses at no charge.
Mark Avrilov · Author
Published Updated
