Mail/Jabber/Bash/Perl: New mail notifications via jabber


Based on an earlier post, the following is a solution to get jabber notifications for new mails.
We do this using a cronjob, but don’t worry, system administrator, it does take minimal resources.

This is dedicated to users of stud3/stud4, but will work on any server you have ssh access to.
jabber-mail-notifications

HOWTO:
1: Get the sources here and extract them. jbiff.tar (gz, 152 KB) (tar.gz archive)
There is a perl script (jabbersend.pl) with the needed modules for sending jabber messages.
Also there is a bash script (jbiff.sh) that checks if the inbox changed and calls the perl script accordingly.
Modify the line

"perl jabbersend.pl jabber.ccc.de username="J13R" password="mybottybot"
to="buchner.johannes@amessage.at" "body=$a | $b | $c"

to your needs. You probably don’t want me to receive your mails notifications. I don’t mind if you use my bot (J13R) as sender, otherwise just enter your jabber account details there.

2: Copy them to a folder in your home directory on the server. ~/test for example.
You can should test the functionality by calling “bash jbiff.sh”. It will create a .oldstatus file to not send the same notification twice.

3: add it to your crontab


export EDITOR="pico" # You probably don't want to use vi on a HP machine
crontab -e # edit the crontab and add the following line:
* * * * * cd test/; bash jbiff.sh

Watch out: Failing cronjobs will send you a error report by mail which could create a infinite loop. You can clear/remove your crontab with “crontab -r”.

Also, this script only detects that something changed and will output the last message in your mailbox, so don’t wonder if you move/delete messages.

Wanted features: I would like the messages to contain newlines (couldn’t find how to do that).

  1. No comments yet.
(will not be published)

  1. No trackbacks yet.