If you get a lot of emails and use AppleMail then you might want to use rules to sort your emails into different mailboxes. For instance, I have a rule for all my newsletters to go into a mailbox called "Newsletters". With this rule I can read my newsletters when I want and can see which emails are from customers. Those emails need a faster response.
Rules in AppleMail are only applied to your Inbox. Now and then an email goes into the Spam mailbox or I misfile an email. Then you can apply your rules manually by using Message -> Apply Rules.
Creating a rule
In AppleMail go to Preferences -> Rules:
The four buttons do what they say: Click on Add Rule to create a new rule. Click on the Edit button to see what a rule does. You can duplicate or delete a rule.
Click on the Add Rule button:
Give your rule a descriptive name. Rules consist of a condition part (2) and an action (2). You can have single or multiple conditions and actions. The conditions can either be applied „all“ or „any“ (1).
A condition has 3 parts: what you want to filter, the operator and a value. Open the popup menu for the filter.
There are a lot of fields that you can use for filtering:
The list starts with the fields from the header. But you can filter for accounts, lots of stuff for senders, junk or not, the priority, attachments. If that isn't enough click on "Edit header list..." to add header fields to the 4 values at the top.
My rules are quite simple and I usually filter for From, Too and Subject. Select From from the list. You will now get a list of operators for text:
If in doubt use "contains". If you had a message selected Mail is going to be helpful and already fills in the From value from the mail. But you can still edit the text as you like.
Here is an example for filtering older emails:
Not for all conditions you have to give an operator or a value. Some conditions just do a yes/no conditions. We developers call that a boolean value.
Click on the plus button to add another condition.
Applying multiple conditions
If you have only one condition then the selection of all/any doesn’t matter. If you have multiple conditions then setting this value correctly is very important.
Let’s say you want to filter for emails with a From:
From contains icloud
From contains gmail
Both conditions can’t be true at the same time and therefore you need to select „Any“.
You can apply all/any only for the complete rule. That makes rules more simple but it restricts them.
Wildcards in values
The operator „contains“ already is a very simple wildcard. It looks for *word*. But sometimes that isn’t enough. Let’s say you want to filter for *word*@domain. Which would filter for a domain and only a part of the email address. But the values don’t support wildcards at all. The current way to support this is to have 2 rules:
From contains word
From contains domain
Which might not have quite the same result.
THE action to take is to move emails. The rule from the screenshot below is for all my newsletters which are moved into the Newsletters mailbox:
But there are more actions available:
The rule for emails from Apple have the „Set Color of Message“ action. But you can copy, redirect or forward emails. You can even do AppleScripts. But these need to be in a certain location because security.
Click on the plus button to add another action.
Rules are executed in order. If a rule doesn't do what you want it to do then try to make the other rules inactive and keep only one rule active. Then make sure that your rule works fine and activate the other rules. For that to work you need to have less than 600 rules from the recent blog entry.
If your rules interfere with each other try to add the action „Stop evaluating rules" to the end of the actions.
Rules can be synchronised between computers. I have an iMac and a MacBook Air. Both have access to the same IMAP accounts. Independent of which computer is on I need to have the same set of rules applied. I read that there can be synchronisation errors. As usual Apple doesn't offer any help when you have problems. The synchronisation is an all or nothing. You can't even say that you only want some rules synched and not others.
What I occasionally get is a message that mail with the subject so-and-so couldn't be moved according to a rule. This seems to occur when both computers at the same time try to move the email and one looses. One thinks that Apple never heard about such complex usage scenarios (that was irony).
Rules in AppleMail support a wide range of workflows. It’s a bit of work to set them up. Occasionally, I need to fine tune my rules. If you need more power then have a look at Mail Act-On.
The rules are done on the computer. iCloud and Gmail offer server-based rules. Server-based rules are done before the computer downloads the emails. You need to set the rules only once and don’t have to deal with synchronisation. But the rules - at least for iCloud - don’t offer the full range of features that AppleMail does. We are going to have a look at server-based rules in the next blog article.