[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Sheflug] Re: Fun With Regexp
>>>>> "Richard" == Richard Ibbotson <richard [at] sheflug.co.uk> writes:
Richard> Baz and Alex Read through these again..
>> http://www.perl.com/pub/a/2001/07/17/mailfiltering.html
>> http://www.perl.com/pub/a/2002/03/06/spam.html
Richard> . I've got SpamAssassin installed under ~/home as a
Richard> .spamassassin file in a sub-directory. This does quite a
Richard> good job on catching and marking mail as *****SPAM*****.
Richard> But, it looks as though Mail::Audit will help it to do a
Richard> better job and provide greater functionality.
Richard> What I can't work out from Simon's pages is what to do to
Richard> put Mail::Audit into the mail server so that it works
Richard> under ~/home. I can see on my own local machine the
Richard> Mail::Audit software that I have compiled that I have the
Richard> following files and folders...
Richard> Audit.pm Makefile Makefile.PL pm_to_blib popread proc2ma
Richard> test.pl Audit [folder] blib [folder]
Richard> Should I create a new folder called .forward and put all
Richard> of the above into this ? Or, what should I do ? Also,
Richard> looking at Simon's pages once again I find that his
Richard> description of his filter rules has confused me. Perhaps
Richard> you can describe a filter to me ?
To save you configuring Perl's CPAN module, and get Mail::Audit and
Mail::SpamAssassin installed in double quick time do this:
Download Mail::Audit and Mail::SpamAssassin from CPAN
(http://search.cpan.org/).
mkdir /home/you/perl-lib/
tar -zxvf Mail::Audit-xxx.tar.gz
cd Mail::Audit-xxx
perl Makefile.pl PREFIX=/home/you/perl-lib/
make
make test
make install
cd ..
tar -zxvf Mail::SpamAssassin-xxx.tar.gz
cd Mail::SpamAssassin-xxx
perl Makefile.pl PREFIX=/home/you/perl-lib/
make
make test
make install
cd ..
You should now have a /home/you/perl-lib directory containing the two modules.
Here's a simple script that will filter ShefLUG mail to one folder,
spam to another, and anything else to mailbox.
#!/usr/bin/perl
use lib '/home/you/perl-lib/';
use Mail::Audit;
use Mail::SpamAssassin;
# Pattern match the To: header of mail to string "shef-lug"
if ($mail->to =~ /shef-lug/io) {
$mail->accept("/home/you/SHEFLUG-MAIL");
}
# Spam check.
if ( $status->is_spam() ) {
$status->rewrite_mail();
$mail->accept("/home/you/SPAM-MAIL");
}
# Everything else to mailbox.
$mail->accept("/home/you/mailbox");
exit 0;
# end
Save that script, and call it from your .forward
.forward is used by sendmail to decide what to do with email. (.qmail
has a similar file called .qmail).
The .forward file should just be an instruction to the MTA to pipe
mail through a script in this case in filter email:
(my .qmail/.forward file)
| /home/baz/spam_check.pl
Sorry I've not explained everything - need to get off the phoneline!
Cheers.
Baz.
--
Barrie J. Bremner
baz-sheflug [at] barriebremner.com http://barriebremner.com/
___________________________________________________________________
Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html
GNU the choice of a complete generation.