How to Set Up Apple Mail Rules

Mail Rules can Automate Your Mac's Mail System

Apple Mail Rule Editor
Finished Bank Statement Rule. Screen shot courtesy of Coyote Moon, Inc.

Apple Mail is one of the most popular email apps for the Mac, but if you have just been using Mail in its default configuration, you have been missing out on one of the best features of Apple Mail; Apple Mail rules.

It's easy to create Apple Mail rules that tell the app how to process incoming pieces of mail. With Apple Mail rules, you can automate those repetitive tasks, such as moving the same type of messages to a particular folder, highlight messages from friends and family, or get rid of those spammy emails we all seem to get.

With a little bit of creativity, and a bit of free time, you can use Apple Mail rules to organize and automate your mail system.

How Mail Rules Work

Rules have two components: the condition and the action. Conditions are guidelines for selecting the type of message an action will affect. You could have a Mail rule whose condition looks for any mail from your friend Sean, and whose action is to highlight the message, so you can more easily see it in your inbox.

Mail rules can do much more than simply find and highlight messages. They can organize your mail; for example, they can recognize banking-related messages and move them to your bank email folder. They can grab spam from recurring senders and move it automatically to a Junk folder or the Trash. They can also take a message and forward it to a different email address. There are currently 12 built-in actions available. If you know how to create AppleScripts, Mail can also run AppleScripts to perform additional actions, such as launch specific applications.

In addition to creating simple rules, you can create compound rules that look for multiple conditions before performing one or more actions. Mail's support for compound rules allows you to create very sophisticated rules.

Types of Mail Conditions and Actions

The list of conditions mail can check for is quite extensive and we're not going to include the entire list here, instead, we will just highlight a few the more commonly used ones.

Mail can use any item that is included in the mail header as a conditional item. Some examples include:

From, To, CC, Subject, Any recipient, date sent, date received, priority, mail account.

Likewise, you can check if the ​item you are checking:

Contains, does not contain, begins with, end with, is equal to, any item you wish to test against, such as text, email name, or numbers.​

When a match to your conditional test is made, you can choose from a number of actions that can be performed, including:

Move message, copy message, set color of message, play sound, reply to message, forward message, redirect message, delete message, run an Applescript.

There are many more conditions and actions available within Mail rules, but those should be enough to pique your interest and give you ideas about what you could accomplish with Apple Mail rules.

Creating Your First Mail Rule

In this Quick Tip, we'll create a compound rule that will recognize mail from your credit card company and notify you that your monthly statement is ready by highlighting the message in your inbox.

The message we're interested in is sent from the alert service at Example Bank, and has a 'From' address that ends in alert.examplebank.com.

Because I receive various types of alerts from Example Bank, I'll need to create a rule that filters messages based on the 'From' field as well as the 'Subject' field. Using these two fields, I can differentiate all of the types of alerts I receive.

Launch Apple Mail

  1. Launch Mail by clicking the Mail icon in the Dock, or by double-clicking the Mail application located at: /Applications/Mail/.
  2. If you have a statement alert from your credit card company, select it so the message is open in Mail. If a message is selected when you add a new rule, Mail assumes that the message's 'From,' 'To,' and 'Subject' fields will probably be used in the rule, and automatically fills the information in for you. Having the message open also lets you see any specific text you may need for the rule.

    Add a Rule

    1. Select 'Preferences' from the Mail menu.
    2. Click the 'Rules' button in the Preferences window that opens.
    3. Click the ‘Add Rule’ button.
    4. Fill in the 'Description' field. For this example, I will use ‘Example Bank CC Statement’ as the description.

      Add the First Condition

    5. Use the dropdown menu to set the ‘If’ statement to ‘All.' The 'If' statement allows you to choose between two forms, 'If any' and 'If all.' The 'If' statement is helpful when you have multiple conditions to test for, as in this example, where we want to test both the 'From' and 'Subject' fields. If you will only be testing for one condition, such as the 'From' field, the 'If' statement doesn't matter, so you can leave it in its default state.
    6. In the 'Conditions' section, just below the 'If' statement, select 'From' from the left-hand dropdown menu.
    7. In the 'Conditions' section, just below the 'If' statement, select 'Contains' from the right-hand dropdown menu.
    8. If you had a message from the credit card company open when you started creating this rule, the 'Contains' field will be automatically filled in with the appropriate 'From' email address. Otherwise, you will need to enter this information manually. For this example, we will enter alert.examplebank.com in the 'Contains' field.

      Add the Second Condition

    9. Click the plus (+) button to the far right of the existing condition.
    10. A second condition will be created.
    11. In the second conditions section, select 'Subject' from the left-hand dropdown menu.
    12. In the second conditions section, select 'Contains' from the right-hand dropdown menu.
    13. If you had a message from the credit card company open when you started creating this rule, the 'Contains' field will be automatically filled in with the appropriate 'Subject' line. Otherwise, you will need to enter this information manually. For this example, we will enter Example Bank Statement in the 'Contains' field.

      Add the Action to be Performed

    14. In the 'Actions' section, select 'Set Color' from the left-hand dropdown menu.
    15. In the 'Actions' section, select 'Text' from the middle dropdown menu.
    16. In the 'Actions' section, select 'Red' from the right-hand dropdown menu.
    17. Click the ‘OK’ button to save your new rule.

    Your new rule will be used for all subsequent messages you receive. If you would like the new rule to process the current contents of your inbox, select all of the messages in your inbox, then select 'Messages, Apply Rules' from the Mail menu.

    Apple Mail rules are very versatile. You can create complex rules with multiple conditions and multiple actions. You can also create multiple rules that work together to process messages. Once you try Mail rules, you'll wonder how you ever managed without them.