{
    "mode": "perldoc",
    "parameter": "Mail::Address",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Mail%3A%3AAddress/json",
    "generated": "2026-06-10T06:02:00Z",
    "synopsis": "use Mail::Address;\nmy @addrs = Mail::Address->parse($line);\nforeach $addr (@addrs) {\nprint $addr->format,\"\\n\";\n}",
    "sections": {
        "NAME": {
            "content": "Mail::Address - parse mail addresses\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Mail::Address;\nmy @addrs = Mail::Address->parse($line);\n\nforeach $addr (@addrs) {\nprint $addr->format,\"\\n\";\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Mail::Address\" extracts and manipulates email addresses from a message header. It cannot be\nused to extract addresses from some random text. You can use this module to create RFC822\ncompliant fields.\n\nAlthough \"Mail::Address\" is a very popular subject for books, and is used in many applications,\nit does a very poor job on the more complex message fields. It does only handle simple address\nformats (which covers about 95% of what can be found). Problems are with\n\n*   no support for address groups, even not with the semi-colon as separator between addresses;\n\n*   limited support for escapes in phrases and comments. There are cases where it can get wrong;\nand\n\n*   you have to take care of most escaping when you create an address yourself: \"Mail::Address\"\ndoes not do that for you.\n\nOften requests are made to the maintainers of this code improve this situation, but this is not\na good idea, where it will break zillions of existing applications. If you wish for a fully\nRFC2822 compliant implementation you may take a look at Mail::Message::Field::Full, part of\nMailBox.\n\n. Example\n\nmy $s = Mail::Message::Field::Full->new($fromheader);\n# ref $s isa Mail::Message::Field::Addresses;\n\nmy @g = $s->groups;          # all groups, at least one\n# ref $g[0] isa Mail::Message::Field::AddrGroup;\nmy $ga = $g[0]->addresses;   # group addresses\n\nmy @a = $s->addresses;       # all addresses\n# ref $a[0] isa Mail::Message::Field::Address;\n",
            "subsections": []
        },
        "METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "Constructors",
                    "content": "Mail::Address->new( $phrase, $address, [ $comment ] )\nCreate a new \"Mail::Address\" object which represents an address with the elements given. In\na message these 3 elements would be seen like:\n\nPHRASE <ADDRESS> (COMMENT)\nADDRESS (COMMENT)\n\nexample:\n\nMail::Address->new(\"Perl5 Porters\", \"perl5-porters@africa.nicoh.com\");\n\n$obj->parse($line)\nParse the given line a return a list of extracted \"Mail::Address\" objects. The line would\nnormally be one taken from a To,Cc or Bcc line in a message\n\nexample:\n\nmy @addr = Mail::Address->parse($line);\n"
                },
                {
                    "name": "Accessors",
                    "content": "$obj->address()\nReturn the address part of the object.\n\n$obj->comment()\nReturn the comment part of the object\n\n$obj->format(@addresses)\nReturn a string representing the address in a suitable form to be placed on a \"To\", \"Cc\", or\n\"Bcc\" line of a message. This method is called on the first address to be used; other\nspecified addresses will be appended, separated by commas.\n\n$obj->phrase()\nReturn the phrase part of the object.\n"
                },
                {
                    "name": "Smart accessors",
                    "content": "$obj->host()\nReturn the address excluding the user id and '@'\n\n$obj->name()\nUsing the information contained within the object attempt to identify what the person or\ngroups name is.\n\nNote: This function tries to be smart with the \"phrase\" of the email address, which is\nprobably a very bad idea. Consider to use phrase() itself.\n\n$obj->user()\nReturn the address excluding the '@' and the mail domain\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance\nwithout commitment to further development.\n\nMail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>.\nMail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. For other contributors see\nChangeLog.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2017 Mark Overmeer\n<perl@overmeer.net>.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself. See http://www.perl.com/perl/misc/Artistic.html\n",
            "subsections": []
        }
    },
    "summary": "Mail::Address - parse mail addresses",
    "flags": [],
    "examples": [],
    "see_also": []
}