Email::MIME::Header::AddressList - MIME support for list of Email::Address::XS
objects
my $address1 = Email::Address::XS->new('Name1' => 'address1@host.com');
my $address2 = Email::Address::XS->new("Name2 \N{U+263A}" => 'address2@host.com');
my $mime_address = Email::Address::XS->new('=?UTF-8?B?TmFtZTIg4pi6?=' => 'address2@host.com');
my $list1 = Email::MIME::Header::AddressList->new($address1, $address2);
$list1->append_groups('undisclosed-recipients' => []);
$list1->first_address();
# returns $address1
$list1->groups();
# returns (undef, [ $address1, $address2 ], 'undisclosed-recipients', [])
$list1->as_string();
# returns 'Name1 <address1@host.com>, "Name2 ☺" <address2@host.com>, undisclosed-recipients:;'
$list1->as_mime_string();
# returns 'Name1 <address1@host.com>, =?UTF-8?B?TmFtZTIg4pi6?= <address2@host.com>, undisclosed-recipients:;'
my $list2 = Email::MIME::Header::AddressList->new_groups(Group => [ $address1, $address2 ]);
$list2->append_addresses($address2);
$list2->addresses();
# returns ($address2, $address1, $address2)
$list2->groups();
# returns (undef, [ $address2 ], 'Group', [ $address1, $address2 ])
my $list3 = Email::MIME::Header::AddressList->new_mime_groups('=?UTF-8?B?4pi6?=' => [ $mime_address ]);
$list3->as_string();
# returns '☺: "Name2 ☺" <address2@host.com>;'
my $list4 = Email::MIME::Header::AddressList->from_string('Name1 <address1@host.com>, "Name2 ☺" <address2@host.com>, undisclosed-recipients:;');
my $list5 = Email::MIME::Header::AddressList->from_string('Name1 <address1@host.com>', '"Name2 ☺" <address2@host.com>', 'undisclosed-recipients:;');
my $list6 = Email::MIME::Header::AddressList->from_mime_string('Name1 <address1@host.com>, =?UTF-8?B?TmFtZTIg4pi6?= <address2@host.com>, undisclosed-recipients:;');
my $list7 = Email::MIME::Header::AddressList->from_mime_string('Name1 <address1@host.com>', '=?UTF-8?B?TmFtZTIg4pi6?= <address2@host.com>', 'undisclosed-recipients:;');
This module implements object representation for the list of the
Email::Address::XS objects. It provides methods for RFC 2047
<https://tools.ietf.org/html/rfc2047> MIME encoding and decoding
suitable for RFC 2822 <https://tools.ietf.org/html/rfc2822> address-list
structure.
- new_empty
- Construct new empty
"Email::MIME::Header::AddressList"
object.
- new
- Construct new
"Email::MIME::Header::AddressList"
object from list of Email::Address::XS objects.
- new_groups
- Construct new
"Email::MIME::Header::AddressList"
object from named groups of Email::Address::XS objects.
- new_mime_groups
- Like "new_groups" but in this method
group names and objects properties are expected to be already MIME
encoded, thus ASCII strings.
- from_string
- Construct new
"Email::MIME::Header::AddressList"
object from input string arguments. Calls
Email::Address::XS::parse_email_groups.
- from_mime_string
- Like "from_string" but input string
arguments are expected to be already MIME encoded.
- as_string
- Returns string representation of
"Email::MIME::Header::AddressList"
object. Calls Email::Address::XS::format_email_groups.
- as_mime_string
- Like "as_string" but output string will
be properly and unambiguously MIME encoded. MIME encoding is done before
calling Email::Address::XS::format_email_groups.
- first_address
- Returns first Email::Address::XS object.
- addresses
- Returns list of all Email::Address::XS objects.
- groups
- Like "addresses" but returns objects
with named groups.
- append_addresses
- Append Email::Address::XS objects.
- append_groups
- Like "append_addresses" but arguments
are pairs of name of group and array reference of Email::Address::XS
objects.
This library should run on perls released even a long time ago. It should work
on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is
made that the minimum required version will not be increased. The version
may be increased for any reason, and there is no promise that patches will
be accepted to lower the minimum required perl.
RFC 2047 <https://tools.ietf.org/html/rfc2047>, RFC 2822
<https://tools.ietf.org/html/rfc2822>, Email::MIME, Email::Address::XS
- Ricardo SIGNES <rjbs@semiotic.systems>
- Casey West <casey@geeknest.com>
- Simon Cozens <simon@cpan.org>
This software is copyright (c) 2004 by Simon Cozens and Casey West.
This is free software; you can redistribute it and/or modify it
under the same terms as the Perl 5 programming language system itself.