> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of David Turgeon
> 
> I was wanting to change the default functionality of SpamAssassin to
> have it forward the original message as an attachment.  I think I
> managed to do this by reading the INPUTMSG file storing it in 
> a variable
> and adding it as a mime_part.  I then wanted to change the original
> message so that the data wouldn't be displayed but a report on the
> ratings as spam.  I tried doing the by calling the 
> replace_with_warning
> method, it failed with error 0 as I was calling it from the filter.
> There are obviously easy ways to change the headers from the 
> filter, my
> question is there an easy way to change the body from the filter?

What I have, is this, in filter_end:

# Record who it was for
action_add_header("X-Orig-Rcpts", join(", ", @Recipients));

# Remove oroginal recipients
foreach $recip (@Recipients) {
        delete_recipient($recip);
        }

# Send to the postmaster
add_recipient('[EMAIL PROTECTED]');

# A container for the original message
my $raw_container = MIME::Entity->build(
        Type            => 'text/plain',
        Description     => 'Raw message',
        Data            => [ "" ],
        );

my $container = MIME::Entity->build(
        Type            => 'message/rfc822',
        Description     => 'Original message',
        Data            => [ "" ],
        );

my $parser = new MIME::Parser;
open(IN, '< INPUTMSG');
my $original = $parser->parse(\*IN);
close(IN);

$original->head()->replace('X-Relay-Addr', $RelayAddr);
$RelayHostname ||= 'N/A';
$original->head()->replace('X-Relay-Host', $RelayHostname);
$original->head()->replace('X-Relay-Time', scalar(localtime));

# Add the original message to the container
$raw_container->add_part($original);
$container->add_part($original);

my $reportPart = MIME::Entity->build(
        Type            => 'text/plain',
        Description     => 'spam warning',
        Data            => [
        $report
        ],
        );

$entity->parts([$reportPart]);
$entity->head()->mime_attr('content-type' => 'multipart/mixed');
$entity->head()->mime_attr('content-type.boundary'
=> '------------=_' . scalar(time) .
"-$$-nikc");

$entity->add_part($raw_container);
$entity->add_part($container);
action_change_header('Subject', "SPAM ($hits): $Subject");
action_change_header("X-Spam-Score", "$hits ($score) $names");
action_rebuild();


That adds a pair of attachments, one as the original email message, one as
plain text (to make spam reporting easy) and makes the body the actual SA
report.


PLEASE - keep list traffic on the list.  Email sent directly to me may be
ignored utterly.

-- 
Rob | What part of "no" was it you didn't understand? 
_______________________________________________
Visit http://www.mimedefang.org and http://www.canit.ca
MIMEDefang mailing list
[EMAIL PROTECTED]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to