How Mail Rules Work

Each rule has two components: a condition and an action. Conditions are guidelines for selecting the messages an action impacts. For example, a Mail rule with the condition to look for emails from your friend Sean might have an action to highlight the message so you can easily notice it in your inbox. Mail rules do more than find and highlight messages. Mail rules organize mail. For example, rules can:

Recognize banking-related messages and move them to a bank email folder.Move spam from recurring senders to a Junk folder or the Trash.Forward a message to a different email address.

In addition to creating simple rules, you can create compound rules that look for multiple conditions before performing one or more actions.

Types of Mail Conditions and Actions

The list of conditions Mail can check for is extensive, but some are more commonly used than others. 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, and mail account. Email can also be filtered by:

Contains.Does not contain.Begins with.Ends with.Is equal to.

Actions that are available when an email matches a condition include:

Move message.Copy message.Set color of message.Play sound.Bounce icon in dock.Send notification.Reply to message.Forward message.Redirect message.Delete message.Mark as read.Mark as flagged.Run an Applescript.

Create Your First Mail Rule

This tutorial creates a compound rule that recognizes mail from a credit card company and highlights the message in the inbox. In this example, the message is sent from the alert service at Example Bank and has a From address that ends in alert.examplebank.com. Because various types of alerts are received from Example Bank, this tutorial creates a rule that filters messages based on the From field and the Subject field. Use these two fields to differentiate the types of alerts received.

Add a Rule

The quickest way to start a new rule is to open a message in Mail and base the rule on the information in the message. If a message is selected when you add a new rule, Mail uses the information in the From, To, and Subject fields to fill in the rule conditions. Having the message open also displays any specific text you need for the rule. To create a rule based on a selected message:

Add the First Condition

The If statement toggles between two conditions: If any and If all. The If statement is useful for multiple conditions, such as in this example, where you want to test both the From and Subject fields. If you test only for one condition, the If statement doesn’t matter, so you can leave it in its default position.

Add the Second Condition

To create complex rules, add a second set of conditions to further filter the messages. In this tutorial, the rule is applied to messages that are from a specified sender and that contain a specified Subject line. To add a second condition to a rule:

Add the Action to Be Performed

Choose an action to be performed on the messages selected by the rule conditions. In this example, messages that meet the rule conditions for the sender and subject are highlighted in red. To add an action to a rule: The new rule is applied to all subsequent messages you receive. If you want a new rule to process the current content of your inbox, press Command+A to select all the messages in the inbox, then go to the Mail menu, select Message, and choose Apply Rules.