python newbie, linux novice, needs to run spamassassin

G

Gates Danderhoff

The frustrating thing about running linux is that every time you look for
an example using a search engine, the guy writing it expects you to know
10 other utilities.

I have a very simple request regarding spamassain: I just need an example
of how to run it once you have downloaded one or more emails into a
folder.

I have a python script which runs poplib and is downloading emails into a
folder, say ~/mymailin.

Each time the script is run and emails have been downloaded into the
folder, I would like to run spamassassin to read through the emails in the
folder and check them for their spamminess and if they are spammy, it
should do whatever spamassassin does: add a header and move it to another
folder, say ~/myspam, or maybe ~/mygoodemail if it's not spammy?

There must be a simple spamassassin command that will do this, that I can
add to the python script and run using the cmdline.... facility, but, as
I say, all the examples I've seen have something to do with running
spamassassin with procmail, fetchmail, qmail and God knows what else.

Some day I'll learn all about procmail, but, for now, I like my little
python poplib script, and a simple spamassassin example should do the
trick.

Thank you for any help.
 
L

Lonnie Princehouse

I don't know spamassassin's exact set up, but usually procmail spam
filters read an email message from standard input and produce an exit
code that tells you if the message is spam or not.

So from the Python side, it should be as easy as running whatever the
command is (a quick googling suggests it is "sa-filter"), feeding it
the message on stdin, and capturing the exit code. Have a look at
Python's os.system, os.popen2, or os.popen3 fuctions. It may also be
the case that the filter emits a modified version of the email on
stdout containing spam-filter related headers.

Also, I'd recommend spambayes above spamassassin. Spambayes is a
statistical approach as opposed to Spamassassin's rule-based system*,
and for bonus point's it's written in Python.



* at this point someone will probably chime in saying it's possible to
rig spamassassin with a bayesian filter... probably so. I haven't
looked at it in years.
 
D

David Dorward

Lonnie said:
* at this point someone will probably chime in saying it's possible to
rig spamassassin with a bayesian filter

It is on by default AFAIK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top