2010년 2월 3일 수요일

qmail 반송메일 제거

#!/usr/bin/perl

 

undef $/;

$inputdata = <STDIN>;
$/ = "\n";

 

$inputdata =~ /Subject: (.*)/;
$subject = $1;

 

$inputdata =~ /Received: from.*\(([0-9.]+)\)/;
$ip = $1;

 

$now_string = localtime;

 

open FH, ">>/var/log/qmail-remote.log";
flock(FH,2);

 

if ($subject =~ /(failure notice)/i)
{
        $inputdata =~ /(no mailbox here by that name)/i;

        if ($1 eq "no mailbox here by that name")
        {
                print FH "$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tDroped!!(NoUser) Subject:$subject\n";
                close FH;
                exit 2;
        }
        else
        {
                print FH "$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tSubject:$subject - Other\n";
                close FH;
        }
}
else
{
        print FH "$now_string\tIP:$ip\tTo:$ARGV[2]\tFrom:$ARGV[1]\tSubject:$subject\n";
        close FH;
}

 

open (MAIL, "| /var/qmail/bin/qmail-remote-org $ARGV[0] $ARGV[1] $ARGV[2]");
print {MAIL} $inputdata;
close MAIL;

댓글 없음:

댓글 쓰기