1Mail::Address(3)      User Contributed Perl Documentation     Mail::Address(3)
2
3
4

NAME

6       Mail::Address - Parse mail addresses
7

SYNOPSIS

9        use Mail::Address;
10        my @addrs = Mail::Address->parse($line);
11
12        foreach $addr (@addrs) {
13            print $addr->format,"\n";
14        }
15

DESCRIPTION

17       "Mail::Address" extracts and manipulates email addresses from a message
18       header.  It cannot be used to extract addresses from some random text.
19       You can use this module to create RFC822 compliant fields.
20
21       Although "Mail::Address" is a very popular subject for books, and is
22       used in many applications, it does a very poor job on the more complex
23       message fields.  It does only handle simple address formats (which
24       covers about 95% of what can be found). Problems are with
25
26       ·   no support for address groups, even not with the semi-colon as
27           separator between addresses;
28
29       ·   limitted support for escapes in phrases and comments.  There are
30           cases where it can get wrong; and
31
32       ·   you have to take care of most escaping when you create an address
33           yourself: "Mail::Address" does not do that for you.
34
35       Often requests are made to the maintainers of this code improve this
36       situation, but this is not a good idea, where it will break zillions of
37       existing applications.  If you wish for a fully RFC2822 compliant
38       implementation you may take a look at Mail::Message::Field::Full, part
39       of MailBox.
40
41       example:
42
43         my $s = Mail::Message::Field::Full->parse($header);
44         # ref $s isa Mail::Message::Field::Addresses;
45
46         my @g = $s->groups;          # all groups, at least one
47         # ref $g[0] isa Mail::Message::Field::AddrGroup;
48         my $ga = $g[0]->addresses;   # group addresses
49
50         my @a = $s->addresses;       # all addresses
51         # ref $a[0] isa Mail::Message::Field::Address;
52

METHODS

54   Constructors
55       Mail::Address->new(PHRASE, ADDRESS, [ COMMENT ])
56
57           Create a new "Mail::Address" object which represents an address
58           with the elements given. In a message these 3 elements would be
59           seen like:
60
61            PHRASE <ADDRESS> (COMMENT)
62            ADDRESS (COMMENT)
63
64           example:
65
66            Mail::Address->new("Perl5 Porters", "perl5-porters@africa.nicoh.com");
67
68       $obj->parse(LINE)
69
70           Parse the given line a return a list of extracted "Mail::Address"
71           objects.  The line would normally be one taken from a To,Cc or Bcc
72           line in a message
73
74           example:
75
76            my @addr = Mail::Address->parse($line);
77
78   Accessors
79       $obj->address
80
81           Return the address part of the object.
82
83       $obj->comment
84
85           Return the comment part of the object
86
87       $obj->format([ADDRESSes])
88
89           Return a string representing the address in a suitable form to be
90           placed on a "To", "Cc", or "Bcc" line of a message.  This method is
91           called on the first ADDRESS to be used; other specified ADDRESSes
92           will be appended, separated with commas.
93
94       $obj->phrase
95
96           Return the phrase part of the object.
97
98   Smart accessors
99       $obj->host
100
101           Return the address excluding the user id and '@'
102
103       $obj->name
104
105           Using the information contained within the object attempt to
106           identify what the person or groups name is.
107
108       $obj->user
109
110           Return the address excluding the '@' and the mail domain
111

SEE ALSO

113       This module is part of the MailTools distribution,
114       http://perl.overmeer.net/mailtools/.
115

AUTHORS

117       The MailTools bundle was developed by Graham Barr.  Later, Mark
118       Overmeer took over maintenance without commitment to further
119       development.
120
121       Mail::Cap by Gisle Aas <aas@oslonett.no>.  Mail::Field::AddrList by
122       Peter Orbaek <poe@cit.dk>.  Mail::Mailer and Mail::Send by Tim Bunce
123       <Tim.Bunce@ig.co.uk>.  For other contributors see ChangeLog.
124

LICENSE

126       Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark
127       Overmeer <perl@overmeer.net>.
128
129       This program is free software; you can redistribute it and/or modify it
130       under the same terms as Perl itself.  See
131       http://www.perl.com/perl/misc/Artistic.html
132
133
134
135perl v5.12.2                      2010-10-01                  Mail::Address(3)
Impressum