Jabber Mail Notification

February 20, 2009    hacking xmpp

I always struggled to find the right mail notification applet for my desktop. Furthermore I always stumble over the question: Why do I have to ask the mail server in a defined time interval “Do I have a new e-mail?”. Wouldn’t it be better if the mail server notifies me if a new e-mail arrives?

This is probably somehow a new form of the good old question “mailing list vs bulletin board” or in general: Do i have to fetch the information or does the information come to me? Personally i always preferred to get the information and not to hunt around for them.

Thinking about this question i realized that notification through Jabber would be perfect and the open XMPP protocol virtually invites one to do such things.

The idea was born. Now the first step was to find a easy to use XMPP implementation for a scripting language like Python, Ruby or PHP. At the end I found a quite nice and easy to use PHP library. While searching such a library I also found this guidance (German only), borrowed some code from it and my solution was born:

    $conn->message('me@jabber.server.org', $msg);
} catch(XMPPHP_Exception $e) {

Now I just had to tell procmail to pipe the mails through the PHP script. If you want to get notified about all mails you can simply put this line at the top of your procmail rules (Or maybe at least behind the spam filter rules 😉 ):

|php /home/schiessle/bin/mailnotification.php

I want to get notified only about some specific mails so I extended my procmail rules in this way:

* ^(To:|Cc:).*foo@bar-mailinglist.org
        |php /home/schiessle/bin/mailnotification.php


That’s it! All in all it was quite easy to get e-mail notification through Jabber. Now I don’t have to search for the right applet, configure it etc.. All I have to do is to start my Jabber client and I will get notified about new mails whatever desktop or computer i’m using.

Björn Schießle
Active in the Free Software movement for over 25 years.
Long-term volunteer at FSFE and member of the General Assembly.
Co-founder and PreSales-Lead of Nextcloud.