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

METHODS

42   Constructors
43       Mail::Address->new(PHRASE, ADDRESS, [ COMMENT ])
44           Create a new "Mail::Address" object which represents an address
45           with the elements given. In a message these 3 elements would be
46           seen like:
47
48            PHRASE <ADDRESS> (COMMENT)
49            ADDRESS (COMMENT)
50
51           example:
52
53            Mail::Address->new("Perl5 Porters", "perl5-porters@africa.nicoh.com");
54
55       $obj->parse(LINE)
56           Parse the given line a return a list of extracted "Mail::Address"
57           objects.  The line would normally be one taken from a To,Cc or Bcc
58           line in a message
59
60           example:
61
62            my @addr = Mail::Address->parse($line);
63
64   Accessors
65       $obj->address()
66           Return the address part of the object.
67
68       $obj->comment()
69           Return the comment part of the object
70
71       $obj->format([ADDRESSes])
72           Return a string representing the address in a suitable form to be
73           placed on a "To", "Cc", or "Bcc" line of a message.  This method is
74           called on the first ADDRESS to be used; other specified ADDRESSes
75           will be appended, separated with commas.
76
77       $obj->phrase()
78           Return the phrase part of the object.
79
80   Smart accessors
81       $obj->host()
82           Return the address excluding the user id and '@'
83
84       $obj->name()
85           Using the information contained within the object attempt to
86           identify what the person or groups name is.
87
88           Note: This function tries to be smart with the "phrase" of the
89           email address, which is probably a very bad idea.  Consider to use
90           phrase() itself.
91
92       $obj->user()
93           Return the address excluding the '@' and the mail domain
94

SEE ALSO

96       This module is part of the MailTools distribution,
97       http://perl.overmeer.net/mailtools/.
98

AUTHORS

100       The MailTools bundle was developed by Graham Barr.  Later, Mark
101       Overmeer took over maintenance without commitment to further
102       development.
103
104       Mail::Cap by Gisle Aas <aas@oslonett.no>.  Mail::Field::AddrList by
105       Peter Orbaek <poe@cit.dk>.  Mail::Mailer and Mail::Send by Tim Bunce
106       <Tim.Bunce@ig.co.uk>.  For other contributors see ChangeLog.
107

LICENSE

109       Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark
110       Overmeer <perl@overmeer.net>.
111
112       This program is free software; you can redistribute it and/or modify it
113       under the same terms as Perl itself.  See
114       http://www.perl.com/perl/misc/Artistic.html
115
116
117
118perl v5.16.3                      2012-12-21                  Mail::Address(3)
Impressum