Post 

Software

New mail notifier for Evolution

Evolution is a great email client, it's just missing a good new mail notifier - actually, it has none. I am running Fedora Core with Gnome and there's the new-mail applet, but it's huge and an overkill for most cases. To make a long story short, i was looking for a new mail notifier for Evolution and found none which were usable - so i made one. The following code should work on most Gnome desktops including Ubuntu and you can use with any other mail client which can pipe new emails to an external application:

Notifier
Getting a new spam notification

It's using the libnotify library with python bindings (yum install notify-python), this is the source:

Save the code to a new file, give it the .py ending and make it executable (chmod +x notifier.py). Go to Evolution and create a new message filter for incoming mail and pipe all new mails to the script.

filter

You can also use the script if you are running procmail locally, just add the following script to your ~/.procmailrc file:

# popup new mail alert
:0 c
| ~/notify.py

I release the notifier code in the public domain, do whatever you like with it. If you do some changes to it, please send me a copy, i may be interested in seeing it. Also it would be nice if you could link back to this post.

19 Comments

Small update from me (in a comment, because i am too lazy to login): you can add following criteria to the filter if you are like me saving your sent mail in the inbox and don't want to have an notification for that: [Status] [is not] [Read]

And i found a "native" patch for the new mail plugin included in evolution, you will have to recompile the whole package, but it may be an better option for some people. I have not tried it, but have a look: http://iapart.net/tresc.php?id=17

I don't have a response, more like a question. I tried all the steps and it didn't pop up any email notification. A couple of things I was unsure of, (1) at the top before the code, you wrote (yum install notify-python), and I was unsure if this was something to be entered in terminal as a command, or not? (2) In the code, it says - icon="email" # full path to icon OR gnome icon stock name, try 'email', where on my list of icons it has an icon named "mail" but no "email", I tried it both ways and still no notification. I think that for those not expert in terminal commands and code (like me), that a little more detail would be very helpful. (3) You say to add the criteria to the filter [Status] [is not] [Read], where and how do you make that update, through terminal or added onto the source code above. I am very unsure and could use a lot of help. Thank you.

dsimpson,

1) you can execute the command mentioned above in the terminal, but only on fedora core. on any other system you need to find a package that is similar to notify-python, use your systems package manager to search for it. On Ubuntu 7.04 it's called python-notify

2) you should get a popup anyway... leave as email first.

3) In evolution, add it under the "Match all' rule (or replace "match all" with that rule)

Finally, make sure it is executable, either execute in terminal the command "chmod +x notifier.py" or on your desktop right-click on it and check the permissions in the properties

If everything does not work, save an email from evolution (file/save message), go to terminal and execute the following command and see if you can get any errors to post here:
cat /path/to/savedmessage.txt | /path/to/notify.py

Hi,

I'm trying it out but I can't have it working. No mails notification....

It works if I export a mail message and then pipe it to the script (ie cat mailmessage | notifier.py).

I believe it has something to do with evolution mail filters. Is this script supposed to work with Evolution 2.8.x ?

Thanks and regards

Z.

I can only test it with 2.10.1, so I don't know what's wrong with your version.

1. Check if the filter actually gets executed, change the status color, flag it or any other harmless action.

2. Create a bash file with:
#!/bin/bash
cat - >~/test.txt
And see if you get a test.txt file with the mail message...

3. ... no idea :-D See if your filter looks like on my screenshot above.

Thanks, I'll try and I'll let you know.

regds

Z.

Hi,

it's me again...

message filters don't work. It seems an Evolution bug.

I'll try to upgrade to 2.10 whatever.

Z.

I remember now... see if you have this:

Edit -> Preferences -> Mail Accounts -> (Your Account) -> Receiving Options -> [X] Apply filters to new messages...

This is fantastic! Thanks!

it works well except i see the tags New mail from: ....

http://img410.imageshack.us/img410/3972/screenshotdq6.png

Fedora 7
Evolution 2.10.3
notify-python-0.1.0-4.fc7
python-2.5-12.fc7

Looks like they changed sth in the new version of libnotify... I have removed the tags from the title in my code.

is there support for other folders other than inbox? i have server side rules to automatically move e-mails to a specified folder so in evolution it doesn't get to the inbox at all.

very cool stuff, but I was wondering if there is code to add that may place the notification in a more reasonable area? Maybe x,y axis?

Thanks for you script notifier.py :)
Great little script, I will use it with mutt and procmail.
Here's a little tip - If you are using procmail add DISPLAY variable to .procmailrc you will avoid the message "GtkWarning: could not open display".
I'm using ubuntu on my desktop and set DISPLAY=:0.0 in .procmailrc. It works great!

This is great! I unfortunately don't know python, is there something that could be added to this script to make it play a sound file on the machine in the background when mail is received?

Thanks, again awesome work

There is actually a major bug in Evolution that makes it impossible for most installations to play a notification sound, so if there is a way to add a notification sound to the python script that would help a lot of people.

Hi Sawyer,

well, right now i'm back on macs, so can't really test it on linux, but there are about thousand and one ways to play audio files with python. i did some pygame before, so here's the pygame way of playing WAV files.

Install the pygame package, on ubuntu that's: apt-get install python-pygame

Put this in the head under "from sys imp....":
import pygame

Next put this under "n.show()":

pygame.init()
sound = pygame.mixer.Sound("/home/user/audio/tada.wav")
sound.play()
pygame.time.delay(5000) #5sec

Replace "/home/user/audio/tada.wav" with the full path to your *wav* file, and pay attention to the indentation, the 4 lines should have the same indent as the lines before. Also, the value 5000 means 5 seconds, if your file is longer and you want to hear the full length, you need to idle longer.

If you are lucky, you should have a working audio and popup notification :-)

Thank You!!
I have been looking for something like since a long time. I filtered all of my mails, and then the notification doesn't pop-up anymore. I had to check the evolution time after time. And I love evolution too much to switch to another mail client.

Leave a comment

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by Movable Type 4.24-en