Angel Gabriel wrote:
Is it possible to have the attachemt only, piped into sa-learn ?

I've set up an account called spam that has the foillowing .procmailrc:


:0: spam.lock
|/home/spam/process_spam.pl

and the file /home/spam/process_spam.pl contains:

--------------cut------------------
#!/usr/bin/perl

use MIME::Parser;

#-
# dump_entity
#-
sub dump_entity
{
  my $ent = shift;
  my @parts = $ent->parts;

foreach my $p (@parts)
{
$body = $p->bodyhandle;
$head = $p->head;
$t = $head->mime_type;
if($t eq "message/rfc822")
{
open LEARN, "|/usr/bin/sa-learn --spam --single >>/home/spam/spam.log" or die "can't make open to sa-learn";
$body->print(\*LEARN);
close LEARN;
}
}


}


#------------------------------------------------------------ # main #------------------------------------------------------------ sub main { my $parser = new MIME::Parser;

  $parser->output_to_core(1);
  $parser->extract_nested_messages(0);

  $entity = $parser->read(\*STDIN) or
      die "Couldn't parse MIME from standard input\n";

  $s = $entity->head->get('Subject', 0);
  chomp($s);
  $f = $entity->head->get('From', 0);
  chomp($f);
  $d = $entity->head->get('Date', 0);
  chomp($d);

  open LOG, ">>/home/spam/spam.log";
  print LOG "Subject is: $s from $f at $d\n";
  close LOG;


dump_entity($entity) if $entity;



}


&main;

exit 0;
-------------------cut------------------

Users simply have to forward the spam
as an attachment to this address, and
the forwarding envelope is removed
before the mail is passed to sa-learn.

You'll need to get MIME::Parser from
CPAN to get this to work.

Maybe one should make a lot of postings
to newsgroups using this email address
so that the spammers feed directly into
sa-learn :-)

Mogens


-- Mogens Kjaer, Carlsberg A/S, Computer Department Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark Phone: +45 33 27 53 25, Fax: +45 33 27 47 08 Email: [EMAIL PROTECTED] Homepage: http://www.crc.dk



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to