How to Set Up Apple Mail Rules

Mail rules can automate your Mac's mail system

Automate basic email tasks in Apple Mail with Apple Mail rules. When you create Mail rules, you tell the app how to process incoming pieces of mail. Mail rules automate repetitive tasks, such as moving the same type of messages to a particular folder, highlighting messages from friends and family, or eliminating spam emails.

Instructions in this article apply to Macs with macOS Mojave (10.14.) and Mail version 12.4. Earlier versions of macOS follow similar processes.

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.

Mail can run AppleScripts to perform additional actions, such as launching specific applications.

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:

  1. Go to Mail > Preferences.

    Preferences menu item in Apple Mail
  2. In Preferences, choose Rules.

    Rules button in macOS Mail Preferences
  3. Select Add Rule.

    Add Rule button in macOS Mail Preferences
  4. In the Description text box, enter a name for the rule, for example, Example Bank CC Statement.

    Description field for Rule in macOS Mail Preferences

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.

  1. Select If > All.

    All Rule drop down in macOS Mail Preferences
  2. In the conditions section below the If statement, select the first drop-down arrow and choose From.

  3. Select the second drop-down arrow and choose contains.

  4. If a message is open (or selected) when you create this rule, the field next to contains automatically fills with the appropriate From email address. Otherwise, enter this information manually. For example, enter alert.examplebank.com.

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:

  1. Go to the right of the first condition line and click the Plus (+) button to add a second condition line.

    Plus button for a second condition line in macOS Mail Preferences
  2. In the second condition section, select the first drop-down arrow and choose Subject.

  3. Select the second drop-down arrow and choose contains.

  4. If a message is open, the field next to the contains field automatically fills with the subject line from the email. Otherwise, enter this information manually. For example, enter Example Bank Statement.

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:

  1. In the Perform the following actions section, select the first drop-down arrow and choose Set Color.

    Set Color menu in macOS Mail Preferences
  2. Select the second drop-down arrow and choose of text.

  3. Select the third drop-down arrow and choose Red.

  4. Click OK to save the new rule.

You can add more than one action, just as you can add more than one condition. Use multiple criteria to fine-tune the effectiveness of the 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.

Was this page helpful?