Good day, Andrew,

On Wed, 8 Dec 2004, Andrew Xiang wrote:

> But I have a whole mbox with 10,000 messages. How can I pipe all the
> messages and move them?
> 
> ----- Original Message ----- 
> From: "Jim Maul" <[EMAIL PROTECTED]>
> To: "Andrew Xiang" <[EMAIL PROTECTED]>
> 
> > Andrew Xiang wrote:
> > > I want to run spamassassin on my existing /var/mail/mymailbox and only
> move
> > > all the spam mail into /var/mail/spam .
> > >
> > > Is there   a way to do that?
> >
> > you could run spamassassin -e on the message and then make a quick
> > script to check the return status and move the messages accordingly.
> >
> >       -e, --exit-code                   Exit with a non-zero exit code
> > if the tested message was spam
> >
> > SA doesnt move anything on its own so you'd have to script it.

        ...with something like the following:

~/bin/reprocess-mailbox
---- snip ----

#!/bin/bash
#Copyright 2004 William Stearns <[EMAIL PROTECTED]> 
#Released under the GPL 

if [ -z "$1" ] || [ ! -r "$1" ]; then
        echo "Usage: $0 folder-to-reprocess"
        exit 1
fi

TmpFile=`mktemp -q "$1.XXXXXX"`
if [ $? -ne 0 ]; then
        echo "$0: Can't create temp file, exiting..."
        exit 1
fi

if [ ! -w "$TmpFile" ]; then
        echo "$TmpFile unwriteable, exiting"
        exit 1
fi

echo "working with $1 and $TmpFile"

nice formail -f -ds /usr/bin/spamc <"$1" >"$TmpFile"

echo "Processing done.  Please check $TmpFile"
---- snip ----

        This should be run on a mailbox that is _not_ actively recieving 
mail.  At the end, you'll need to rename the tmpfile back to the original 
file to keep the changes, and then start your mail flowing again.
        Cheers,
        - Bill

---------------------------------------------------------------------------
        "5) what are people like spaf/chris rouland/lance then?
a) THEY ARE THE ENEMY. WHITEHATS = ENEMY."
        -- http://www.blackhatbloc.org/phrack/texts/faq1.txt
--------------------------------------------------------------------------
William Stearns ([EMAIL PROTECTED]).  Mason, Buildkernel, freedups, p0f,
rsync-backup, ssh-keyinstall, dns-check, more at:   http://www.stearns.org
--------------------------------------------------------------------------

Reply via email to