[8426] in SIPB bug reports
spam-inc for Ask SIPB column
daemon@ATHENA.MIT.EDU (Richard Tibbetts)
Thu Mar 13 01:34:19 2003
Date: Thu, 13 Mar 2003 01:34:17 -0500
From: Richard Tibbetts <tibbetts@MIT.EDU>
To: bug-sipb@mit.edu, sipb-tech-column@mit.edu
Mail-Followup-To: bug-sipb@mit.edu, sipb-tech-column@mit.edu
I have just made steps towards installing spam-inc in the sipb locker.
spam-inc has the goal of being a drop in inc replacement for mh users
who wish to refile their spam into mh folders. You can see the column
at http://www.mit.edu/~asksipb/2003columns/2003-03-14-spamassassin/
The relevant question is the last one.
This script has grown a great deal since 5pm today. I think it is
stabilizing around a reasonable set of features. However, it still has
bugs. I would like to ask the help of people here to iron them out. Until
I am happier with it, the links in the various binary directories end up
pointing to a script that just prints a message.
I am including the script in this mail, to get some more eyeballs on
it. The script is installed and available for editing at
/mit/sipb/share/spam-inc/spam-inc.real. You will have to edit the
read-write version, of course. Please use RCS. Thanks for your time.
Richard
#!/bin/sh
# $Id: spam-inc.real,v 1.2 2003/03/13 06:24:36 tibbetts Exp $
# Originally written 03/13/2003 for the Ask SIPB column in the tech.
# Bugs to bug-sipb@mit.edu, Questions to sipb@mit.edu
# KNOWN BUGS
# - incing to non-inbox doesn't work
# - incing to non existant folder doesn't work
# - there are some quoting issues.
# - because it scans the messages before refiling, the numbers
# listed won't be the ones in the spamfolder.
#
# add any more bugs you find, if you don't have time to fix them.
# Settings
SPAMFOLDER=${SPAMFOLDER-"spamfolder"} # Folder to put spam in
QUOTATHRESH=${QUOTATHRESH-"10"} # Threshold for quota warning,
# in megabytes.
# Find the mailbox, if any. Will have the + sign.
MAILBOX=`echo $@ | xargs -n 1 | grep '^+'`
# Find the last current message. Calculate the new first message.
OLDLAST=`pick last $MAILBOX`
NEWFIRST=`expr $OLDLAST + 1`
# Incorporate new mail using whatever arguments were specified.
if inc -silent "$@"; then
# Mark all the new messages as part of the unscreened sequence
mark -zero $NEWFIRST-last -sequence unscreened
# Pickout unscreened messages that have the spam flag.
if (pick unscreened -sequence spams --x-spam-flag YES 2>/dev/null); then
echo "Refiling spam:"
# Show the spams subject lines and put them in the spam folder.
scan spams;
refile "+$SPAMFOLDER" spams
echo
fi
# Display the remaining messages in the unscreened sequence, if any
if (pick unscreened 2>/dev/null >/dev/null); then
echo "Non-spam mail:"
scan unscreened
fi
else
exit
fi
# Check to see if the user is using a lot of quota
USAGE=`du -sk "$HOME/Mail/$SPAMFOLDER/" |
awk '{print int(\$1/1024)}'`
if [ $USAGE -ge $QUOTATHRESH ]; then
echo
echo You have $USAGE megabytes of spam in your spamfolder. To delete
echo some of it, change to your spamfolder and delete some messages.
echo For example:
echo
echo " athena% scan +$SPAMFOLDER"
echo " athena% rmm 1-400"
echo
echo You should use an appropriate range of message numbers, of course,
echo and make sure that the mail you delete is all spam.
fi