[Mimedefang] action_wrap_header

Mickey Hill mickey at rudolphtire.com
Wed Jan 23 11:09:47 EST 2002


Hi everyone,

David, you mentioned a wrap_header function, but I haven't found it in
the 2.3 release.  I needed such a function for my SpamAssassin report,
so here's what I wrote and added to mimedefang.pl.  It's pretty simple
(simple is good!) and it's working well for me.  If it's useful to you
or anyone else, you are welcome to it!

#***********************************************************************
# %PROCEDURE: action_wrap_header
# %ARGUMENTS:
#  header -- header name (eg: X-My-Header)
#  value -- header value (eg: any text goes here)
# %RETURNS:
#  Nothing
# %DESCRIPTION:
#  Makes a note for milter to add a multi-line header to the message.
#***********************************************************************
sub action_wrap_header {
    my($header, $value) = @_;
    my @values = reverse split(/\n/, $value);

    for (@values) { action_add_header($header, $_) }
}


In my mimedefang-filter, here's an excerpt from my filter_begin:

    my ($hits, $req, $names, $report) = spam_assassin_check();
    action_add_header("X-Spam-Score", "$hits, Required: $req");
    if ($hits > 0) {
        action_add_header("X-Spam-Tests", "$names");
        action_wrap_header("X-Spam-Report", "$report");
    }

All this gives me the following headers:

X-Spam-Score: 7.1, Required: 5
X-Spam-Tests: PURE_PROFIT,OPPORTUNITY
X-Spam-Report: 
X-Spam-Report: SPAM: ---- Start SpamAssassin results
X-Spam-Report: SPAM: 7.1 hits, 5 required;
X-Spam-Report: SPAM: *  4.0 -- BODY: /PURE PROFIT/
X-Spam-Report: SPAM: *  3.1 -- BODY: /OPPORTUNITY/
X-Spam-Report: SPAM: 
X-Spam-Report: SPAM: ---- End of SpamAssassin results

-------------------------
Mickey Hill
Rudolph's Inc
2021 Rob Mason Rd
PO Box 69
Murray KY 42071 USA
Phone (270) 753-0686 x124
Fax   (270) 753-0753
mickey at rudolphtire.com
www.rudolphtire.com





More information about the MIMEDefang mailing list