RealNitro's Blog

Archives for: March 2005

Mar 18
Mabber.py

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

cd mabber

to enter the created mabber directory. Execute the script for the first time with

chmod 700 mabber.py
./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 :

cd ..
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

and add:

PATH=$HOME/bin:usr/bin:/usr/local/bin
MAILDIR=$HOME/mail
DEFAULT=/var/mail/USERNAME
LOGFILE=$MAILDIR/from
LOCKFILE=$HOME/.lockmail

#mabber
:0 hc
| $HOME/mabber/mabber.py

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.

RealNitro EmailCodingPermalink
Mar 1
Php gotcha, mail, FOSDEM

It has been a while since I have posted here, for two reasons: I didn't have much to say, and last week was very busy. I did a rewrite of the gotcha php-code that is used for the Home I live in. It took me a while to decypher the old code (amazingly complex), and eventually it took me 4 evenings to finish the job. However, the gotcha that's going on atm still uses the old code. :-( There was no time to test the new version thorougly, and just before the start of the gotcha (22h. last sunday), I discovered a little bug too. But I'm looking at it from the bright side: now I have the opportunity to fine tune my code, check it for weaknesses in its security, add new features, maybe add a fully featured admin-page, give it some new html code... If anyone (that is: anyone I know and trust ;-) ) wants to see my code running, just let me know. Btw, does anyone know of a way to check if an e-mail that should have been sent with the php code has really been sent? I'm asking this because last sunday the old php code did not start at first (I had to try 3 times!), and apparently some people didn't receive their passwords (which sould have been sent with the php mail function). :-/

Two days ago (sunday) I went to FOSDEM. The overall 'experience' was better than had I expected it to be. None of the presentations I attended were too technical (except the one about nautilus ;-) ). The one I enjoyed the most was the one about FAI, followed closely by XFCE. I think I liked the one about FAI the most because we might use it in stead of Fedora Stateless. (the speaker was very good too)

There ya go. Not much more to say. I have a big, unpublished post here at this blog about 'mabber.py'. But I will not publish it before I tested the installation instructions, and I still need to choose a license (or invent one).

RealNitro EmailWebdesign, Linux, CodingPermalink

Categories

Who's Online?

  • Guest Users: 448

Misc

XML Feeds

What is RSS?