314 lines
7.5 KiB
HTML
314 lines
7.5 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Mail::Field</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Mail::Field</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::Field - base-class for manipulation of mail header fields
|
|
<A NAME="lbAC"> </A>
|
|
<H2>INHERITANCE</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Mail::Field is extended by
|
|
Mail::Field::AddrList
|
|
Mail::Field::Date
|
|
Mail::Field::Generic
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use Mail::Field;
|
|
|
|
my $field = Mail::Field->new('Subject', 'some subject text');
|
|
my $field = Mail::Field->new(Subject => 'some subject text');
|
|
print $field->tag,": ",$field->stringify,"\n";
|
|
|
|
my $field = Mail::Field->subject('some subject text');
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
<TT>"Mail::Field"</TT> creates and manipulates fields in <FONT SIZE="-1">MIME</FONT> headers, collected
|
|
within a Mail::Header object. Different field types have their
|
|
own sub-class (extension), defining additional useful accessors to the
|
|
field content.
|
|
<P>
|
|
|
|
People are invited to merge their implementation to special fields into
|
|
MailTools, to maintain a consistent set of packages and documentation.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Constructors</H3>
|
|
|
|
|
|
|
|
Mail::Field (and it's sub-classes) define several methods which return
|
|
new objects. These can all be categorized as constructor.
|
|
<DL COMPACT>
|
|
<DT id="1">Mail::Field-><B>combine</B>($fields)<DD>
|
|
|
|
|
|
Take a <FONT SIZE="-1">LIST</FONT> of <TT>"Mail::Field"</TT> objects (which should all be of the same
|
|
sub-class) and create a new object in that same class.
|
|
<DT id="2">Mail::Field-><B>extract</B>( $tag, $head [, $index ] )<DD>
|
|
|
|
|
|
|
|
|
|
Takes as arguments the tag name, a <TT>"Mail::Head"</TT> object
|
|
and optionally an index.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If the index argument is given then <TT>"extract"</TT> will retrieve the given tag
|
|
from the <TT>"Mail::Head"</TT> object and create a new <TT>"Mail::Field"</TT> based object.
|
|
<I>undef</I> will be returned in the field does not exist.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If the index argument is not given the result depends on the context
|
|
in which <TT>"extract"</TT> is called. If called in a scalar context the result
|
|
will be as if <TT>"extract"</TT> was called with an index value of zero. If called
|
|
in an array context then all tags will be retrieved and a list of
|
|
<TT>"Mail::Field"</TT> objects will be returned.
|
|
<DT id="3">Mail::Field-><B>new</B>( $tag [, <FONT SIZE="-1">STRING</FONT> | %options] )<DD>
|
|
|
|
|
|
|
|
|
|
Create an object in the class which defines the field specified by
|
|
the <TT>$tag</TT> argument.
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Fake constructors</H3>
|
|
|
|
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="4">$obj-><B>create</B>(%options)<DD>
|
|
|
|
|
|
|
|
|
|
This constructor is used internally with preprocessed field information.
|
|
When called on an existing object, its original content will get
|
|
replaced.
|
|
<DT id="5">$obj-><B>parse</B>()<DD>
|
|
|
|
|
|
|
|
|
|
Parse a field line.
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H3>Accessors</H3>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="6">$obj-><B>set</B>(%options)<DD>
|
|
|
|
|
|
|
|
|
|
Change the settings (the content, but then smart) of this field.
|
|
<DT id="7">$obj-><B>stringify</B>()<DD>
|
|
|
|
|
|
|
|
|
|
Returns the field as a string.
|
|
<DT id="8">$obj-><B>tag</B>()<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="9">Mail::Field-><B>tag</B>()<DD>
|
|
|
|
|
|
|
|
Return the tag (in the correct case) for this item. Well, actually any
|
|
casing is <FONT SIZE="-1">OK,</FONT> because the field tags are treated case-insensitive; however
|
|
people have some preferences.
|
|
</DL>
|
|
<A NAME="lbAJ"> </A>
|
|
<H3>Smart accessors</H3>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="10">$obj-><B>text</B>( [<FONT SIZE="-1">STRING</FONT>] )<DD>
|
|
|
|
|
|
|
|
|
|
Without arguments, the field is returned as <B>stringify()</B> does. Otherwise,
|
|
the <FONT SIZE="-1">STRING</FONT> is parsed with <B>parse()</B> to replace the object's content.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
It is more clear to call either <B>stringify()</B> or <B>parse()</B> directly, because
|
|
this method does not add additional processing.
|
|
</DL>
|
|
<A NAME="lbAK"> </A>
|
|
<H2>DETAILS</H2>
|
|
|
|
|
|
|
|
<A NAME="lbAL"> </A>
|
|
<H3>SUB-CLASS <FONT SIZE="-1">PACKAGE NAMES</FONT></H3>
|
|
|
|
|
|
|
|
All sub-classes should be called Mail::Field::<I>name</I> where <I>name</I> is
|
|
derived from the tag using these rules.
|
|
<DL COMPACT>
|
|
<DT id="11">•<DD>
|
|
Consider a tag as being made up of elements separated by '-'
|
|
<DT id="12">•<DD>
|
|
Convert all characters to lowercase except the first in each element, which
|
|
should be uppercase.
|
|
<DT id="13">•<DD>
|
|
<I>name</I> is then created from these elements by using the first
|
|
N characters from each element.
|
|
<DT id="14">•<DD>
|
|
N is calculated by using the formula :-
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
int((7 + #elements) / #elements)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="15">•<DD>
|
|
<I>name</I> is then limited to a maximum of 8 characters, keeping the first 8
|
|
characters.
|
|
</DL>
|
|
<P>
|
|
|
|
For an example of this take a look at the definition of the
|
|
<TT>"_header_pkg_name()"</TT> subroutine in <TT>"Mail::Field"</TT>
|
|
<A NAME="lbAM"> </A>
|
|
<H2>DIAGNOSTICS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="16">Error: Undefined subroutine <method> called<DD>
|
|
|
|
|
|
Mail::Field objects use autoloading to compile new functionality.
|
|
Apparently, the method called is not implemented for the specific
|
|
class of the field object.
|
|
</DL>
|
|
<A NAME="lbAN"> </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="lbAO"> </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="lbAP"> </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="17"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="18"><A HREF="#lbAC">INHERITANCE</A><DD>
|
|
<DT id="19"><A HREF="#lbAD">SYNOPSIS</A><DD>
|
|
<DT id="20"><A HREF="#lbAE">DESCRIPTION</A><DD>
|
|
<DT id="21"><A HREF="#lbAF">METHODS</A><DD>
|
|
<DL>
|
|
<DT id="22"><A HREF="#lbAG">Constructors</A><DD>
|
|
<DT id="23"><A HREF="#lbAH">Fake constructors</A><DD>
|
|
<DT id="24"><A HREF="#lbAI">Accessors</A><DD>
|
|
<DT id="25"><A HREF="#lbAJ">Smart accessors</A><DD>
|
|
</DL>
|
|
<DT id="26"><A HREF="#lbAK">DETAILS</A><DD>
|
|
<DL>
|
|
<DT id="27"><A HREF="#lbAL">SUB-CLASS <FONT SIZE="-1">PACKAGE NAMES</FONT></A><DD>
|
|
</DL>
|
|
<DT id="28"><A HREF="#lbAM">DIAGNOSTICS</A><DD>
|
|
<DT id="29"><A HREF="#lbAN">SEE ALSO</A><DD>
|
|
<DT id="30"><A HREF="#lbAO">AUTHORS</A><DD>
|
|
<DT id="31"><A HREF="#lbAP">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>
|