in reply to Re: getting headers from essage
in thread getting headers from essage

It will have the form

my $hashref = { From => [ 'Mark Smith <mark.smith@example.org>', ], To => [ join( ', ', '"Doe, John" <john.doe@example.org>', '"Roe, Jane" <jane.roe@example.org>', ), ], ... };

Replies are listed 'Best First'.
Re^3: getting headers from essage (Email::Address)
by LanX (Saint) on Dec 16, 2025 at 22:01 UTC
    Thanks, actually it can get much more complicated tho

    https://en.wikipedia.org/wiki/Email_address

    I think there should° be a module dedicated to parse a list of email addresses.

    Doing this manually smells like trying to parse HTML with a regex.

    UPDATE

    °) Yep, see Email::Address on CPAN (unexpected name ;-)

    my @addrs = Email::Address->parse( q[me@local, Casey <me@local>, "Casey" <me@local> (West)] );

    and from the description

    ACHTUNG! Email isn't easy (if even possible) to parse with a regex, at least if you're on a perl prior to 5.10.0. Providing regular expressions for use by other programs isn't a great idea,

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery