1 # Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 package PublicInbox::Address;
7 our @EXPORT_OK = qw(pairs);
10 grep { defined } map { $_->address() } parse_email_addresses($_[0])
14 grep { defined } map {
16 my $addr = $_->address;
17 $n = $_->user if defined($addr) && $n eq $addr;
19 } parse_email_addresses($_[0]);
22 sub xs_pairs { # for JMAP, RFC 8621 section 4.1.2.3
23 [ map { # LHS (name) may be undef
24 [ $_->phrase // $_->comment, $_->address ]
25 } parse_email_addresses($_[0]) ];
29 require Email::Address::XS;
30 Email::Address::XS->import(qw(parse_email_addresses));
31 *emails = \&xs_emails;
37 require PublicInbox::AddressPP;
38 *emails = \&PublicInbox::AddressPP::emails;
39 *names = \&PublicInbox::AddressPP::names;