Filed under: Software, How-tos, Productivity
Mail.app rules!
One of the neat things about Mail.app is rules. Rules will perform a specified action if a certain condition is met. These actions include moving, copying, and setting the color of a message, as well as automatically replying, forwarding, and redirecting a message. For example, the "News from Apple" rule, which highlights messages received from Apple in light blue, is included in mail.app by default. Here are a few of my favorite rules.
To create a rule, choose "Add Rule" within the "rules" pane of mail.app's preferences.
When some emails are more important than others
Some emails are more important than others. With this rule, you'll know get a more visual way of discerning which emails may demand more immediacy. Say you're awaiting an email from Stan Sitwell, (CEO of Sitwell Enterprises), about a possible business deal. The following rule will result in the mail.app icon bouncing in the dock when an email from Stan Sitwell, or a high priority, message arrives in your inbox.
- In this case, "any of the following conditions" should be chosen
- "From" contains "stan@sitwellenterprises.com"
- "Priority is high" -Perform the following actions: "Bounce icon in dock"
And then there are the less important emails
Say your brother, George Oscar Bluth (also known as "GOB"), continually asks you to borrow money to help fund his fledgling career as a magician. You're tired of it, and you want any email from GOB that contain the word "money" in it to automatically be filed in a special folder.
- Here, "all of the following conditions" should be selected
- "From" contains "gob@bluthcompany.com"
- "Message Content Contains" "money"
- In the "Perform the following actions" action, choose "Move Message" to mailbox and choose the folder of your liking
Announce the name of the email sender
Similar to how mom would tell you if Jimmy or Mike was calling on the other line, this mail rule, when combined with an AppleScript that George Sudarkoff put together, will speak the name of the sender of the message as the message arrives in your inbox. What's more, if you have a song playing in iTunes, said song will pause and resume play after the name is spoken.
- First, launch the AppleScript Editor and copy and paste the code from this page on George Sudarkoff's site. Then, save the AppleScript somewhere on your computer.
- Now, choose your conditions, as you may not want the names of all senders read along.
- In the "Perform the following actions" action, choose "Run AppleScript," and select the AppleScript file you just saved.
Automatically queue up torrents
One of my favorite mail-centric AppleScripts that I like to incorporate with rules (via macosxhints) automatically runs an AppleScript when it sees the words "download torrent" in the subject field. To do this, just click on Mail.app's preferences and create a subject-based rule that, when met, will run a AppleScript: that particular AppleScript is downloadable here [download link]. The AppleScript will then launch your specified torrent client (by default, it's Azureus, so you'll need to use the AppleScript Editor to change this if you so desire) and add the torrent file to the queue.
While torrents are often used for illegal purposes, there are many legally distributed torrent files, which often help companies and individuals reduce their bandwidth burden; for example, while at work, I've emailed myself the torrent files for new releases of the iPhone PwnageTool.
As the issue of the legality of torrents and P2P networks may vary depending on your locality, users should abide by their local laws accordingly.
Readers, let us know about some of your favorite rules in mail.app.

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 2)
datagrab said 3:27PM on 12-01-2009
How do you make a rule that automatically moves/copies an email you sent to someone? For instance, let's say I have a folder for a person named John. I want a rule that moves/copies any email I send to John to the folder "John".
Reply
Noah O said 3:42PM on 12-01-2009
You should create a smart mailbox that contains any messages containg the recipient "John"
Poltras said 4:02PM on 12-01-2009
I definitely prefer smart folders to complex rules. I just classify stuff for SVN, bugtracker, mailing lists into their own folders, then use smart folders to check per projects or keywords.
datagrab said 2:33PM on 12-02-2009
The Smart Mailboxes really don't do everything I want though. I can create one called "John" and set it up so everything to/from John goes in it, but I can't create subfolders so that emails specific a project can be filed within it. It's either all or nothing with Smart Mailboxes as far as I can tell.
Am I missing something?
Mike said 3:27PM on 12-01-2009
One important thing to mention about Rules: They're only applied automatically to *new* email. If you check email on your iPhone or anywhere else, then come back to Mail then you must apply the rules manually.
Reply
Dorv said 3:47PM on 12-01-2009
One of the only things I dislike about mail.app.
SpinThis! said 4:12PM on 12-01-2009
Yeh and Mail's rules only work locally on that machine unless you have a .mac and you have your rules set to sync across multiple machines.
If you do your own e-mail, server-side rules (via procmail or mailfilter) are where it's at. They're a little more of a pain in the ass to setup and update but they work across multiple machines and if you have your mail filter into different folders, they also show up like that on the iPhone.
derajfast said 3:39PM on 12-01-2009
It's alpaca, actually.
Reply
Francisco said 4:02PM on 12-01-2009
I've been scratching my head for a while cause I want a rule that makes every mail I move from my iPhone to the mobileme junk folder to get reported as spam. That would be sweet, but I can't find a way to do it
Reply
SyracuseSeth said 4:02PM on 12-01-2009
I do think Apple's mail rules bring some interesting features. However, compared to Entourage they leave me wanting. I would love to have a rule that cleans up old mail messages (say those that reach 2 years of age) and dump them in a folder that is ready for me to consider deleting/archiving. However, once you have a rule operate over the inbox, it does not operate over any other mailboxes or folders. Also, I'd love to assign/mark messages with colors. AND, finally, why am I stuck with just Any/All as my operators. Why not make it fully robust and allow boolean operators and multiple conditions. For example, find all mail containing "John Smith" and "is 7 days old" but not containing phrase "project x" and not sent from his "@gmail" account or "@yahoo" account.
Reply
SpinThis! said 4:35PM on 12-01-2009
You should really read Apple's rules again since you do all of what you're asking for with the built-in rules and smart folders. A smart folder is a perfect candidate for your first rule: mail over x date.
puhsitch said 6:38PM on 12-01-2009
The fact that Apple hasn't changed the "any/all" restriction is baffling to me. That's something that should have been brought in a long time ago.
hmlong said 5:10AM on 12-02-2009
I suspect that the next version will up the "any/all" restrictions, as evidenced by the more advanced rules engine that was added to iTunes Smart Lists.
Sjan said 4:22PM on 12-01-2009
My biggest gripe about Mail.app rules is that they are not copied in the iPhone mail app. Sure, if I want to leave my laptop at home, turned on, with Mail.app open then items go into their proper folders. But that is usually not the case.
Reply
Moose said 4:51PM on 12-01-2009
This is not rule related, but here's hoping someone can point me in the right direction:
Is there a way to have ALL attachments automatically zipped? I have a lot of clients who only see non-zipped attachments as inline files that they can't access. Very annoying. Would an Applescript do it, perhaps or am I missing something very obvious?
Reply
Don O'Shea said 6:17PM on 12-01-2009
How about a rule that says that if you specify that your Sent mailbox should show a To: column and not a From: column, which (duh!) always lists the sender (me), that this will remain in effect should I close mail.app?
How about a rule that says that if I attempt to open an already-open message, that there is sufficient program that it brings the open message to the front?
And how about a set of rules that allows me to send messages to the back of the stack of windows, so I can manage the mess that mail presents me with?
I DO realize these are not programmed rules, but they oughta be in place before we even talk about user initiated rules.
Reply
srw said 8:08PM on 12-01-2009
Something must be messed up with your Mail.app installation:
-I have configured to only show To:-column in my Sent-box, and it is always remembered across restarts. No From:-column, since as you say it is not very informative.
- When double-clicking / pressing Enter on an already opened mail message, it automatically pops to the front.
- Not sure what you mean with a "rule" here, but you can always go to the Window-menu and select the main window there -> it will be above all message windows.
Are you running some kind of third-party plugin for Mail.app? As far as I can tell, Mail.app has worked exactly like this for quite some time. If not I fear you'll have to do some bug hunting :-(
Reply
upstageleft said 8:58PM on 12-01-2009
Apple Mail continues to fail me in one major respect that should not be a problem. I want to create a log of all messages filtered by my rules. I have set my various spam-deleting Mail rules to run an applescript which writes info to a log file, and then delete the offending message. What happens is that Mail changes the action order to delete the message first, and then NEVER RUNS the applescript. I even changed it to run a basic script that just pops up a dialog to say that the script has indeed run, but no dice.
I don't know if this will work, but here's a link to a screenshot of an example rule: http://imgur.com/dhPQ7.png
The script it calls is at:
~/Library/Scripts/Mail Scripts/Rule Actions/Log.scpt
I'm not including the script because it doesn't matter. Mail never runs it.
Anyone with an idea why this doesn't work? (I'm running 10.5.8, and upgrading to 10.6 is not a useful suggestion for me at present.)
Reply
julian said 8:35PM on 12-01-2009
thanks for the Tip!
you guys should have a rate this article button so that i can like articles
Reply
Dylan said 9:10PM on 12-01-2009
GRR. I accidentally created a rule that highlighted every single email. I deleted it, and it still didn't remove the highlight.
How do I remove this rule?
Reply