Some time ago, I wrote a small python script that notified me with a jabber message whenever a new e-mail has arrived on my UGent-account. I already was using a similar script, but I wanted to create one myself. And now it's time to publish it. :-)
What does it do: it notifies you with a jabber message when a new e-mail has arived
What do I need: a jabber account for yourself and for the bot, access to procmail filters, python support on the procmail server, a jabber client and my scipt.
How: first, a procmail filter forwards the e-mail headers to mabber.py. Mabber analyses the headers, extracts the needed info and formats it. Then, using xmpppy and a dummy jabber-account, a the little bot pops online and sends you a 'headline' message.
Where do I get it: download mabber.py here
Note: similar scripts/progs exist in Perl and Java.
How to set it up on eduserv:
1) Download the mabber.tar.gz file to your computer. Use an SCP client (like WinSCP on windows) to log in on eduserv with your own login and password. Make sure the right side is selected and upload the mabber.tar.gz file to your home-directory.
2) Using an SSH client (like Putty for windows), log on to eduserv again. First, the mabber.tar.gz file has to be extracted. To do this, enter:
tar xvpfz mabber.tar.gz
The console should output a list of extracted files. Now enter the command
to enter the created mabber directory. Execute the script for the first time with
chmod 700 mabber.py
It will tell you there was no configfile found, and a dummy-one was created. To adjust this dummy file, go back to the previous directory and open the dummy file :
pico -w .mabber
Change the values for 'jid', 'password' and 'tojid' to the JID of your bot, its password and your own JID respectively. Remove the '#' in front of 'jid', 'password' and 'tojid', save with 'CTRL+O' and exit with 'CTRL+X'.
Note:In order to keep your password hidden from other users, mabber.py creates your file with '600' permissions (only you are able to read it and adjust it). If you descide to create the file yourself, do not forget to execute
chmod 600 .mabber
3) Now its time to add a procmail filter. More info here. First execute (while still in the folder of .mabber -- your home folder)
pico -w .forward
In this file, add one line:
"|IFS=' '&&exec /usr/local/bin/procmail -f-||exit 75 #USERNAME"
in which you change USERNAME to your own username. Save with 'CTRL+O', exit with 'CTRL+X'. Now its time to define the filter. Again we use pico to create/adjust a text file:
pico -w .procmailrc
Again, change USERNAME into your own username, save with 'CTRL+O' and exit with 'CTRL+X'.
That's it! Try sending yourself an e-mail. A few seconds later (could be half a minute) you should receive a jabber-message containing the sender, the subject and the date. Be sure to check if you really received the mail. If not, doublecheck your .procmailrc file! If you have any questions about the installation or use of this file, feel free to comment. I'll answer asap.