have: (zimbra + ad) + (openfire + ad + miranda +ntlm)
need: send a message to Jabber when i receive a new e-mail message.


in /opt/zimbra/postfix/conf/master.cf.in

change :
smtp inet n - n - - smtpd
to
smtp inet n - n - - smtpd
-o content_filter=filter:dummy

and add
filter unix - n n - 20 pipe
flags=Rq user=zimbra argv=/opt/zimbra/conf/script/filter.pl ${sender} ${recipient} ${user}


in /opt/zimbra/conf create dir script
and create file filter.pl

#!/usr/bin/perl
require "/opt/zimbra/conf/script/unit_ldap.pl";

$INSPECT_DIR='/opt/zimbra/store/incoming';
$SENDMAIL='/opt/zimbra/postfix-2.6.5.2z/sbin/sendmail -G -i';


$from=$ARGV[0];
$numArgs = $#ARGV;
my $jid,$jabber;
open(file,"> $INSPECT_DIR/in.$$");

while (<stdin>) {
print (file "$_");

}
close (file);

for ($i=1;$i<=$numArgs/2;$i++)
{
$to=$ARGV[$i];
$user=$ARGV[$i+$numArgs/2];
system "$SENDMAIL $to <$INSPECT_DIR/in.$$";

if (index($to,"abcmebel.ru")>0)
{
($jid,$jabber)=unit_ldap::get_jid_from_mail($to);
if ($jabber eq "yes")
{
system "/opt/zimbra/conf/script/sendmessage.php $jid \"You have new message from $from \n---mail server http://10.0.0.242---\"";
}
}
# system "logger \"script running from from= $from to=$to user=$user count =$numArgs jid=$jid, jabber=$jabber i=$i\"";


}

unlink "$INSPECT_DIR/in.$$" ;



and file unit_ldap.pl

package unit_ldap;
use Net::LDAP;
my $prefix="\@domain";


BEGIN {
#change it
$ldap = Net::LDAP->new("ldap-server");
$ldap->bind("username\@domain", password=>"passwd");

}


sub get_jid_from_mail{
my $mail=$_[0];
my $sAMAccountName,$info,$jabber;
# print "mail= $mail";
$mesg = $ldap->search(filter=>
"(&(objectclass=user)(!(userAccountControl:1.2.840 .113556.1.4.803:=2))(mail=$mail))",
base=>"dc=tcdon,dc=ru",
attrs=> ['sAMAccountName','info']);


@entries = $mesg->entries;
foreach $entry (@entries) {
$sAMAccountName=$entry->get_value('sAMAccountName');
# print " \n$sAMAccountName\n";
$info=$entry->get_value('info');
}
$info=~s/\r?\n/----/g;
@lines=split /----/,$info;
# ($par,$val)=split /:/,$a;
$jabber='';
foreach $arg (@lines)
{
($par,$val)=split /:/,$arg;
if ($par eq "jabber")
{
$jabber=$val;
}
}

if ($jabber ne "no")
{
$jabber="yes";
}
if (length($sAMAccountName)<1)
{
$jabber="no";
}
return "$sAMAccountName\@tcdon.ru",$jabber;

}


1;
END {
$ldap->unbind;
}



and add you script for sending message
for example xmpphp - Project Hosting on Google Code