[Mimedefang] SA Report position

Clayton, Nik [IT] nik.clayton at citigroup.com
Mon May 19 06:59:00 EDT 2003


> MIMEDefang appears to take the opposite approach by default - 
> in other words, the SA report gets tagged on the original 
> message as an attachment.
>  
> Is there an easy way to modify this behaviour so that we get 
> something more this basic SpamAssassin?

Yes.  This code is based on something that Michael Sims sent to the list
a few months ago.

my $wrapping_threshold = 5;   # Whatever SA score you want to start 
                              # wrapping messages at

sub filter_end {
    # Do the SpamAssassin checks as normal.  Put the results in $hits
    ...

    if($hits >= $wrapping_threshold) {
        # A container for the original message
        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
        $container->add_part($original);

        my $report = MIME::Entity->build(
                        Type            => 'text/plain',
                        Description     => 'spam warning',
                        Data            => [
"One or more lines of text go here\n",
"These will appear in the body of the message that's been wrapped\n",
"so put whatever you want your users to see here.\n",
"\n",
"Note that it's an array of \\n terminated lines.\n",
                                                ],
                );

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

        $entity->add_part($container);
        action_change_header('Subject', "[Spam?] ($hits): $Subject");
        action_rebuild();
    }
}

David, this is probably FAQ'able.  Alternatively, how about an 
action_wrap_message([ $ref_to_array_of_lines ]) function in a future
version of MD?

N
-- 
1        1         2         3         4         5         6         7    7
         0         0         0         0         0         0         0    5
                                                    -- The 75 column-ometer
Global Messaging,                 A: Top posting
120 Cheapside, x83331             Q: What's the most annoying e-mail habit?



More information about the MIMEDefang mailing list