Thursday, June 28, 2007

How to make simple mail notification using jabber (using jabber.class.php and procmail)

jabber.class.php - cjphp.netflint.net/
procmail
jabber server or acount on xmmp server ( i using it on non ssl connection, with ssl jabber.class.php crashed )
php cmd installed

Let's start :

First create files in your home directory like below:
.forward

| /usr/bin/procmail

.procmailrc
:0 c
| $HOME/mail2jabber.sh

mail2jabber.sh
#!/bin/bash
(cat - | formail -X From: -X Subject:
echo .
echo quit
) | /usr/bin/php mail2jabber.php

mail2jabber.php
require("class.jabber.php");
?>
$JABBER = new Jabber;
?>
$JABBER->server = "your server name ( example: chrome.pl)";
$JABBER->port = "5222";
$JABBER->username = "username";
$JABBER->password = "password";
$JABBER->resource = "ClassJabberPHP";
$JABBER->enable_logging = FALSE;
//$JABBER->log_filename = "logfile.txt";
?>
$JABBER->Connect() or die("Couldn't connect!");
$JABBER->SendAuth() or die("Couldn't authenticate!");
$JABBER->SendPresence(NULL, NULL, "online");
$JABBER->SendMessage("where send a message ex. adm@chrome.pl",
"normal",
NULL,
array( // body, thread... whatever
"body" => "You have a new messages on „email account name” ! log in and
check on "mail www interface" or use favourite mail client :) "
)
);
$JABBER->Disconnect();
?>

Then:
copy class.jabber.php
chmod 755 mail2jabber.sh


enjoy

No comments: