Rules for Creating Rules in Apple’s Mail App

| How-To

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 “” 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 “” 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.

Popular TMO Stories



I suggest a different approach to rules that may be helpful to other’s in my position. The use of rules are essential in the running of my company.

Instead of having broad category mailboxes, I have specific mailboxes for each contact and a rule associated with it. I then make liberal use of Smart Mailboxes; I have smart mailboxes: Today’s emails, Yesterday’s emails, Last 4 days, Last 7 days, Unread messages. These can be adapted as needed or more added for current projects. This way all messages are filtered as they arrive but are still visible in Today’s emails smart mailbox along with all messages sent. If I need to delve into earlier emails, I can go to that contact’s mailbox. My default mailbox is the smart mailbox “Today’s emails”.

I do create filters based on domain names as much as possible (e.g. to avoid having to create specific rules for each contact if the contact’s company is already represented in the rules.

My rules have the basic setup:
If any of the following are met:
Move message to (select contact’s mailbox)

Combined with using IMAP and basically unlimited storage (we have our own mail server), this system means regardless of what computer I sit down at, I can see what messages were received and sent from all computers. All sent and received messages are available to everyone all the time in nearly real time. I can even see drafts in progress. Often one person will write a draft, then ask another to review it. Easily done with this set up. All of this applies even if I’m working from home or on the road.

The mailbox hierarchy also mirrors our folder hierarchy on our file server so it is easy to find files for a particular contact.

Combining this setup with using automator scripts that insert event templates in iCal really make a great way of running a small company without having to invest in an off-the-shelf system. We have a company account so ical syncs and updates everyone’s calendars nearly in real-time. So everyone has all emails and all calendar updates are visible for everyone in the company automatically.

Mail rule issues I wish Apple would address
The great problem with Apple’s Mail rules is the difficulty in organizing and finding rules once you have many. They are listed in the order of creation and can’t be sorted in different ways except dragging and dropping each one. If you haven’t labelled them well, it gets messy. And you can’t activate, deactivate multiple rules in one go, just one at a time, which is a pain sometimes. They also aren’t as powerful as Eudora’s rules, which could save attachments automatically in specific locations. You have to save attachments manually.

Another issue to be aware of is not to have rules running on more than one computer for the same accounts. I made this mistake once and it results in duplicates of messages transferred to mailboxes. Just have one machine with rules running. We have 7-8 computers receiving and sending messages to the same set of mail accounts but only one has the rules running.

Another problem with Apple’s rules is that they aren’t automatically applied to your sent messages. I have to open the sent mailbox, highlight all and Apply Rules to get them filtered. I do this once or twice a day to get all our company’s responses in the correct mailbox. Even if they haven’t been filtered, the sent messages are still visible in the Today’s emails mailbox so nothing is out of sight.

I hope my experience may help others.




Is there any way to use Apple Mail rules on an iPhone? Spam makes using email on my iPhone more work than it’s worth.

Log in to comment (TMO, Twitter or Facebook) or Register for a TMO account