You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Andrew Xiang <xi...@gratingworks.com> on 2004/12/08 18:02:53 UTC

how to run SA3.0.1 on a existing mailbox

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?

thanks
Andrew


Re: how to run SA3.0.1 on a existing mailbox

Posted by Jim Maul <jm...@elih.org>.
William Stearns wrote:
> 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" <jm...@elih.org>
>>To: "Andrew Xiang" <xi...@gratingworks.com>
>>
>>>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
>

Thanks William, i knew someone would come up with this before i could :)

-Jim

Re: how to run SA3.0.1 on a existing mailbox

Posted by Theo Van Dinter <fe...@kluge.net>.
On Wed, Dec 08, 2004 at 12:40:04PM -0500, William Stearns wrote:
> 	...with something like the following:
> 
> ~/bin/reprocess-mailbox
> ---- snip ----
> nice formail -f -ds /usr/bin/spamc <"$1" >"$TmpFile"
> ---- snip ----

Ewww!  Ok, it's not bad if you want to pass things through spamd, but an
easier way is:

spamassassin --mbox $file > $file.out

-- 
Randomly Generated Tagline:
Give a man some fire and he'll be warm for a day.  Light a man on fire
 and he'll be warm for the rest of his life.

Re: how to run SA3.0.1 on a existing mailbox

Posted by Andrew Xiang <xi...@gratingworks.com>.
Bill,

This does not move spam into a new file. In fact, it moves all into a new
file.
I want to be able to move ONLY SPAM or ONLY HAM into a new file.

thanks
Andrew

----- Original Message ----- 
From: "William Stearns" <ws...@pobox.com>
To: "Andrew Xiang" <xi...@gratingworks.com>
Cc: "Jim Maul" <jm...@elih.org>; "ML-spamassassin-talk"
<us...@spamassassin.apache.org>; "William Stearns" <ws...@pobox.com>
Sent: Wednesday, December 08, 2004 12:40 PM
Subject: Re: how to run SA3.0.1 on a existing mailbox


> 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" <jm...@elih.org>
> > To: "Andrew Xiang" <xi...@gratingworks.com>
> >
> > > 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 <ws...@pobox.com>
> #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 (wstearns@pobox.com).  Mason, Buildkernel, freedups, p0f,
> rsync-backup, ssh-keyinstall, dns-check, more at:   http://www.stearns.org
> --------------------------------------------------------------------------
>


Re: how to run SA3.0.1 on a existing mailbox

Posted by Andrew Xiang <xi...@gratingworks.com>.
It seem to copy all the emails into the temp file. It does not remove spam
from the mbox.
The purpose is to remove all the spams inside mailbox.

-Andrew

----- Original Message ----- 
From: "William Stearns" <ws...@pobox.com>
To: "Andrew Xiang" <xi...@gratingworks.com>
Cc: "Jim Maul" <jm...@elih.org>; "ML-spamassassin-talk"
<us...@spamassassin.apache.org>; "William Stearns" <ws...@pobox.com>
Sent: Wednesday, December 08, 2004 12:40 PM
Subject: Re: how to run SA3.0.1 on a existing mailbox


> 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" <jm...@elih.org>
> > To: "Andrew Xiang" <xi...@gratingworks.com>
> >
> > > 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 <ws...@pobox.com>
> #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 (wstearns@pobox.com).  Mason, Buildkernel, freedups, p0f,
> rsync-backup, ssh-keyinstall, dns-check, more at:   http://www.stearns.org
> --------------------------------------------------------------------------
>


Re: how to run SA3.0.1 on a existing mailbox

Posted by William Stearns <ws...@pobox.com>.
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" <jm...@elih.org>
> To: "Andrew Xiang" <xi...@gratingworks.com>
> 
> > 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 <ws...@pobox.com> 
#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 (wstearns@pobox.com).  Mason, Buildkernel, freedups, p0f,
rsync-backup, ssh-keyinstall, dns-check, more at:   http://www.stearns.org
--------------------------------------------------------------------------

Re: how to run SA3.0.1 on a existing mailbox

Posted by Andrew Xiang <xi...@gratingworks.com>.
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" <jm...@elih.org>
To: "Andrew Xiang" <xi...@gratingworks.com>
Cc: <us...@spamassassin.apache.org>
Sent: Wednesday, December 08, 2004 12:21 PM
Subject: Re: how to run SA3.0.1 on a existing mailbox


> 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?
> >
> > thanks
> > Andrew
> >
> >
> >
>
> 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.
>
> -Jim
>


Re: how to run SA3.0.1 on a existing mailbox

Posted by Jim Maul <jm...@elih.org>.
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?
> 
> thanks
> Andrew
> 
> 
> 

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.

-Jim