Filters, Labels and Rules That Do the Sorting
Build mail filters that file receipts, newsletters and alerts automatically, without hiding the messages you need to see.
Key takeaways
- Every filter is a condition plus an action, and precise conditions such as a sender address or list identifier work better than loose keywords.
- Test a rule as a search first, then apply gentle actions such as labeling and archiving before anything destructive.
- Know whether your rules run on the mail server or only in an app on one computer.
- Review filters now and then, remove stale ones and check that none were created by someone else.
A mail filter, also called a rule, checks each incoming message against conditions you choose and then acts on it: applying a label, moving it to a folder, marking it, forwarding it or deleting it. A handful of well-chosen filters can keep routine mail out of your way while important messages stay in plain sight.
The skill is mostly restraint. Start with the few kinds of mail that arrive often and never need quick attention, use precise conditions, and check what the filters catch before you trust them.
Labels, folders and categories
A folder holds a message in one place. A label or tag attaches a name to a message, and one message can carry several. Gmail is built around labels, while most IMAP mail programs and Outlook use folders, with Outlook adding colored categories that behave like tags.
The practical difference shows up when something belongs in two places, such as a travel receipt for a client project. With labels you apply both. With folders you choose one and rely on search for the other.
When viewed through IMAP in another app, Gmail labels usually appear as folders, which can make one message look duplicated. It is the same message listed in two views.
How a rule is evaluated
Order matters in many systems. In Outlook, rules run in listed order and an option such as "stop processing more rules" prevents later ones from touching the same message. Gmail applies all matching filters, so conflicting actions are harder to predict. Put specific rules above general ones where order is under your control.
Choose conditions that stay accurate
Some conditions are far more dependable than others.
| Condition | Good for | Weakness |
|---|---|---|
| Exact sender address | A particular service or person | Breaks if they change address |
| Sender domain | Everything from one organization | May sweep in important notices |
| Recipient or plus tag | Mail to a specific alias | Only if senders use that address |
| List identifier header | Mailing lists and many newsletters | Not available on all mail |
| Subject words | Automated reports with fixed titles | Easy to match too much |
| Size or attachment | Cleaning up large files | Says nothing about importance |
Mailing lists often include a List-Id header, defined in RFC 2919, which stays the same even when individual authors differ. Gmail exposes it through the list: search operator. Plus addressing is another stable handle: mail to [email protected] can be filed with a single rule on the recipient.
Combine conditions to narrow a match, and use exceptions. "From the store AND subject contains receipt" is safer than "from the store", which could also hide a notice about a problem with your order.
Design your destinations first
Before writing rules, decide where mail should end up. A small set of destinations named after what you will do with the contents works better than an elaborate tree of topics. For example:
- Reading for newsletters and announcements, visited when you have spare time.
- Records for receipts, statements and confirmations, rarely read but often searched.
- Notifications for automated messages from tools, scanned once a day.
- A few active projects, removed or archived when the work ends.
Everything else stays in the inbox. That default is important: an unmatched message from a new person should be somewhere you will see it.
For each destination, decide how often you will open it. If the honest answer is never, either the mail should not arrive at all or the rule should label it and archive it without pretending you will review it. Name destinations so the purpose is obvious a year from now, and use color sparingly so that a colored label still means something.
Useful searches to turn into filters
In Gmail you can type a search, check the results and create a filter from it. These examples use documentation addresses:
from:[email protected] subject:(invoice OR receipt)
list:announce.example.org
to:[email protected]
from:[email protected] -subject:(failed OR urgent)
cc:[email protected] -to:[email protected] The fourth line excludes alerts that mention failure, so those still reach the inbox. Outlook and other apps express the same ideas through rule dialogs. Searching your mail covers the operators.
A starter set
Begin with a few rules and live with them for a couple of weeks.
Notice that most actions keep the message. Reserve automatic deletion for mail you are certain about, and prefer unsubscribing to filtering when you simply do not want it, using the guidance in unsubscribing safely. For junk from unknown senders, use the spam button, which helps the provider's filtering in a way a personal delete rule does not.
Worked examples
Say you receive build reports from an automated system. Most say that everything succeeded. A good pair of rules files successful reports into Notifications and marks them read, while a second rule, listed first, flags any subject containing the failure wording and leaves it in the inbox. Check the exact subject lines the system sends before relying on them, and revisit the rules if the tool is upgraded.
Now say you volunteer for a club and receive both announcements and personal questions. Filter the announcement list by its list identifier. Do not filter by the secretary's address, because that would also hide the message she writes directly to you.
Finally, say a vendor sends invoices from one address and promotions from the same domain. Match the exact invoice address and label it Records. Handle the promotions by unsubscribing, so you do not need a second rule that might one day catch a real bill. If invoices ever start arriving from a different address, treat that change with caution and confirm it with the vendor, since fake invoices imitate this pattern.
Server rules, app rules and scripts
Where a rule runs determines when it works.
- Server-side rules run as mail arrives, whether or not your devices are on. Webmail filters and many business systems work this way.
- Client-side rules run inside an app on one computer. They act only when that app is open, and your phone may show unsorted mail until then.
Some mail servers support Sieve, a filtering language defined in RFC 5228. A short script looks like this:
require ["fileinto"];
if header :contains "list-id" "announce.example.org" {
fileinto "Lists";
stop;
} require declares the extension used for filing into folders. The test checks a header, and stop ends processing for that message. Folder naming and available extensions depend on your server. Many providers with Sieve support also offer a graphical editor that writes the script for you.
Test before you trust
- Run the conditions as a search and read through the results. Look for anything you would not want moved.
- Create the rule with a label only, leaving mail in the inbox.
- Watch for a few days.
- Add archiving or moving once the matches look right.
- If your app offers to apply the rule to existing mail, check the count first. A broad rule applied backward can move thousands of messages.
Avoid forwarding loops. Two mailboxes that forward to each other, or an automatic reply answering another automatic reply, can multiply messages quickly. Good mail systems detect many loops, but do not depend on it.
Keep filters from hiding things
The main risk of automation is silence. A password reset, a fraud alert or a reply from a customer can land in a folder you never open.
- Show unread counts on filtered folders you care about.
- Do not mark filtered mail as read unless you truly never need to notice it.
- Check the spam and filtered folders when you expect something that has not arrived.
- Exclude security notices from broad rules.
Rules are also a favorite hiding place for intruders. A filter you did not create that deletes or forwards messages is a warning of compromise, explained in forwarding rules attackers love. Never create a rule because a stranger or an unsolicited message asks you to. At work, forwarding outside the organization may be blocked or against policy.
Rules in shared and business mailboxes
In a shared mailbox, a personal habit can become everyone's problem. A rule that moves or marks messages affects what colleagues see, so agree on rules together, name an owner and write down what each does. Prefer labels or categories that show status over moves that make messages seem to vanish.
Administrators can also apply organization-wide mail flow rules, for example adding a banner to outside mail or blocking certain attachment types. These run before yours. If a message behaves strangely and your own rules do not explain it, ask whoever manages the mail system to trace its delivery.
Maintain the system
Review your rules a few times a year. Delete those for services you left, merge near duplicates and rename the rest so their purpose is obvious. If your provider allows exporting filters, save a copy before big changes or before moving to another provider, since rules often do not transfer automatically.
Filters support a habit and do not replace it. Pair them with a regular triage routine like the one in taming an overflowing inbox.
Common questions
Why did a filter not apply?
Check that the condition matches the actual header values, that no earlier rule stopped processing, that a client-side rule had its app running and that the message was not diverted to spam first.
How many filters are too many?
When you cannot say what a rule does or where its mail goes, you have too many. A short list you understand beats an elaborate one you have forgotten.