# Email::MIME::Header::AddressList - MIME support for list of Email::Addr... - perldoc - [phpMan]

## NAME
    [Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown) - MIME support for list of [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown) objects

## VERSION
    version 1.953

## SYNOPSIS
      my $address1 = [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown)->new('Name1' => '<address1@host.com>');
      my $address2 = [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown)->new("Name2 \N{U+263A}" => '<address2@host.com>');
      my $mime_address = [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown)->new('=?UTF-8?B?TmFtZTIg4pi6?=' => '<address2@host.com>');

      my $list1 = [Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)->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](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)->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](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)->new_mime_groups('=?UTF-8?B?4pi6?=' => [ $mime_address ]);
      $list3->as_string();
      # returns '☺: "Name2 ☺" <<address2@host.com>>;'

      my $list4 = [Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)->from_string('Name1 <<address1@host.com>>, "Name2 ☺" <<address2@host.com>>, undisclosed-recipients:;');
      my $list5 = [Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)->from_string('Name1 <<address1@host.com>>', '"Name2 ☺" <<address2@host.com>>', 'undisclosed-recipients:;');

      my $list6 = [Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)->from_mime_string('Name1 <<address1@host.com>>, =?UTF-8?B?TmFtZTIg4pi6?= <<address2@host.com>>, undisclosed-recipients:;');
      my $list7 = [Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)->from_mime_string('Name1 <<address1@host.com>>', '=?UTF-8?B?TmFtZTIg4pi6?= <<address2@host.com>>', 'undisclosed-recipients:;');

## DESCRIPTION
    This module implements object representation for the list of the [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown) 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.

  EXPORT
    None

### Class Methods
    new_empty
        Construct new empty "[Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)" object.

    new Construct new "[Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)" object from list of [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown)
        objects.

    new_groups
        Construct new "[Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)" object from named groups of
        [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)" object from input string arguments. Calls
        [Email::Address::XS::parse_email_groups](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS%3A%3Aparseemailgroups/markdown).

    from_mime_string
        Like "from_string" but input string arguments are expected to be already MIME encoded.

### Object Methods
    as_string
        Returns string representation of "[Email::MIME::Header::AddressList](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME%3A%3AHeader%3A%3AAddressList/markdown)" object. Calls
        [Email::Address::XS::format_email_groups](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS%3A%3Aformatemailgroups/markdown).

    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](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS%3A%3Aformatemailgroups/markdown).

    first_address
        Returns first [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown) object.

    addresses
        Returns list of all [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown) objects.

    groups
        Like "addresses" but returns objects with named groups.

    append_addresses
        Append [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown) objects.

    append_groups
        Like "append_addresses" but arguments are pairs of name of group and array reference of
        [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown) objects.

## PERL VERSION
    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.

## SEE ALSO
    RFC 2047 <<https://tools.ietf.org/html/rfc2047>>, RFC 2822 <<https://tools.ietf.org/html/rfc2822>>,
    [Email::MIME](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AMIME/markdown), [Email::Address::XS](https://www.chedong.com/phpMan.php/perldoc/Email%3A%3AAddress%3A%3AXS/markdown)

## AUTHOR
    Pali <<pali@cpan.org>>

## AUTHORS
    *   Ricardo SIGNES <<cpan@semiotic.systems>>

    *   Casey West <<casey@geeknest.com>>

    *   Simon Cozens <<simon@cpan.org>>

## COPYRIGHT AND LICENSE
    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.

