292 lines
6.2 KiB
HTML
292 lines
6.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Mail::Address</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Mail::Address</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-07-25<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Mail::Address - parse mail addresses
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use Mail::Address;
|
|
my @addrs = Mail::Address->parse($line);
|
|
|
|
foreach $addr (@addrs) {
|
|
print $addr->format,"\n";
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
<TT>"Mail::Address"</TT> extracts and manipulates email addresses from a message
|
|
header. It cannot be used to extract addresses from some random text.
|
|
You can use this module to create <FONT SIZE="-1">RFC822</FONT> compliant fields.
|
|
<P>
|
|
|
|
Although <TT>"Mail::Address"</TT> is a very popular subject for books, and is
|
|
used in many applications, it does a very poor job on the more complex
|
|
message fields. It does only handle simple address formats (which
|
|
covers about 95% of what can be found). Problems are with
|
|
<DL COMPACT>
|
|
<DT id="1">•<DD>
|
|
no support for address groups, even not with the semi-colon as
|
|
separator between addresses;
|
|
<DT id="2">•<DD>
|
|
limited support for escapes in phrases and comments. There are
|
|
cases where it can get wrong; and
|
|
<DT id="3">•<DD>
|
|
you have to take care of most escaping when you create an address yourself:
|
|
<TT>"Mail::Address"</TT> does not do that for you.
|
|
</DL>
|
|
<P>
|
|
|
|
Often requests are made to the maintainers of this code improve this
|
|
situation, but this is not a good idea, where it will break zillions
|
|
of existing applications. If you wish for a fully <FONT SIZE="-1">RFC2822</FONT> compliant
|
|
implementation you may take a look at Mail::Message::Field::Full,
|
|
part of MailBox.
|
|
<P>
|
|
|
|
<B>. Example</B>
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
my $s = Mail::Message::Field::Full->new($from_header);
|
|
# ref $s isa Mail::Message::Field::Addresses;
|
|
|
|
my @g = $s->groups; # all groups, at least one
|
|
# ref $g[0] isa Mail::Message::Field::AddrGroup;
|
|
my $ga = $g[0]->addresses; # group addresses
|
|
|
|
my @a = $s->addresses; # all addresses
|
|
# ref $a[0] isa Mail::Message::Field::Address;
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Constructors</H3>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="4">Mail::Address-><B>new</B>( $phrase, $address, [ $comment ] )<DD>
|
|
|
|
|
|
|
|
|
|
Create a new <TT>"Mail::Address"</TT> object which represents an address with the
|
|
elements given. In a message these 3 elements would be seen like:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
PHRASE <ADDRESS> (COMMENT)
|
|
ADDRESS (COMMENT)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Mail::Address->new("Perl5 Porters", "<A HREF="mailto:perl5-porters@africa.nicoh.com">perl5-porters@africa.nicoh.com</A>");
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="5">$obj-><B>parse</B>($line)<DD>
|
|
|
|
|
|
|
|
|
|
Parse the given line a return a list of extracted <TT>"Mail::Address"</TT> objects.
|
|
The line would normally be one taken from a To,Cc or Bcc line in a message
|
|
|
|
|
|
<P>
|
|
|
|
|
|
example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my @addr = Mail::Address->parse($line);
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Accessors</H3>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="6">$obj-><B>address</B>()<DD>
|
|
|
|
|
|
|
|
|
|
Return the address part of the object.
|
|
<DT id="7">$obj-><B>comment</B>()<DD>
|
|
|
|
|
|
|
|
|
|
Return the comment part of the object
|
|
<DT id="8">$obj-><B>format</B>(@addresses)<DD>
|
|
|
|
|
|
|
|
|
|
Return a string representing the address in a suitable form to be placed
|
|
on a <TT>"To"</TT>, <TT>"Cc"</TT>, or <TT>"Bcc"</TT> line of a message. This method is called on
|
|
the first address to be used; other specified addresses will be appended,
|
|
separated by commas.
|
|
<DT id="9">$obj-><B>phrase</B>()<DD>
|
|
|
|
|
|
|
|
|
|
Return the phrase part of the object.
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Smart accessors</H3>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="10">$obj-><B>host</B>()<DD>
|
|
|
|
|
|
|
|
|
|
Return the address excluding the user id and '@'
|
|
<DT id="11">$obj-><B>name</B>()<DD>
|
|
|
|
|
|
|
|
|
|
Using the information contained within the object attempt to identify what
|
|
the person or groups name is.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B>Note:</B> This function tries to be smart with the ``phrase'' of the
|
|
email address, which is probably a very bad idea. Consider to use
|
|
<B>phrase()</B> itself.
|
|
<DT id="12">$obj-><B>user</B>()<DD>
|
|
|
|
|
|
|
|
|
|
Return the address excluding the '@' and the mail domain
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
This module is part of the MailTools distribution,
|
|
<I><A HREF="http://perl.overmeer.net/mailtools/">http://perl.overmeer.net/mailtools/</A></I>.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>AUTHORS</H2>
|
|
|
|
|
|
|
|
The MailTools bundle was developed by Graham Barr. Later, Mark
|
|
Overmeer took over maintenance without commitment to further development.
|
|
<P>
|
|
|
|
Mail::Cap by Gisle Aas <<A HREF="mailto:aas@oslonett.no">aas@oslonett.no</A>>.
|
|
Mail::Field::AddrList by Peter Orbaek <<A HREF="mailto:poe@cit.dk">poe@cit.dk</A>>.
|
|
Mail::Mailer and Mail::Send by Tim Bunce <<A HREF="mailto:Tim.Bunce@ig.co.uk">Tim.Bunce@ig.co.uk</A>>.
|
|
For other contributors see ChangeLog.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>LICENSE</H2>
|
|
|
|
|
|
|
|
Copyrights 1995-2000 Graham Barr <<A HREF="mailto:gbarr@pobox.com">gbarr@pobox.com</A>> and
|
|
2001-2017 Mark Overmeer <<A HREF="mailto:perl@overmeer.net">perl@overmeer.net</A>>.
|
|
<P>
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
under the same terms as Perl itself.
|
|
See <I><A HREF="http://www.perl.com/perl/misc/Artistic.html">http://www.perl.com/perl/misc/Artistic.html</A></I>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="13"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="14"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="15"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="16"><A HREF="#lbAE">METHODS</A><DD>
|
|
<DL>
|
|
<DT id="17"><A HREF="#lbAF">Constructors</A><DD>
|
|
<DT id="18"><A HREF="#lbAG">Accessors</A><DD>
|
|
<DT id="19"><A HREF="#lbAH">Smart accessors</A><DD>
|
|
</DL>
|
|
<DT id="20"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="21"><A HREF="#lbAJ">AUTHORS</A><DD>
|
|
<DT id="22"><A HREF="#lbAK">LICENSE</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:47 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|