Front page | perl.pep |
Postings from August 2016
From: Ricardo Signes
August 23, 2016 02:26
Message ID: 20160823022609.GA25768@debian
* email@example.com [2016-08-18T17:35:10]
> On Thursday 18 August 2016 23:21:28 Ricardo Signes wrote:
> > As you say, 1 and 2 are dealt with. For 3 or 4, you want to have an
> > object in the header slot, rather than a string. Once you've done
> > that, you use its methods. If the object's To field stores a
> > string, you "upgrade" it with something like:
> > $email->header(To => mailbox_headers_from( $email->header('To') );
> > ...and it seems like one would quickly amass some sort of routine
> > like:
> > upgrade_headers($email);
> > ...that would upgrade all the headers it knows about.
> Can you describe (or write code) how you imagine that I get header
> "Original-Cc" in form of addresses in list of named groups from email
> which is stored in string scalar? I'm not sure that I understand how you
> mean it...
Here's a verbose form:
# Get an email.
my $email = get_some_email_mime();
# Get the header -- the (unfolded) raw bytes.
my $cc_hdr = $email->header_raw('Original-CC');
# parse it into an object
my $cc_obj = parse_mailboxes( $cc_obj );
# put that object into the header:
# get the raw mime-encoded bytes again:
my $cc_hdr2 = $email->header_raw('Original-CC');
# get a list of sub-object from the object's imaginary interface:
my @boxes = $email->header_obj('Original-CC')->boxes;