How to Set Up Apple Mail Rules

Mail rules can automate your Mac's mail system

Apple Mail Rule Editor

Automate your 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. With a little creativity and some free time, you can use Apple Mail rules editor to organize and automate your mail system.

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

How Mail Rules Work

Rules have 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. 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.

If you know how to create AppleScripts, 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

Other conditions and actions are available in Mail rules, but this list gives a general idea about what can be accomplished with Apple Mail rules.

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 in the Apple Mail App on Your Mac

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 may need for the rule.

To create a rule based on a selected message:

  1. Go to the Mail menu and select Preferences.

    Preferences menu item in Apple Mail
  2. In the Preferences window, 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, use Example Bank CC Statement as the description.

    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 when you have multiple conditions to test for, such as in this example, where you want to test both the From and Subject fields of the selected message. If you only test for one condition, the If statement doesn't matter, so you can leave it in its default position.

  1. Select the If dropdown arrow and choose All.

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

  3. Select the second dropdown 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 that further filter the types of messages that the rule is applied to. 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 dropdown arrow and choose Subject.

  3. Select the second dropdown 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

Now it's time to choose an action that will 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 dropdown arrow and choose Set Color.

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

  3. Select the third dropdown arrow and choose Red.

  4. Click OK to save the new rule.

You can add more than one action, just like 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. Any that have, for example, the From and Subject information specified in the rule appear in red text.

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.

Mail rules are versatile. You can create complex rules with multiple conditions and multiple actions. You can also create multiple rules that work together to process messages.