develooper Front page | perl.pep | Postings from August 2016

Re: Email::Address::XS

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
August 23, 2016 02:26
Subject:
Re: Email::Address::XS
Message ID:
20160823022609.GA25768@debian
* pali@cpan.org [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:
  $email->header_set('Original-CC', $cc_obj);

  # 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;

-- 
rjbs

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About