[Thamesvalley-pm] calling all Perl newbies!

Richard Dawe rich at phekda.gotadsl.co.uk
Tue Aug 21 07:17:42 PDT 2007


Hello.

Greg Matthews wrote:
[snip]
> 2. We have a mailbox that users can send wrongly tagged spam mail to. 
> i.e. false positives. Users are asked to send these false positives as 
> an attachment in an attempt to keep all the header information intact. 
> At the moment I use mutt to read this mailbox and extract all the 
> correctly attached false postives to a mbox folder which I can then 
> eaily feed through spamassassin to train the Bayes database. The process 
> is scripted apart from the sorting the cruft from the genuine using my 
> own eyeballs and mutt. I did make an attempt to write something that 
> could recognise the correct attachments but it turned out to be much 
> harder then I expected. Translating what seems obvious to me while using 
> mutt into a robust, scripted algorithm proved too difficult.

Have you tried using the Email::* modules? They are a lot simpler to use
than some of the other modules I've seen. They are part of the Perl
Email Project (PEP) -- see:

http://emailproject.perl.org/wiki/Main_Page

PEP has a pretty friendly mailing list -- I'm sure they could give you
some tips on how to get started.

I started writing a GUI app to do mailing list management called
"subscripto" that uses the Email::* modules. Perhaps you could look at
its source, to see how to open up a mailbox and iterate over the
messages in it. The source is here (although it needs some time and love
spent on it, to be usable):

http://homepages.nildram.co.uk/~phekda/richdawe/subscripto/

Oh, and here's a code snippet from another program I wrote that builds a
list of Email::Simple objects for messages classified as spam by my
e-mail system. NB: I've changed the mail folder path.

use strict;
use warnings;

use Email::Folder;
use Email::Simple;

my $folder = Email::Folder->new('/path/to/a/thunderbird/mail/folder');

my @spams;
foreach ($folder->messages) {
    push(@spams, $_) if ($_->header('X-Spam-Status') =~ /^Yes,/);
}

HTH, bye, Rich =]

-- 
Richard Dawe [ http://homepages.nildram.co.uk/~phekda/richdawe/ ]

"You just amass stuff while you are alive. It's like stuff washed up
 on a beach somewhere, and that somewhere is you." -- Damien Hirst


More information about the Thamesvalley-pm mailing list