Sub topic 10
Automating sorting with filters and rules
This chapter assumes you already use folders or labels, archiving and search in your email client, and that you have a task list. It builds on the previous chapter about unsubscribing. Some mail is useful but does not need a decision from you today. Filters and rules sort that mail before you see it.
What a filter does
A filter (Gmail's term) or rule (Outlook's and Apple Mail's term) has three parts:
- A condition, such as "the sender is [email protected]" or "the message has a List-Unsubscribe header".
- An action, such as move to a folder, apply a label, mark as read, or skip the inbox.
- A trigger. The client applies the rule to each message as it arrives.
A filter takes over the per-message decision for mail you can predict. It does not replace triage for mail that needs judgment.
Choose what to automate
Automate mail where you already know the answer every time.
| Kind of mail | Typical action | Why |
|---|---|---|
| Newsletters and bulk mail | Move to a Newsletters folder | You read it in a scheduled session |
| Receipts and order confirmations | Label "Receipts", skip the inbox | It is reference mail and search will find it |
| Automated alerts you act on | Keep in the inbox, add a star or label | It needs a decision |
| Mail from your manager | Never filter away | A missed message costs too much |
A worked rule
Many bulk senders include a List-Unsubscribe header, so one rule can catch much of that mail. This rule is written in Sieve, a standard mail-filtering language (RFC 5228) used by many servers.
require ["fileinto"];
# Bulk mail that carries a List-Unsubscribe header goes to a folder
# you read in a scheduled session, not into the inbox.
if exists "List-Unsubscribe" {
fileinto "Newsletters";
}require loads the fileinto extension. The if exists test checks that the header is present. fileinto moves the message to the named folder, and the message never reaches the inbox. In Gmail or Outlook you build the same rule in the settings screens instead of writing Sieve.
A filter is the same decision as the triage function, applied by the client. This is the decision order from earlier in the tutorial:
def triage(is_junk, needs_action, minutes_needed, someone_else_better, worth_keeping):
"""Return the action to take for one message."""
if is_junk:
return "delete"
if not needs_action:
return "archive" if worth_keeping else "delete"
if someone_else_better:
return "delegate"
if minutes_needed <= 2:
return "do now"
return "defer to task list"
print(triage(False, True, 1, False, True)) # do now
print(triage(False, True, 30, False, True)) # defer to task list
print(triage(False, False, 0, False, True)) # archiveA rule can only answer the questions it can read from the message: sender, subject and headers. It cannot tell whether a message needs action from you, so rules suit the "archive" and "delete" branches best.
How rules fit the process
Common errors
- Hiding mail you need. A rule that skips the inbox and marks mail as read makes it invisible. Use that only for mail you will never act on. For everything else, keep the folder or label visible and check it in a session.
- Rules that are too broad. Filtering on a whole domain such as
example.comcan catch a person's mail along with the automated mail. Match the exact address or a header instead. - Rules that nobody reviews. Senders change addresses, and old rules start to misfile mail. Check your rules during the weekly review.
- Starting with many rules. Begin with two or three, and add a rule when you notice you are sorting the same kind of mail by hand a third time.
Exercise
A rule moves everything from the domain shop.example.com to a "Receipts" folder and marks it read. Last week you missed a message from a shop employee about a delivery problem. What two changes would you make to the rule?
Show answer
Narrow the condition to the exact automated sender address (for example [email protected]) so personal mail from other addresses at the domain stays in the inbox. Also stop marking messages as read, so anything that does land in the folder still looks unread and is noticed during a session.