Rules for Creating Rules in Apple’s Mail App

Apple’s Mail app for Mac OS X has the ability to create a rich set of e-mail handling rules. These rules can move or copy a message to a named mailbox, set a color, play a sound, delete a message an so on. Creating these rules is not hard, but care must be taken. Here are some lessons learned.

For all of 2010, I had a flaw in the rules on a family Macintosh. The result was that my wife and I missed some personal e-mails at the time they were sent. Fortunately, I discovered the problem last week, and the e-mails were subsequently found in a Junk folder. As so often happens with me, a mistake like that launches me into both a full scale rewrite and a research project to help me better understand the rules of the rules, so to speak.

As for writing the rules themselves, there are plenty of articles on the Internet that explain the mechanics of that, so I won’t go into those details here. Here are two: [1,2]. Also, this article assumes that you’ve already pre-filtered out spam with something like Apple’s junk mail filtering, SpamSieve or a server-side service.

Anyway, while I was pondering the philosophy of e-mail rules and rewriting my own rules, I started taking notes about some of the things I found to be true, and so I thought I’d share them with you.

How Rules are Processed.

The first thing to know is how rules are processed after you create them.

  • Rules are invoked, one by one, from the top down.
  • The processing of rules stops when an action moves a message to a named mailbox. Rules below that are ignored.
  • The processing of rules stops when you select the action: “stop evaluating rules.” Use this with caution: you may not be as done as you thought.
  • If, at the end of processing, no rule was applicable, the message stays where it was.

The Philosophy of Rules

Avoid Sequential Conflicts. The kinds of things you can check, the actions you can take, and the processing of the rules dictates how you structure your rules and the order in which you create them. Note, rules can be dragged up or down if you want to change their order, but that can have unexpected consequences.

For example, if you have a rule that checks for an important company, like Apple, in the From: line and filters it into a folder name “Apple” and later, down the list you check if the Sender is in your address book, where you have an Apple entry, and sends it into a folder called “Personal,” the first rule will intercept the second rule. Reversing the order of these rules could change which mailbox the message ends up in.

One way to avoid conflicts is to sketch out the rules so you can see the entire scope of what you’re doing. Another is to keep a clean Address Book. By that, I mean don’t try to enter the myriad of addresses used by merchants as a means of detecting desirable e-mail, even though they will suggest you do so. Those addresses vary constantly and, besides, the address book should be used for people you want to send and receive email from, not mailbots. Instead, use a rule like: If From: Ends with “” then Move to “Finance”. That way, if the company’s e-mail address string changes slightly, you’ll still get the message. Another way of saying this is that rules can search inside strings, while the Address Book check cannot. Take advantage of that.

Avoid Complex Logic. Rules have a popup at the top for conditions. That popup can be If “any” (which is like “or”) or it can be If “all” (which is like “and”). What that means is that you can create rules like this: If A or B or C then X. Alternatively, If A and B and C, then X. What you cannot do is: “If A and B or C then X.” I would rather keep the rule simple and understandable, then inspect the inbox for stragglers, than try to write complex rules.

Mail App rules

Recognize Implicit Facts. Don’t create explicit rules that duplicate implicit facts. For example, say you’re a developer with address “[email protected]” You want to check if a message is from Apple developer relations. It’s fine to check the From: field, but don’t also check to see if the To: field contains “[email protected]” because that’s already a given. Apple could do a mass mailing, and your specific address might not even appear in the To: line. Coding implicit facts just leads to needless complexity and possible errors.

Keep Sender Focus. Along the lines of the above, say you have three e-mail accounts. You want to check for personal e-mail, for example, the Sender is in your address book. Barring any special reason, you don’t also need to check the To: line. One reason is that you might be on the cc: line of a message sent to someone else. It should be enough that the sender is in your Address Book. Keep it simple.

Keep Mailbox Focus: Don’t create rules and filter messages into named mailboxes unless you intend to check those mailboxes often. That implies that named mailboxes should be very broad in their contents, for example, “Finances.” If you create a named mailbox for every institution you do business with, you’ll have too many mailboxes to check routinely. Instead, use the search field at the top of the window, within a mailbox, to focus on just one institution.

Test and test again. Before you finish a rule set with a catch-all that directs any remaining e-mails into a Junk folder, let your rule set work for a few weeks and leave stragglers visible in your inbox. That way, you can see the results of items not caught by rules, and you can do more tuning. On the other hand, if messages that don’t match a rule get dumped out of sight as junk, you’ll won’t become aware of failed rules unless you check your Junk folder religiously.

Don’t be too ruthless. Let a few stragglers through and click delete as needed. For example, if the Sender is not in your Address Book and none of your addresses are on the To: line, you could discard the message. But what about a mass mailing that has undisclosed recipients for a Class Action Lawsuit? It wouldn’t pass that test, but you’d want to see the message. In other words, use rules for broad filing convenience, not as a way to block or delete every last possible message when it doesn’t seem to be high priority.

Don’t File, Filter. If you find yourself dragging a lot of messages into named mailboxes as a way of cleaning out your inbox, you haven’t finished your rules. Only drag messages on an occasional basis when a rule didn’t work and when it’s not worth the time or risk to create a new rule. You should be able to do everything you need to do with eight or less rules. If you have more than that, you may need to re-think the rules. You may have too many named mailboxes or you may be doing tests that are too restrictive.


Because rules are processed from top to bottom and rule evaluation stops when a message is moved to another mailbox, you’ll need to think about keeping the rules orthogonal, that is non-conflicting, and order-sensitive. Create broad categories of special mailboxes, so you’re not checking too many of them. Let special cases stay in your inbox if need be. Take advantage of the substring searches in rules. Only put addresses in your Address Book that are people you want to correspond with and let rules deal with organizations and their myriad of ever changing substrings.

These are just a few suggestions based on my experience. Of course, it’s possible to do a whole lot more than this, and there is also a rich collection of add-ons at Hawk Wings that can help. However, the goal here is simply to bring clarity to your rule making and avoid missing important e-mails. Rules that duplicate or conflict and get too complex are hard to analyze for failure and can end up causing you to miss an important e-mail from, say, an old friend. Or a job inquiry from a recruiter you’ve never heard of. Or a message from your boss that gets pre-filtered because of an intercepting rule. Creating an old-fashioned flow chart could actually hep a lot.

If you have suggestions of your own that will help beginners stay organized, you’re invited to share them in the comments.