[Mimedefang] Logs of bounced messages

Dave Shepherd Dave.Shepherd at vixel.com
Tue Sep 3 12:32:01 EDT 2002


I suppose there are many way to skin a cat.

I like to have a separate logfile that I role nightly and have emailed to me via
cron job.

Perhaps Skoll can clean it up a bit and add with a command line startup switch
like filter_sender & filter_recipient ??

I added a sub to mimedefang-filter like this:

# from filter_end in the SA part
:
:
           if ($hits > 20) { # It's SPAM so bounce it
                $bounce = "yes";
                $recips = join(', ', @Recipients);

&filter_log($hits,$RelayHostname,$RelayAddr,$Sender,$Subject,$recips);
                syslog('err', 'Message seems to be spam, rejected');
                action_bounce("Message seems to be spam, rejected");
            }
:
:

#***********************************************************************
# New Sub filter_log added by Dave S. to log spam rejects
#***********************************************************************
sub filter_log {
    my ($hits, $host, $ip,$sender,$subject,$recipients) = @_;
    my $log="/etc/mail/SpamLogs/current.log";
    open(FILE, ">>$log");
        if($host =~ s/^\[//) {}
        if($host =~ s/\]$//) {}
        if($sender =~ s/^<?//) {}
        if($sender =~ s/>?$//) {}
        if($recipients =~ s/^<?//) {}
        if($recipients =~ s/>?$//) {}
        #print FILE "blacklist_from $host\nblacklist_from $ip\n";
        print FILE "**********************************************\n",
                scalar localtime,
                "\n$host\t$ip\n",
                "To: $recipients\n",
                "From: $sender\n",
                "Subject: $subject\n",
                "Hits: $hits\n";
    close(FILE);

} # End sub

The above sub writes a seperate logfile (current.log) that logs this crap.
Sample log data:

**********************************************
Tue Sep  3 09:22:08 2002
smarthost4.mail.uk.easynet.net  212.135.6.14
To: jbw1 at vixel.com
From: ias1a2s at dreamwiz.com
Subject: Non Smoker & Smoker Insurance for Pennies a Day
Hits: 26.4
**********************************************
Tue Sep  3 09:22:18 2002
ip-87-133.evc.net       212.95.87.133
To: fedora at vixel.com
From: ias1a2s at dreamwiz.com
Subject: Non Smoker & Smoker Insurance for Pennies a Day
Hits: 25.1
**********************************************
Tue Sep  3 09:22:52 2002
c14841.catch.sdsl.no    217.8.148.41
To: pwal at vixel.com
From: 1q1mailbot5 at altavista.se
Subject: Life Insurance For Pennies a Day.
Hits: 25.1

Then a simple sh script called nightly from cron:
rolelogs.sh

#!/usr/bin/sh
DATE=`/usr/bin/date "+%b %d"`
cd /etc/mail/SpamLogs

if [ -f spamlog.3 ]; then
   /usr/bin/rm -R spamlog.3
fi

if [ -f spamlog.2 ]; then
   mv spamlog.2 spamlog.3
fi

if [ -f spamlog.1 ]; then
   mv spamlog.1 spamlog.2
fi

if [ -f spamlog.0 ]; then
   mv spamlog.0 spamlog.1
fi

if [ -f current.log ]; then
   mv current.log spamlog.0
fi

touch current.log
chmod 666 current.log
/usr/bin/mailx -s "Spam Reject log for $DATE" postmaster at vixel.com < ./spamlog.0


Dave S.


tasdevil at newsguy.com wrote:

> Hi, I got spam assassin bouncing messages now if its more than 10 points -
> thank you to those who helped me.
>
> Is it possible to log the info so I can get a list of what messages were sent
> to each user and from whom?
> The maillog file produced from sendmail shows who sent it but not for whom the
> message was intended.
>
> thank you
>
> _______________________________________________
> MIMEDefang mailing list
> MIMEDefang at lists.roaringpenguin.com
> http://lists.roaringpenguin.com/mailman/listinfo/mimedefang




More information about the MIMEDefang mailing list