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

NAME

6       Mail::Field - base-class for manipulation of mail header fields
7

INHERITANCE

9        Mail::Field is extended by
10          Mail::Field::AddrList
11          Mail::Field::Date
12          Mail::Field::Generic
13

SYNOPSIS

15        use Mail::Field;
16
17        my $field = Mail::Field->new('Subject', 'some subject text');
18        my $field = Mail::Field->new(Subject => 'some subject text');
19        print $field->tag,": ",$field->stringify,"\n";
20
21        my $field = Mail::Field->subject('some subject text');
22

DESCRIPTION

24       "Mail::Field" creates and manipulates fields in MIME headers, collected
25       within a Mail::Header object.  Different field types have their own
26       sub-class (extension), defining additional useful accessors to the
27       field content.
28
29       People are invited to merge their implementation to special fields into
30       MailTools, to maintain a consistent set of packages and documentation.
31

METHODS

33   Constructors
34       Mail::Field (and it's sub-classes) define several methods which return
35       new objects. These can all be categorized as constructor.
36
37       Mail::Field->combine($fields)
38           Take a LIST of "Mail::Field" objects (which should all be of the
39           same sub-class) and create a new object in that same class.
40
41       Mail::Field->extract( $tag, $head [, $index ] )
42           Takes as arguments the tag name, a "Mail::Head" object and
43           optionally an index.
44
45           If the index argument is given then "extract" will retrieve the
46           given tag from the "Mail::Head" object and create a new
47           "Mail::Field" based object.  undef will be returned in the field
48           does not exist.
49
50           If the index argument is not given the result depends on the
51           context in which "extract" is called. If called in a scalar context
52           the result will be as if "extract" was called with an index value
53           of zero. If called in an array context then all tags will be
54           retrieved and a list of "Mail::Field" objects will be returned.
55
56       Mail::Field->new( $tag [, STRING | %options] )
57           Create an object in the class which defines the field specified by
58           the $tag argument.
59
60   "Fake" constructors
61       $obj->create(%options)
62           This constructor is used internally with preprocessed field
63           information.  When called on an existing object, its original
64           content will get replaced.
65
66       $obj->parse()
67           Parse a field line.
68
69   Accessors
70       $obj->set(%options)
71           Change the settings (the content, but then smart) of this field.
72
73       $obj->stringify()
74           Returns the field as a string.
75
76       $obj->tag()
77       Mail::Field->tag()
78           Return the tag (in the correct case) for this item.  Well, actually
79           any casing is OK, because the field tags are treated case-
80           insensitive; however people have some preferences.
81
82   Smart accessors
83       $obj->text( [STRING] )
84           Without arguments, the field is returned as stringify() does.
85           Otherwise, the STRING is parsed with parse() to replace the
86           object's content.
87
88           It is more clear to call either stringify() or parse() directly,
89           because this method does not add additional processing.
90

DETAILS

92   SUB-CLASS PACKAGE NAMES
93       All sub-classes should be called Mail::Field::name where name is
94       derived from the tag using these rules.
95
96       •   Consider a tag as being made up of elements separated by '-'
97
98       •   Convert all characters to lowercase except the first in each
99           element, which should be uppercase.
100
101name is then created from these elements by using the first N
102           characters from each element.
103
104       •   N is calculated by using the formula :-
105
106               int((7 + #elements) / #elements)
107
108name is then limited to a maximum of 8 characters, keeping the
109           first 8 characters.
110
111       For an example of this take a look at the definition of the
112       "_header_pkg_name()" subroutine in "Mail::Field"
113

DIAGNOSTICS

115       Error: Undefined subroutine <method> called
116           Mail::Field objects use autoloading to compile new functionality.
117           Apparently, the method called is not implemented for the specific
118           class of the field object.
119

SEE ALSO

121       This module is part of the MailTools distribution,
122       http://perl.overmeer.net/mailtools/.
123

AUTHORS

125       The MailTools bundle was developed by Graham Barr.  Later, Mark
126       Overmeer took over maintenance without commitment to further
127       development.
128
129       Mail::Cap by Gisle Aas <aas@oslonett.no>.  Mail::Field::AddrList by
130       Peter Orbaek <poe@cit.dk>.  Mail::Mailer and Mail::Send by Tim Bunce
131       <Tim.Bunce@ig.co.uk>.  For other contributors see ChangeLog.
132

LICENSE

134       Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2017 Mark
135       Overmeer <perl@overmeer.net>.
136
137       This program is free software; you can redistribute it and/or modify it
138       under the same terms as Perl itself.  See
139       http://www.perl.com/perl/misc/Artistic.html
140
141
142
143perl v5.36.0                      2022-07-22                    Mail::Field(3)
Impressum