{
    "mode": "perldoc",
    "parameter": "Mail::Message::Field::AddrGroup",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Mail%3A%3AMessage%3A%3AField%3A%3AAddrGroup/json",
    "generated": "2026-06-10T13:45:57Z",
    "synopsis": "my $g = Mail::Message::Field::AddrGroup->new(name => 'name');\nmy $a = Mail::Message::Field::Address->new(...);\n$g->addAddress($a);\nmy $f = Mail::Message::Field::Addresses->new;\n$f->addGroup($g);",
    "sections": {
        "NAME": {
            "content": "Mail::Message::Field::AddrGroup - A group of Mail::Message::Field::Address objects\n",
            "subsections": []
        },
        "INHERITANCE": {
            "content": "Mail::Message::Field::AddrGroup\nis a User::Identity::Collection::Emails\nis a User::Identity::Collection\nis a User::Identity::Item\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "my $g = Mail::Message::Field::AddrGroup->new(name => 'name');\n\nmy $a = Mail::Message::Field::Address->new(...);\n$g->addAddress($a);\n\nmy $f = Mail::Message::Field::Addresses->new;\n$f->addGroup($g);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "An address group collects a set of e-mail addresses (in this case they are\nMail::Message::Field::Address objects).\n\nExtends \"DESCRIPTION\" in User::Identity::Collection::Emails.\n",
            "subsections": []
        },
        "OVERLOADED": {
            "content": "Extends \"OVERLOADED\" in User::Identity::Collection::Emails.\n\noverload: @{}\nInherited, see \"OVERLOADED\" in User::Identity::Collection\n\noverload: stringification\nReturns the string() value.\n\noverload: stringification\nInherited, see \"OVERLOADED\" in User::Identity::Collection\n",
            "subsections": []
        },
        "METHODS": {
            "content": "Extends \"METHODS\" in User::Identity::Collection::Emails.\n\n$obj->string()\nReturns the address group as string. When no name is specified, it will only be a comma\nseparated list of addresses. With a name, the groups name will be prepended and a semi-colon\nappended. When no addresses where included and there is no name, then \"undef\" is returned.\n",
            "subsections": [
                {
                    "name": "Constructors",
                    "content": "Extends \"Constructors\" in User::Identity::Collection::Emails.\n\n$obj->coerce($object)\nCoerce an $object into a Mail::Message::Field::AddrGroup. Currently, you can only coerce\nUser::Identity::Collection::Emails (which is the base class for this one) into this one.\n\nMail::Message::Field::AddrGroup->new( [$name], %options )\nInherited, see \"Constructors\" in User::Identity::Collection::Emails\n"
                },
                {
                    "name": "Attributes",
                    "content": "Extends \"Attributes\" in User::Identity::Collection::Emails.\n\n$obj->description()\nInherited, see \"Attributes\" in User::Identity::Item\n\n$obj->itemType()\nInherited, see \"Attributes\" in User::Identity::Collection\n\n$obj->name( [$newname] )\nInherited, see \"Attributes\" in User::Identity::Item\n\n$obj->roles()\nInherited, see \"Attributes\" in User::Identity::Collection\n"
                },
                {
                    "name": "Collections",
                    "content": "Extends \"Collections\" in User::Identity::Collection::Emails.\n\n$obj->add($collection, $role)\nInherited, see \"Collections\" in User::Identity::Item\n\n$obj->addCollection( $object | <[$type], %options> )\nInherited, see \"Collections\" in User::Identity::Item\n\n$obj->collection($name)\nInherited, see \"Collections\" in User::Identity::Item\n\n$obj->parent( [$parent] )\nInherited, see \"Collections\" in User::Identity::Item\n\n$obj->removeCollection($object|$name)\nInherited, see \"Collections\" in User::Identity::Item\n\n$obj->type()\nMail::Message::Field::AddrGroup->type()\nInherited, see \"Collections\" in User::Identity::Item\n\n$obj->user()\nInherited, see \"Collections\" in User::Identity::Item\n"
                },
                {
                    "name": "Maintaining roles",
                    "content": "Extends \"Maintaining roles\" in User::Identity::Collection::Emails.\n\n$obj->addRole($role| <[$name],%options> | ARRAY)\nInherited, see \"Maintaining roles\" in User::Identity::Collection\n\n$obj->removeRole($role|$name)\nInherited, see \"Maintaining roles\" in User::Identity::Collection\n\n$obj->renameRole( <$role|$oldname>, $newname )\nInherited, see \"Maintaining roles\" in User::Identity::Collection\n\n$obj->sorted()\nInherited, see \"Maintaining roles\" in User::Identity::Collection\n"
                },
                {
                    "name": "Searching",
                    "content": "Extends \"Searching\" in User::Identity::Collection::Emails.\n\n$obj->find($name|CODE|undef)\nInherited, see \"Searching\" in User::Identity::Collection\n"
                },
                {
                    "name": "Addresses",
                    "content": "$obj->addAddress(STRING|$address|%options)\nAdd one e-mail address to the list which is maintained in the group. This is a wrapper\naround addRole() adding flexibility on how addresses are specified. An $address can be\nanything which is acceptable for Mail::Message::Field::Address::coerce() or a list of\noptions which will create such an object.\n\nexample: of adding an address to an address group\n\nmy @data = (fullname => \"Myself\", address => 'me@tux.org');\n$group->addAddress(@data);\n\nmy $addr = Mail::Message::Field::Address->new(@data);\n$group->addAddress(@data);\n\nmy $ma = Mail::Address->new(...);\n$group->addAddress($ma);\n\n$obj->addresses()\nReturns all addresses defined in this group. The addresses will be ordered alphabetically to\nmake automated testing possible: roles are stored in a hash, so have an unpredictable order\nby default.\n\nexample: getting all addresses from a group\n\nmy @addrs = $group->addresses;\nmy @addrs = map { $->address } $self->roles; #same\n"
                },
                {
                    "name": "Error handling",
                    "content": ""
                }
            ]
        },
        "DIAGNOSTICS": {
            "content": "Error: $object is not a collection.\nThe first argument is an object, but not of a class which extends\nUser::Identity::Collection.\n\nError: Cannot coerce a $type into a Mail::Message::Field::AddrGroup\nError: Cannot create a $type to add this to my collection.\nSome options are specified to create a $type object, which is native to this collection.\nHowever, for some reason this failed.\n\nError: Cannot load collection module for $type ($class).\nEither the specified $type does not exist, or that module named $class returns compilation\nerrors. If the type as specified in the warning is not the name of a package, you specified\na nickname which was not defined. Maybe you forgot the 'require' the package which defines\nthe nickname.\n\nError: Cannot rename $name into $newname: already exists\nError: Cannot rename $name into $newname: doesn't exist\nError: Creation of a collection via $class failed.\nThe $class did compile, but it was not possible to create an object of that class using the\noptions you specified.\n\nError: Don't know what type of collection you want to add.\nIf you add a collection, it must either by a collection object or a list of options which\ncan be used to create a collection object. In the latter case, the type of collection must\nbe specified.\n\nWarning: No collection $name\nThe collection with $name does not exist and can not be created.\n\nError: Wrong type of role for $collection: requires a $expect but got a $type\nEach $collection groups sets of roles of one specific type ($expect). You cannot add objects\nof a different $type.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "This module is part of Mail-Message distribution version 3.012, built on February 11, 2022.\nWebsite: http://perl.overmeer.net/CPAN/\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself. See http://dev.perl.org/licenses/\n",
            "subsections": []
        }
    },
    "summary": "Mail::Message::Field::AddrGroup - A group of Mail::Message::Field::Address objects",
    "flags": [],
    "examples": [],
    "see_also": []
}