Growl Notifications for Apple Mail on Mac OS X Snow Leopard (10.6)

UPDATE: You can grab a beta version of 64-bit Growl 1.2 from the Growl beta site.

GrowlMail is broken on Mac OS X Snow Leopard (10.6). The dev team for Growl has a fix in the works, but I use Prowl and like to have notifications go to my iPhone when I’m not at my computer. So in the meantime, here is my solution.

Screen shot 2009-09-02 at 9.51.22 AM

I was originally inspired by James Higgs.

You first want to create a new AppleScript using AppleScript Editor and save it somewhere logical. I used /Library/Scripts/Mail Scripts/Rule Actions/Growl.scpt Below is the code:

-- Growl Alerts in Mail
-- Hunter Ford [http://www.cupcakewithsprinkles.com]
-- This script arises from the lack of any Growl Support in Mac OS X Snow Leopard (10.6)
-- Code inspired by and adapted from James Higgs [http://blog.jameshiggs.com/2009/08/28/growlmail-on-snow-leopard-a-temporary-fix/] as well as those mentioned.

tell application "GrowlHelperApp"
	-- Make a list of all the notification types
	-- that this script will ever send:
	set the allNotificationsList to {"New Email"}

	-- Make a list of the notifications
	-- that will be enabled by default.
	-- Those not enabled by default can be enabled later
	-- in the 'Applications' tab of the growl prefpane.
	set the enabledNotificationsList to {"New Email"}

	-- Register our script with growl.
	-- You can optionally (as here) set a default icon
	-- for this script's notifications.
	register as application "Mail" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Mail"
end tell

-- Mail Rule Trigger
--
-- Source: Benjamin S. Waldie [http://www.mactech.com/articles/mactech/Vol.21/21.09/ScriptingMail/index.html]
using terms from application "Mail"
	on perform mail action with messages theSelectedMessages for rule theRule
		repeat with thisMessage in theSelectedMessages
			-- Process the current message

			-- Grab the subject and sender of the message
			set growlSubject to subject of thisMessage
			set growlSender to my ExtractName(sender of thisMessage)

			-- Use the first 100 characters of a message
			set growlMessage to (content of thisMessage)
			set growlLength to (length of growlMessage)

			if growlLength > 100 then
				set growlMessage to (characters 1 through 100 of growlMessage) & "…"
			end if

			set growlMessage to growlSubject & "

" & growlMessage

			-- Send a Notification
			tell application "GrowlHelperApp"
				notify with name "New Email" title growlSender description growlMessage application name "Mail"
			end tell
		end repeat
	end perform mail action with messages
end using terms from

-- *ExtractName*
--
-- gathers the name portion from the "From: " line
--
-- Source: robJ [http://forums.macosxhints.com/archive/index.php/t-19954.html]
to ExtractName(sender_)
	if sender_ begins with "<" then
		return text 2 thru -2 of sender_
	else
		set oldTIDs to text item delimiters
		try
			set text item delimiters to "<"
			set name_ to first text item of sender_
			set text item delimiters to oldTIDs
		on error
			set text item delimiters to oldTIDs
		end try
		return name_
	end if
end ExtractName

Run this first in the AppleScript Editor. As this is what will “register” the notification with Growl. Click the green “play” button that says “Run”.

Screen shot 2009-09-01 at 10.46.18 PM

Then you want to create a new rule in mail that will run this script on every message that comes in.

Screen shot 2009-09-01 at 4.45.20 PM

Make sure to select “Don’t Apply” that way you don’t flood your screen with tons of Growl notifications.

Screen shot 2009-09-01 at 4.53.15 PM

Comments

48 Responses to “Growl Notifications for Apple Mail on Mac OS X Snow Leopard (10.6)”

  1. Detlef Hüttemann on September 2nd, 2009 4:09 am

    Thanks – works fine!

  2. James Higgs on September 2nd, 2009 6:03 am

    Awesome. Thanks for doing that, Hunter. I may never use GrowlMail again!

  3. Cosimo on September 2nd, 2009 10:10 am

    Almost perfect!
    It just need to send the command to open the new message once the growl notification is clicked… would it be possible to add this to the apple script?

  4. Hunter Ford on September 2nd, 2009 10:56 am

    @Cosimo I’m afraid not. At the moment, only Cocoa and Carbon apps can track clicks on Growl alerts using the Growl Application Bridge. Applescript just ain’t that fancy.

  5. Eloise's thoughts and fancies on September 3rd, 2009 6:35 pm

    Snow Leopard -w00t (mostly)…

    So, my copy of Snow Leopard arrived today. A couple of hours later both machines are running it quite happily.

    Let’s start with the bad news (there’s not much actually).
    Not installing Rosetta seems like a losing prospect. There are just too man…

  6. Achal on September 3rd, 2009 9:10 pm

    Thanks so much for the script. It worked wonderfully just a small glitch on my mac. It shows the details of one previous message rather than that of the new message. (I am synching with an Microsoft server 2007).

  7. Still Learning… » Blog Archive » Snow Leopard First Impressions on September 5th, 2009 11:54 am

    [...] Next up were a couple Apple Mail plugins that notify me when I receive new mail, Growl Mail and MailUnread Menu.  I wasn’t terribly surprised to find them incompatible as Mail it known for breaking these plugin bundles whenever it updates.  I was able to find a script that could communicate with Growl through use of a rule that, so I am still notified about new mail.   That script can be found here [...]

  8. Jared on September 5th, 2009 3:36 pm

    Thanks so much for this! I just installed SL and found this issue with Growl and Mail and it’s now fixed with your script. :)

  9. Growl Mail - Alternative unter Snow Leopard | i-Meister - Fürn Apple und n i on September 7th, 2009 12:15 pm

    [...] es hier; Ein kleines Apple Skript welche die Mailbenachrichtigung ähnlich wie Growl Mail [...]

  10. blog.no-panic.at » GrowlMail notifications under OS X Snow Leopard on September 8th, 2009 8:14 am

    [...] under OS X Snow Leopard GrowlMail no longer works under Snow Leopard. Here’s a work-around: http://www.cupcakewithsprinkles.com/growl-notifications-for-apple-mail-on-mac-os-x-snow-leopard-10-6... Written by Florian Beer in: moblog | Tags: growl, growlmail, mail, osx, snowleopard Related [...]

  11. Dorian Grey on September 9th, 2009 6:30 am

    Absolutely awesome! Thank you very much!

  12. Brian Larson on September 16th, 2009 2:12 pm

    This rules!! Thanks for posting this. It worked perfectly.

  13. Chris on September 16th, 2009 2:35 pm

    It seems to only want to display the notification for the currently selected email and repeats the same number of times as there are new emails.

  14. Nick on September 21st, 2009 7:34 pm

    I’m having the same issue as Chris… Whenever I get an email, it’s just display the most recent selected email.

    Any idea what changes to the script need to be made?

  15. xmoov on September 22nd, 2009 3:05 am

    No thats what I call xmoov :-) Good lookin out!

  16. Bob Proctor on September 22nd, 2009 7:11 am

    Awesome! Thanks so much for this script. It works fine.

  17. T on September 23rd, 2009 5:08 am

    thanks this is great! :o )

  18. T on September 23rd, 2009 1:31 pm

    um wtf? the way you copy and pasted it, the line numbers show up so i get a line number in front of every line…. i have to manually remove it now, that is awful…. could you copy and paste it without the line numbers? i know it “looks cooler” but it isn’t practical.

  19. Wayne on October 1st, 2009 5:11 pm

    Outstanding.

    Thanks.

  20. Hunter Ford on October 2nd, 2009 12:35 pm

    @T If you hover your mouse inside the code block, at the top right, you should see a number of icons. These will allow you to view the source without the line numbers. There’s also an option to copy the code to your clipboard.

  21. Tim on October 21st, 2009 11:05 am

    I tried compiling the script and got lots of end of line errors highlighting the quotation marks around application “Mail” and so on.
    The script saved fine, and I ran the registration – apparently ok, in that nothing appeared to happen – yet when I try and compile the script, I still get eo line errors, and nothing happens when mail arrives..
    I copied the script on to the clipboard which I emptied in to the app script editor…any thoughts?

  22. Rick on November 10th, 2009 3:14 am

    Does not work. Followed the steps exactly, no actions in Mail. First clue something was wrong was that I wasn’t asked if I wanted to apply this rule after I created and saved it.

  23. Rod on November 10th, 2009 11:51 am

    Hunter – you just saved me! Growl mail is broken again with the lated patch from Apple, (1.6.2) but your script is working perfectly! Thanks for taking the time to write it and share it with perfect instructions!

  24. chainaddicted on November 10th, 2009 5:36 pm

    works great,

    thx,

    marius

  25. Josh on November 11th, 2009 9:17 pm

    works like a charm! Thanks so much!

  26. Sascha on November 12th, 2009 12:24 pm

    Works great, just except for the clicking issue Cosimo mentioned.
    Annoying that after every OSX update Growl doesn’t work properly any more…

  27. Jimmy on November 17th, 2009 12:42 pm

    worked like a charm, but lmao i got 1400 mails in my mailbox after that grows was opening each one so i had to quit it hehe.

    thanks

  28. RedEye on November 24th, 2009 7:37 am

    Works Fine!!! Thanks a lot

  29. Chris on November 30th, 2009 11:58 am

    Absolutely awesome! code works perfectly and is much simpler than many other workarounds I have already tried. Thanks!

  30. Madhavi on December 1st, 2009 8:47 pm

    Thanks for your script! Worked like a charm!
    Ever since the new Snow Leopard upgrade, and Growl Mail went bust, I have been so frustrated!
    But now I found your script and things are great once again!

  31. kippiler on December 3rd, 2009 12:40 am

    wow, you are awesome!!!!
    it works great! thanks a lot!!!

  32. Mauricio Clauzet on December 8th, 2009 8:45 am

    Excelent, thanks for sharing, it works great here!

  33. Wiz on December 10th, 2009 4:45 pm

    Works GREAT!!! Just ran the newest Apple update and got real upset when Growl Mail was broken again! You saved me from going nuts! Thank you so much!

  34. Notificaciones de Mail con Growl « Blog de Maquito on December 16th, 2009 2:03 am

    [...] AppleScript está sacado de Cupcake With Sprinkles, y es para Snow Leopard. Lo que hay que hacer es abrir el Editor AppleScript que se encuentra en [...]

  35. Ulf Bierkämper on December 16th, 2009 4:02 am

    Thanks, thanks, thanks… :-)

    Great job!

  36. Dan on December 17th, 2009 2:33 pm

    I am seeing the same issue with the script that Chris, Nick, and Achal are seeing.

    If there is nothing in my inbox, I get no growl notification. If I have stuff in the inbox, for a new mail, it’s showing the info from the previous email.

    Strange.

  37. DiSH on December 18th, 2009 9:51 am

    Thanks! It’s great!

  38. Chris J. Politzki on December 20th, 2009 10:07 pm

    Nice work… was getting frustrated that I couldn’t see when I was getting a new email message.

    Thanks for posting this!

  39. Gabi on December 25th, 2009 7:48 am

    Oh!!! Really, really, really useful!!!! Thanks a lot!!! ;)

  40. katmoda on December 28th, 2009 3:10 pm

    great work!

    I was missing this when i went to SL

    Works well for what i wanted!

    Thank you for sharing!

  41. Fred on December 29th, 2009 6:18 am

    Hi,

    Same issue as a few others. I get the notification right but for the mail before last.

    Any idea ?

  42. Erik Rapprich on January 4th, 2010 4:06 pm

    Thanks this is awesome. I’m def. passing this along.

  43. Growl-Push: Howl optisch besser als Prowl on January 5th, 2010 3:38 am

    [...] -> Growl Notifications for Apple Mail on 10.6 [...]

  44. Krakmann on January 6th, 2010 5:50 am

    OMG. Thanks. A. Lot.

  45. Tom Bates on January 8th, 2010 11:01 am

    Nice One :)

  46. Stephen on January 13th, 2010 10:14 am

    For those complaining about the line numbers, you can click the icon in the upper right corner to get the source.

    And I have the previous e-mail problem too. Weird. I think it’s more an AppleMail issue.

  47. Nick Gushlow on February 19th, 2010 4:34 am

    Works brilliantly thanks.

  48. Snow Leopard Issue With Mail, Exchange, and AppleScript rule | Veritrope on February 22nd, 2010 8:50 pm

    [...] quick search around reveals that this may not just be me: I saw this Comment Thread and also this post on [...]

Leave a Reply