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!


Add Yours
  • Nice article, thanks!

  • I just got my shiny new MBP 17″ in the mail yesterday, straight outta Shanghai! Actually, it is not shiny; it is beautifully matte :)

    Anyways, I was wondering about using Mail with Gmail (IMAP preferably) and setting up mail rules will affect/interact with gmail filters. Do filters still get applied to incoming messages with gmail? Does mail ignore gmail’s labels? Does gmail ignore mail rules? Just curious, because I love gmail, but I also like desktop clients and Mail’s interface (with the widescreen plugin).

  • Uhm… wouldn’t that rule ‘Go to Sleep’ make the system sleep if ANYONE sent you an e-mail with that subject? Shouldn’t you add a rule stating that it must also originate from a specific e-mail address?

    • Good point Rob :-)

      • Yeah, cuz that’s a HUGE spam issue these days. People are trying to hack into your system by putting your computer to sleep.

    • @andy: Of course it’s not a huge ‘spam’ issue; but it’s a gross oversight as far as security is concerned.

  • One of Mail’s most powerful features is not immediately obvious, and rarely used to it’s full potential.


  • I’d been using smart mailboxes till today when i read the post. I like this way much better :)

  • An article about some useful Apple Scripts would be nice.

    • I 2nd this. And could you do a quick blurb about the iSight snapping a photo? I think that’d be more useful than putting your computer to sleep.

      Great articles, keep ’em coming.

  • Anyone know how to write Apple Script to Encoding Text Message??

    I want to create the Rule that encode my email.


  • Can I have mine and my husbands mailboxes appear in the left column?

  • Hey Guys i Use mac Mail and was wondering if im sending a large attached document and it takes real looooong to send, if my mac goes to sleep/hibernation will it still send off or cancel?

    sorry if this is a repeat :)

  • These rules seems to be very effective against the unsolicited emails aka spam. I believe this solution must be used on the PCs too because the rate success is very good.

  • I am usually to running a blog and i really recognize your content. The article has really peaks my interest. I’m going to bookmark your site and hold checking for brand new information.

  • I have an old mac mini. It’s 3 years old and somehow, I screwed up the Junk mail box. Is there any way to “reinstall” the origiinal disc without losing all my work and files? All I want to do is clean up my junk mail so that I can receive emails. Somehow or another, I screwed around with the preference junk mail box called Advance and now I am not getting any emails. Thanks to everyone that might take an interest in this problem and reply to me.
    Al Costa

  • Thanks for the auspicious writeup. It actually was a enjoyment account it. Glance complex to far delivered agreeable from you! However, how can we be in contact?

  • Youre so cool! I dont suppose Ive read something like this before. So nice to search out someone with some unique thoughts on this subject. realy thank you for starting this up. this website is something that is needed on the internet, somebody with a bit originality. helpful job for bringing something new to the internet!

  • I love this! Thanks for posting this great information.

  • Hi,
    I would like to set my mail to send e-mails 2 – 3 after I clicked on send, this way I can go back to them if I missed something or if regret sending the e-mail… please help me !

  • Great Article. I do need to point out a typo that needs to be fixed. In the second paragraph, it says “What rules are capable of, and how DO use them…”. Please change DO to TO. haha

    “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.”

  • Dear Henry,

    Please can you specify how to set specific rules to specific email accounts. At present it seems like my rules in ‘Mail’ are applied to all my email accounts in ‘Mail’ but I wish to have different rules for my various email accounts. Thanks in advance.