Basically I'm processing archived mail thru spamassassin in an attempt to weed out spam. In order to identify it as spam I will be adding a header to the spam. so when I use "re_write" I get back a Mail::SpamAssassin::Message but I then want to add my own header to the message.

f ($status->is_spam())
  {
     my $mail = message_from_string_or_arrayref($rewritten);
     #$mail->head->replace("X-Accept-Flag", "Spam");
     print "$filename is spam\n";
open (NEW_MESSAGE, ">$filename.new") || die ("Couldn't open message $filename
:$!\n");
     print NEW_MESSAGE $first;
     print NEW_MESSAGE $mail->get_pristine;
     close(NEW_MESSAGE);
     exit;
     # backup old msg
move ($filename, "$filename.backup") || die ("Couldn't move message $filename
:$!\n");
     # replace old with new
move ("$filename.new", "$filename") || die ("Couldn't replace message $filena
me:$!\n");
  } else {
     print "$filename is not spam\n";
  }

I know SpamAssassin will add it's own headers but I want to add my own in addition.

The rules my Mail client uses do not allow me to use regular expressions which is why I need a reliable string that identifies that the mail was in fact considered Spam.

On Jul 17, 2006, at 10:22 PM, Theo Van Dinter wrote:

On Mon, Jul 17, 2006 at 10:03:39PM -0500, Robert Nicholson wrote:
Also, if I have a Mail::SpamAssassin::Message and I want to replace a
header in the message do I have to do all this myself and reconstruct
a new message with the new header value?

From what I can tell this class retains header and body as scalars.

Can you be a little more specific about what you're trying to do?

Generally speaking, without mucking about manually, which I don't recommend, you can't modify the headers in the internal data structure. You can add and you can delete, but there's no modify function. There's also no way to modify the original headers on output, beyond adding in X-Spam-* headers. You can take the output from rewrite_mail() and modify it yourself (it's just a
scalar).

--
Randomly Generated Tagline:
Know a good chiropractor? My computer has a slipped disk.

Reply via email to