[AMaViS-user] Executing a logging script from Amavis

This is a discussion on [AMaViS-user] Executing a logging script from Amavis within the Amavis User forums, part of the Anti-Spam and Anti-Virus Related Forums category; Hi all, At home I'm running Psotfix & Spamassassin to good effect. Using the simple shell script below, I ...


Go Back   Usenet Forums > Anti-Spam and Anti-Virus Related Forums > Amavis User

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2005
Nigel Gibbs
 
Posts: n/a
Default [AMaViS-user] Executing a logging script from Amavis


Hi all,

At home I'm running Psotfix & Spamassassin to good effect. Using the
simple shell script below, I log all emails along with their status in a
mysql database for later analysis/recovery.

I have configured a similar solution at work, but instead have
introduced Amavis and ClamAV too. Trouble is the postfix filter which
executes my script below doesn't seem to see everything, namely stuff
what amavis bins higher up in the filtering process. =20

Can anyone please tell me if there is a way to ensure that my script is
called for _every_ email which comes into the system, showing it's
status?

I had a hunch I could use it as an MTA in the Amavis config file, or am
I barking up the wrong tree?

Thanks in advance!


-Nigel


=3D-=3D-=3D-=3D-=3D-=3D-=3D--=3D-=3D=3D-

#!/bin/sh

INSPECT_DIR=3D/var/spool/filter
SENDMAIL=3D"/usr/sbin/sendmail -i"
SPAMASSASSIN=3D/usr/bin/spamassassin

# Exit codes from <sysexits.h>
EX_TEMPFAIL=3D75
EX_UNAVAILABLE=3D69
EX_OK=3D0
EX_SPAM=3D0

cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit
$EX_TEMPFAIL; }

# Clean up when done or when aborting.
trap "rm -f in.$$; rm -f out.$$" 0 1 2 3 15

cat | $SPAMASSASSIN > out.$$ || { echo Message content rejected; exit
$EX_UNAVAILABLE; }

MAILFROM=3D`grep -m 1 "^[Ff]rom:" out.$$ | cut -c7-`
MAILTO=3D`grep -m 1 "^[Tt]o:" out.$$ | cut -c5-`
MAILSCORE=3D`grep -m 1 X-Spam-Level out.$$ | cut -d' ' -f2`
MAILSCORE=3D`expr length "$MAILSCORE"`

# return of 1 by grep means not found, funnily enough.
IS_SPAM=3D`grep -m 1 "^X-Spam-Flag: YES" out.$$`
SPAMFLAG=3D$?
if [[ $SPAMFLAG =3D 1 ]]; then
SUBJECT=3D`grep -m 1 "^[Ss]ubject:" out.$$ | cut -c25-`
ACTION=3DAllowed
BODY=3D`cat out.$$ | gzip -f | uuencode -m /dev/stdout`
$SENDMAIL "$@" < out.$$
else
SUBJECT=3D`grep -m 1 "^[Ss]ubject:" out.$$ | cut -c25-`
ACTION=3DQuarantined
BODY=3D`cat out.$$ | gzip -f | uuencode -m /dev/stdout`
fi

mysql -u filteruser --password=3Dfilterpassword -D spamfilter -e "insert
into mail (mFrom,mTo,mSubject,mBody,mScore,mArrived,mClean,m Action)
values
('$MAILFROM','$MAILTO','$SUBJECT','$BODY',$MAILSCO RE,now(),$SPAMFLAG,'$A
CTION');"

exit 0


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/...fo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:49 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0