Creating AOL-style “You’ve got mail!” system alerts on OS X

America OnlineOkay, it’s fair to say that I was struggling to fill my lunch hour yesterday, and one thing that I’ve wanted to do for a number of years was trigger the awesomely-cool “You’ve got mail” voice when I get new emails on my computer. If, like me, you were never one who actually used AOL as a service provider (and why would you), then your best bet is to think of the film of the same name starring Meg Ryan and Tom Hanks.

The basis of this trick is going to be achieved through Mac Mail’s ability to have a rule which triggers an AppleScript script. We’ll come back to that, first of all it’s time to play with Mac OS’s text to speech feature…

Give your computer a voice
Fire up terminal (it can be found in Applications > Utilities if you’re unsure) and type the following to test out the text-to-speech functionality (bear in mind that you’ll need your volume turned up!):

You should hear a manly computer voice saying “You’ve got mail” to you hopefully. Notice that the wording is wrapped in apostrophes but there’s no apostrophe between the you and the ve of you’ve. This is not grammatically correct, I know, but it still gets read correctly and it helps us to write it like that for when we get to the AppleScript portion of the lecture (and yes, it is a lecture). You can choose from a whole host of voices to use, a list of which can be shown by typing:

Then when you settle on one – I chose whisper – the finished bash command should be something along the lines of:

Writing the AppleScript script
Now it’s time to put it into a very simple script that we can then trigger from Mac Mail. To do this we’ll be using AppleScript Editor, which is found under Applications > Utilities > AppleScript Editor. Open the editor up and type the following into the top box:

Essentially it’s what we typed into terminal earlier but preceded by do shell script and wrapped in quotes (hence what we did with apostrophes earlier). The code will appear purple until you press the ‘Compile’ icon on the toolbar above, and if that works you should see your do shell script text appear in a bold navy-blue and the rest of the text becoming black. Now save the file somewhere memorable being sure to choose the file format “Script”.

Setup the rule in Mac Mail
Now if you fire up Mac Mail and go to Mail > Preferences > Rules and click “Add Rule”, configure the rule as shown below, replacing your email address and the path to the AppleScript script you saved above:

Mac Mail Rule

Save the rule and give it a test run, you should find that just as new emails come in your computer says “You’ve got mail”. Job done. I’m sure it won’t get annoying…

  • this is awesome, but i haven’t actually tested. my wife has ‘you’ve got mail’ (the movie) on, so i thought it’d be funny to actually re-live. haha.