Working With Rules in Mail

One of Mail’s most powerful features is not immediately obvious, and rarely used to it’s full potential. This feature is called “rules” and can be found hidden within the application’s preferences. Rules basically allow you to tell Mail what to do when certain things happen – moving email between folders, adding colours, or automatically sending a response.

Here, I will explain what rules are capable of, and how do use them to make the most of your email client. The article will also outline a few novel examples, including the ability to send your computer to sleep via a simple email.

Getting Started

Fire up Mail if it isn’t already open, and then in the Menu bar, go: Mail -> Preferences, or hit in the keyboard short-cut, ⌘ + ,. In the Preferences window that pops up, you’ll see that rules is the last item on the far right. Click on this, and the window will change to one resembling the following:

Opening Rules

Opening Rules

Setting up a Rule

To add a new rule in Mail, simply click the ‘Add Rule’ button in the preferences window. A new window will slide out to reveal a set of characteristics that you can input.

For this exercise, I’ll show you how to manage your emails so that when you receive an email from Apple, Facebook, or any other company, you can direct these into a separate folder away from your personal or work emails.

Adding a New Rule

Adding a New Rule

The description is the name of the rule, so that you can refer back to it easily later on. In this case, we can name our rule “Apple” or something similar. Basically when ‘all’ or ‘any’ of conditions that you input are met, Mail will perform whatever action you ask it to.

Configuring a Rule

Now, because we want to move messages that come from Apple, in the first pull down menu (apart from the any/all one at the top) choose “From”. Apple have many different email addresses, and specifying each of them individually wouldn’t be practical. However, all of their addresses do have the word “apple” in them! With this knowledge, we can simply choose ‘Contains’ from the second pull down menu, and in the text field next to it, type in the text: “apple”.

With this information, Mail will search for emails from a sender with the word ‘apple’ in the address. If we want to do the same for other companies, click on the circular ‘plus’ button to the right of the text field you just typed in, and enter the required text, such as “facebook”.

If you have a look at the first pull down menu below “Perform the following actions:”, you’ll see that there is quite a range of things you can do. For now though, just choose “Move Message”.

Now, because we haven’t yet created a place to move these commercial messages to, we will do that now. Go back to your inbox in Mail, and down the very bottom left corner is a plus sign. Click on it, and choose ‘New Mailbox…’ Leave the ‘Location’ as ‘On My Mac’, and then enter a name for this mailbox. I’ve named mine “Apple.”

Creating a Mailbox

Creating a Mailbox

Once done, hit the ‘OK’ button and go back to your new rule in the preferences window. Now, after the words ‘to mailbox:’ you should be able to find your new mailbox ‘Apple’ in the pull down menu. Depending on which version of Mail you’re using, this may be hidden in the folder ‘On My Mac.’ Now you’re done! Hit the OK button to save your rule.

Entering Rule Details

Entering Rule Details

You should now find that all of the emails that Apple has sent you, and will send you in the future automatically are moved to this new folder, separate from all of your other emails.

Some of you may be wondering “why not just use Smart Groups”? Well, the reason for this is because Smart Groups only displays specific emails in these ‘groups’. It doesn’t actually move messages from one location to another, which is useful when you want to separate commercial messages from personal ones. Also, this example I have provided above is mostly to help inexperienced users understand how Rules in Mail work, so that they can begin experimenting with other ideas themselves.

Other Uses

Of course, moving and organising items from one folder to another is just the tip of the iceberg, and there’s a huge amount more that can be done with rules. Here are a selection of some the best uses that I’ve found:

Colour Coding Messages:

A great rule that you can set up under the action is to colour code emails from specific people. I’ve set my Mail to do this so that when one of my friends sends me an email it appears highlighted orange, notifying me at a quick glance. This option can be found via ‘Set Color of Message’ under the actions.

Sound Alerts:

Another thing that I had going a while back, was that I had a comments section of my website. Every time someone sent me a comment, it went to my home email address with the subject as ‘Comment.’ In Mail’s rules, I set it up to play a pre-recorded audio clip of the computer announcing that “You have received a comment.” This is also pretty neat.

Remote Sleep:

Here’s a very clever idea of the sort of thing that you can do when you use a bit of scripting. Say you just arrived at work, and then realised that you left your home computer turned on. Not to worry, just send an email to your home computer with the subject as “Go to sleep”, and the computer will do it automatically. Here’s how…

Open up Script Editor, which can be located under AppleScript in your Applications folder. In Script Editor, type:

tell application “Finder” to sleep

Go File -> Save As… Name your script as “Go to sleep”. File Format should be left as Script, so choose a location and hit ‘Save’. In Mail, make a new rule, and fill it in as I’ve done in the image below (the location of your script may be in a different location to mine):

Email Your Mac to Sleep

Email Your Mac to Sleep

From now on, whenever you send yourself and email with “Go to sleep” as the subject, your computer will go to sleep immediately.

Auto Reply:

Away on holiday? Just make yourself another rule with the action set to ‘Reply to Message’. Now just type a message and whoever you’ve set as the conditions will receive your automatic response. This could also be very useful if you’re running a business and want to send out automatic emails to those who enquire about something.


Rules in Mail are an incredibly powerful feature, often overlooked. I have various rules set up, which all contribute to making Mail more friendly. They are certainly worth looking into, and very simple to use after you’ve mastered the basics.

If you’re familiar with AppleScript, there are endless possibilities for actions which can be created in response to an email; announce the name of who sent you a message every time you receive an email, take a photograph of the home computer’s room to check for burglars, or log out of the computer remotely. The possibilities are endless!