Re: SpamAssassin integration missing Received: headers

Mark Overmeer <[email protected]> Wed, 16 Jun 2004 11:17:52 +0200
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Carlos Perez ([email protected]) [040615 17:41]:
> I found there was a bug in my previous code-- SpamAssassin apparently calls
> get_header expecting an array or scalar, based on looking at NoMailAudit.pm
> So here is the latest version (if I find additional bugs, I will e-mail you
> off-line).

Ah... SpamAssassin is not documented at all, and NoMailAudit is quite
horrible code... not really usable as docs.  But I see your point.
$field->unfoldedBody is already stripping some blanks and certainly
the new-lines: I expect that this is sufficient.

So... I think that the following method suffices:  (untested)

sub get_header($)
{   my ($self, $name) = @_;
    my $head = $self->get_mail_object->head;
                                                                                
    # Return all fields unfolded in list context
    return map { $_->unfoldedBody } $head->get($name)
        if wantarray;
                                                                                
    # Only one field is expected
    my $field = $head->get($name);
    defined $field ? $field->unfoldedBody : undef;
}

Correct?
-- 
Thanks for the report and the example solution.  That really helped.

               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net