How the internet worksExhibit 21
Why do emails go to spam?
A spam filter asks who sent the message, scores what it says, and listens to what people report. We built a tiny word-counting filter from 4,136 real text messages. On 1,035 messages it had never seen it got 98% right, and then one friendly sentence fooled it.
Try it: write a message, watch the score
This is the small filter from our video. It learned from 4,136 real text messages and only counts words. Type anything: each word pushes the score towards spam or away from it. Nothing you type leaves your browser.
A word-counting filter is easy to fool, as the examples show. Real mail filters also check who sent the message, the sender's reputation and reports from people. The training messages are texts, not emails.
The video for this exhibit comes out on YouTube on Friday 29 January. Subscribe so you don’t miss it
Watch: why emails go to spam
A spam filter built from real messages, and the one sentence that fooled it.
The video loads from YouTube only when you press play. Watch on YouTube
Who sent it
Before a filter reads a single word, it checks the sender. A domain can publish a list of the servers allowed to send its mail; that record is called SPF. It can also sign each message with a key, so the receiver can tell if it was faked or changed; that is DKIM. A third record, DMARC, tells receivers what to do when those checks fail. Since February 2024, Gmail requires all three from anyone sending about 5,000 or more messages a day to personal Gmail accounts.
What it says
The classic method is counting words. In the 4,136 real messages our filter learned from, the word "free" appeared in 23.6% of the spam and 1.2% of the rest; "claim" in 14% of the spam and almost never otherwise; "later" went the other way. Every word nudges the score up or down, and the filter adds up the nudges. The idea became widely known through Paul Graham's 2002 essay A Plan for Spam.
What we measured
We wrote the filter from scratch and trained it on the SMS Spam Collection, a public set of real text messages labelled spam or not (they are texts, not emails). The set contains word-for-word copies, so we kept each message once: 5,171 messages. Shown 1,035 messages it had never seen, it caught 120 of the 131 spam messages and wrongly flagged 6 of the 904 real ones: 1,018 right, or 98%. Always answering "not spam" would already score 87% on this data, so the two counts say more than the percentage.
How we fooled it
A prize message we wrote scored 100% spam. With letters swapped for digits it was still spam. With the words misspelled it passed, at 11%. With one friendly sentence added at the end it dropped to under 7%. That is why real filters do not stop at words: they also weigh the sender's reputation and how many people report the mail as spam.
Why real mail gets lost
Often one of three things: the sender never set up the identity checks; too many people marked their earlier mail as spam (Gmail's limit for senders is a reported spam rate of 0.3%, three in a thousand); or the message simply reads like spam. If a real email lands in your spam folder, mark it as not spam; Google says that trains the filter.
Frequently asked questions
Why do real emails go to spam?
Often for one of three reasons: the sender has not set up the identity checks (SPF, DKIM, DMARC), too many recipients marked the sender's earlier mail as spam, or the wording looks like spam to the filter.
How does a spam filter decide?
It combines several things: whether the sender passes identity checks, the sender's reputation, the words and links in the message, and reports from people. Our demo shows only the word-counting part.
How accurate was the filter in the video?
Trained on 4,136 real text messages and tested on 1,035 it had never seen, it caught 120 of 131 spam messages and wrongly flagged 6 of 904 real ones, which is 98% right overall.
Can spammers fool a filter that counts words?
Yes. In our test, misspelling the words or adding one friendly sentence made a prize message pass. That is why real filters also look at who is sending and how people react to the mail.
Sources
- Google: Email sender guidelines (SPF, DKIM, DMARC, spam rate)
- Cloudflare Learning: What are DMARC, DKIM and SPF?
- Official Gmail Blog: The mail you want, not the spam you don't (2015)
- Google, The Keyword: how Gmail blocks more than 99.9% of spam
- Paul Graham: A Plan for Spam (2002)
- UCI Machine Learning Repository: SMS Spam Collection
Last updated
Keep exploring

How does Google search so fast?
Search real books two ways and watch the timer.
How does Netflix stream without buffering?
Slow the connection for a minute: one player freezes, the other keeps playing.
How does a JPEG make photos so small?
Drag a quality slider on a real photo and watch the blocks appear.See all the exhibitsSubscribe on YouTube (opens in a new tab)