A spam filter is automated software that checks every incoming email against sender reputation, authentication records, content patterns and machine-learning models, then delivers it, sends it to the spam folder, or blocks it. Modern filters such as Gmail's block more than 99.9 percent of spam, phishing and malware, but they still make mistakes — legitimate mail can land in spam, and a small share of attacks still gets through.
Key takeaways
- A spam filter scores every email on reputation, authentication, content and behavior before deciding to deliver, quarantine or block it.
- Bayesian and machine-learning filters learn from the messages you mark as spam, so your reports make the filter smarter.
- Legitimate mail lands in spam when authentication is missing or the sender's reputation is poor — fix SPF, DKIM and DMARC first.
Every day, billions of unwanted emails are sent — ads you never asked for, scams, fake invoices and malware. Almost none of them reach your inbox, and the reason is a spam filter: software that inspects every message and decides, in milliseconds, whether you should ever see it.
What is a spam filter?
A spam filter is an automated software system that analyzes incoming email and separates unsolicited, unwanted or malicious messages from legitimate mail. It acts as a gatekeeper between the open internet and your inbox, and any message it suspects is redirected to a spam or junk folder, quarantined, or rejected outright.
Internet providers, free email services and businesses all run spam filters. Gmail, Outlook and Yahoo filter mail on their servers before it reaches any device, while companies add gateway filters that sit in front of their mail servers. Your email app may add its own local rules on top.
Spam is any unsolicited bulk message sent without your consent, usually for commercial or fraudulent purposes. A filter's job is not just to hide ads: it is a security control that blocks phishing links, malicious attachments and business email compromise attempts. The FBI's Internet Crime Complaint Center received 191,561 phishing and spoofing complaints in 2025, and most of those attacks started as an email a filter was supposed to catch.
How does a spam filter work?
A spam filter runs every message through a layered pipeline — connection checks, authentication, header and content analysis, then machine-learning classification — and each stage adds to a score that decides the message's fate. The whole process takes milliseconds.
First comes the connection check. The receiving server looks at the sending IP address: is it on a blocklist, does it have a history of sending spam, is it a residential connection pretending to be a mail server? A bad reputation can get the message rejected before its content is even read.
Next is authentication. The filter checks SPF, DKIM and DMARC records to see whether the sender is authorized to use the domain in the From address. A message that fails these checks looks forged, and filters treat it accordingly. Our guide to what DMARC is and how to set it up explains the record that matters most.
Then the filter reads the headers and the content: the routing path, whether the Reply-To differs from the From address, the words and links in the body, and any attachments. Finally, a machine-learning classifier weighs all of it against patterns learned from billions of messages and produces a score.
What are the main types of spam filters?
There are several kinds of filter, and modern email services use most of them at once. Each catches something the others miss.
| Type | How it decides | Strength | Weakness |
|---|---|---|---|
| Blocklist | Blocks senders on known spammer lists | Stops known bad senders instantly | Useless against new senders |
| Header | Checks routing, Reply-To, authentication | Catches forged and spoofed mail | Can be fooled by a clean-looking header |
| Content | Scans words, links, images, attachments | Catches classic spam patterns | Spammers reword messages to dodge it |
| Rule-based | Applies user or admin rules | Precise control for known cases | Needs constant manual updating |
| Bayesian | Learns word probabilities from your mail | Adapts to your inbox | Needs training data to work well |
| Machine learning / AI | Neural models trained on billions of messages | Catches new, unseen spam | Can be opaque when it makes mistakes |
Apache SpamAssassin, the open-source filter used by many mail servers, combines several of these at once: text analysis, Bayesian filtering, DNS blocklists and collaborative databases, all feeding one score. Gmail's system goes further: Google has used neural networks in Gmail's spam filter since 2015, and in December 2024 it said Gmail had begun using a large language model trained on phishing, malware and spam.
What is Bayesian filtering, and how does it learn?
Bayesian filtering is the statistical heart of most spam filters. It is named after Thomas Bayes, the 18th-century mathematician whose theorem relates the probability of an event to the evidence for it. Applied to email, it asks: given the words and features in this message, how likely is it to be spam?
The filter is trained on a large set of messages already labeled spam or legitimate mail (called "ham"). It learns, for example, that the word "free" in all capitals appears far more often in spam than in ham, while your boss's name appears almost never in spam. Each feature pushes the probability up or down.
The clever part is that the filter keeps learning from you. When you mark a message as spam, or rescue one from the spam folder, the filter updates its model. That is why the same filter behaves differently for different people — and why reporting spam instead of just deleting it makes your own filter smarter.
Modern filters add far more features than words: the number of capital letters in the subject, the number of special characters, the presence of HTML, link destinations, sending speed and the age of the sending domain. Early learning-based filters used naive Bayes classifiers, following a 1998 paper by Sahami, Dumais, Heckerman and Horvitz and Paul Graham's 2002 essay, as described in TechTarget's spam filter definition.
Why do good emails end up in spam?
A filter has two ways to be wrong, and they are not equally costly. A spam message that reaches the inbox is a nuisance; a legitimate message sent to the junk folder may never be read. Filters are therefore tuned to make very few false positives — but they still happen.
The most common reasons legitimate mail lands in spam are authentication and reputation. If your domain has no SPF, DKIM or DMARC records, filters cannot verify you, and many will treat your mail as suspicious by default. Sending from a new domain, a shared server with a bad neighbor, or a bulk-mail service with a poor reputation has the same effect.
Content matters too: all-caps subject lines, heavy images with little text, link shorteners, and phrases common in spam all add score. So does behavior: a sudden burst of mail from an address that normally sends a few messages a day looks like a compromised account.
If your business mail keeps landing in spam, check your domain first with our free DMARC checker. Missing or broken records are the fixable cause in most cases.
How do spammers get past spam filters?
Spammers treat the filter as an opponent to outsmart, and they have several reliable tricks. Knowing them helps you understand why some junk still arrives.
- Fresh infrastructure. New domains and IP addresses have no bad reputation yet, so blocklists miss them. Attackers register domains in bulk and burn through them.
- Compromised accounts. Mail sent from a genuine hacked account passes authentication and reputation checks, because the sender is real.
- Image-based spam. Putting the sales pitch inside an image defeats word-based content filters, though modern filters now read images too.
- Link tricks. URL shorteners, redirects and look-alike domains hide the real destination from simple link checks.
- Clean, short messages. A spear phishing email with no link and no attachment contains almost nothing for a content filter to flag — which is why spear phishing is so hard to filter.
- Engagement farming. Some spam is designed to get replies or clicks, because engagement signals can teach a filter the sender is legitimate.
This arms race is why filters moved from keyword lists to machine learning. Google's RETVec text vectorizer improved Gmail's spam detection by 38 percent, according to Adaptive Security's guide to modern spam filtering, and Gmail now blocks more than 99.9 percent of spam, phishing and malware.
How can you make your spam filter work better?
Your filter is only as good as the feedback you give it. A few habits make a real difference, and they cost nothing.
- Report spam, do not just delete it. The report button is the filter's training signal. Deleting a message teaches it nothing.
- Rescue good mail. If a legitimate message lands in spam, mark it as "not spam" so the filter learns the sender is safe.
- Unsubscribe properly. Real newsletters have a working unsubscribe link. Use it instead of marking them as spam, or the filter learns the wrong lesson about similar senders.
- Never click unsubscribe in a scam. In phishing or obvious junk, the unsubscribe link confirms your address is live and invites more spam. Report it instead.
- Block persistent senders. Most mail apps let you block a sender outright, which is stronger than a spam report for repeat offenders.
For a business, the admin side matters more: turn on your provider's strongest anti-phishing settings, enable external-sender banners, and publish SPF, DKIM and DMARC at p=reject so attackers cannot send as your domain. If a suspicious message still gets through, paste its headers into our free email header analyzer to see the real sending server.
Is spam the same as phishing?
No, though they overlap. Spam is bulk unwanted mail, usually advertising or scams sent to millions of people. Phishing is a targeted attack that pretends to be someone you trust to steal passwords or money. All phishing is unwanted mail, but most spam is not phishing — it is just noise.
The distinction matters because filters handle them differently. Bulk spam is easy to score: it looks like other bulk spam. Phishing, especially spear phishing aimed at one person, can look almost identical to legitimate mail. That is why a spam filter is a layer, not a guarantee — and why the most dangerous messages are the ones that look clean.
See our phishing email examples to learn what the messages that slip past filters actually look like.
The bottom line
A spam filter is a layered scoring system, not a simple blocklist. It checks who sent the message, whether the sender is who they claim to be, what the message contains, and what millions of similar messages turned out to be — then delivers, quarantines or blocks it in milliseconds.
Make it work better by reporting spam instead of deleting it, rescuing good mail, and fixing your own domain's authentication if your mail lands in spam. You can check your domain's SPF and DMARC records in seconds with our free DMARC checker.
Frequently asked questions
What is a spam filter in simple terms?
A spam filter is a program that checks incoming email and moves junk, scams and virus-laden messages to a spam folder or blocks them entirely, so only mail it trusts reaches your inbox.
How does a spam filter decide what is spam?
It scores each message on the sender's reputation, whether SPF, DKIM and DMARC authentication pass, the words and links in the content, and patterns learned from millions of messages. A high score means spam.
Why do legitimate emails go to spam?
Usually because the sender failed authentication, sent from a new domain or a shared server with a bad reputation, or used content that looks like spam. Missing SPF, DKIM or DMARC records are the most common cause.
Can a spam filter block phishing emails?
It blocks most of them, but not all. Gmail blocks more than 99.9 percent of spam, phishing and malware, yet targeted spear phishing with no link or attachment can still reach the inbox, which is why user awareness still matters.
What is a Bayesian spam filter?
A Bayesian filter uses probability: it learns which words and features appear more often in spam than in legitimate mail, then calculates the probability that a new message is spam. It improves as you mark messages as spam or not spam.
How do I stop my emails from going to spam?
Publish SPF, DKIM and DMARC records for your domain, send from a consistent address, avoid spam-trigger words and link shorteners, and ask recipients to add you to their contacts. Then check your domain with a free authentication checker.
Is the spam filter on my phone the same as in Gmail?
No. Gmail and Outlook filter mail on the server before it reaches any device. Phone apps may add their own local rules, and mobile carriers run separate filters for SMS spam, which is a different system.
Should I open the spam folder to check for missing mail?
Yes, check it regularly — at least weekly. Filters make mistakes, and a legitimate message caught by mistake can sit unnoticed. If you find one, mark it as not spam so the filter learns.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against TechTarget's spam filter definition, EBSCO's research summary and current guides to Gmail's AI-powered filtering.
How we write and fact-check →