[Mailmunge] Fetching all Headers.

Dianne Skoll dianne at skollsoft.com
Mon Nov 11 21:08:12 EST 2024


On Mon, 11 Nov 2024 20:35:55 -0500
list--- via Mailmunge <mailmunge at lists.mailmunge.org> wrote:

> I resolved unfolding the headers so this approach works, but id still
> prefer a cleaner approach if possible.

I'm not sure what problem you're trying to solve.  MIME::Head let's you get
any header just as pulling it out of a hash would.

If you want a hash data structure, then you really need a hash of arrayrefs
to handle repeated headers like Received:

You can also open the file ./HEADERS for reading as documented at
https://mailmunge.org/docs/pod_mailmunge-protocol.php in the section
"FILE LAYOUT FOR THE SCAN COMMAND"; this file contains exactly one
header per line (wrapped headers are unwrapped) and you can easily add this
to a hash, something like this:

    my %headers;
    my $fp = IO::File->new($self->headers_file(), "r");
    while(my $line = $fp->getline()) {
        chomp($line);
        my($k, $v) = split(/\s*:\s*/, $line, $2);
        push(@{$headers{$k}}, $v);
     }
     $fp->close();

The $self is a Mailmunge::Filter object, since this is presumably being
called from a method thereof.

Regards,

Dianne.


More information about the Mailmunge mailing list