MailBox Question re parsing From, To, CC addresses
Ed Greenberg <[email protected]> Sun, 19 Sep 2004 09:56:30 -0700
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <D12A39BE2299C3092D9B1168@[10.100.2.13]> |
Hi folks,
When I get an address, as in:
my @from = $msg->head->get('from');
and then $from = $from[0];
I find that $from contains something like:
First Last <[email protected]>
I need to parse out the various pieces of this. I could do it myself, but I
can't believe that there isn't a way to do it using MailBox methods.
When I try this, I came up with:
my $addr = Mail::Message::Field::Address->parse($from);
print $addr->address,$/;
but I get errors like:
ERROR: Cannot coerce a Mail::Message::Field::Unstructured into a
Mail::Message:Field::Address
So I need to get a more structured object back, rather than a string.
What's the method that will return To, From, and Cc addresses as objects
suitable for parsing?
Or am I going about this all wrong?
Thanks,
</edg>