(stringification) produces the unfolded body of the field, which may be what you expect. This is what makes what the field object seems to be a simple string. The string is produced by unfoldedBody().
print $msg->get('subject'); # via overloading print $msg->get('subject')->unfoldedBody; # same my $subject = $msg->get('subject') || 'your mail'; print "Re: $subject\n";
Always true, to make it possible to say if($field)
.
(string comparison) Compare the unfolded body of a field with an other
field or a string, using the buildin cmp
.
See METHODS in Mail::Reporter
Create a copy of this field object.
See Mail::Message::Field::Fast::new(),
Mail::Message::Field::Flex::new(),
and Mail::Message::Field::Full::new().
By default, a Fast
field is produced.
Option | Defined in | Default |
---|---|---|
log | Mail::Reporter |
|
trace | Mail::Reporter |
|
Some fields are described in the RFCs as being structured: having a
well described syntax. These fields have common ideas about comments
and the like, what they do not share with unstructured fields, like
the Subject
field.
my $field = Mail::Message::Field->new(From => 'me'); if($field->isStructured) Mail::Message::Field->isStructured('From');
Returns the total length of the field in characters, which includes the field's name, body and folding characters.
Returns the number of lines needed to display this header-line.
Print the whole header-line to the specified file-handle. One line may result in more than one printed line, because of the folding of long lines. The $fh defaults to the selected handle.
Returns whether this field can be disclosed to other people, for instance
when sending the message to an other party. Returns a true
or false
condition.
See also Mail::Message::Head::Complete::printUndisclosed().
(Instance method class method) As instance method, the current field's name is correctly formatted and returned. When a STRING is used, that one is formatted.
print Mail::Message::Field->Name('content-type') # --> Content-Type my $field = $head->get('date'); print $field->Name; # --> Date
This method may be what you want, but usually, the foldedBody() and unfoldedBody() are what you are looking for. This method is cultural heritage, and should be avoided.
Returns the body of the field. When this field is structured, it will
be stripped from everything what is behind the first semi-color (;
).
In any case, the string is unfolded.
Whether the field is structured is defined by isStructured().
Returns the folded version of the whole header. When the header is shorter than the wrap length, a list of one line is returned. Otherwise more lines will be returned, all but the first starting with at least one blank. See also foldedBody() to get the same information without the field's name.
In scalar context, the lines are delived into one string, which is a little faster because that's the way they are stored internally...
my @lines = $field->folded; print $field->folded; print scalar $field->folded; # faster
Returns the body as a set of lines. In scalar context, this will be one line containing newlines. Be warned about the newlines when you do pattern-matching on the result of thie method.
The optional $body argument changes the field's body. The folding of the argument must be correct.
Remove the comments and folding white spaces from the STRING. Without string and only as instance method, the unfoldedBody() is being stripped and returned.
WARNING: This operation is only allowed for structured header fields (which are defined by the various RFCs as being so. You don't want parts within braces which are in the Subject header line to be removed, to give an example.
Returns the body as one single line, where all folding information (if available) is removed. This line will also NOT end on a new-line.
The optional $body argument changes the field's body. The right folding is performed before assignment. The $wrap may be specified to enforce a folding size.
my $body = $field->unfoldedBody; print "$field"; # via overloading
Returns a list of Mail::Address objects, which represent the e-mail addresses found in this header line.
my @addr = $message->head->get('to')->addresses; my @addr = $message->to;
Get the value of an attribute, optionally after setting it to a new value.
Attributes are part of some header lines, and hide themselves in the
comment field. If the attribute does not exist, then undef
is
returned. The attribute is still encoded.
my $field = Mail::Message::Field->new( 'Content-Type: text/plain; charset="us-ascii"'); print $field->attribute('charset'); # --> us-ascii print $field->attribute('bitmap') || 'no' # --> no $field->atrribute(filename => '/tmp/xyz'); $field->print; # --> Content-Type: text/plain; charset="us-ascii"; # filename="/tmp/xyz" # Automatically folded, and no doubles created.
Returns a list of key-value pairs, where the values are not yet decoded. Keys may appear more than once.
my @pairs = $head->get('Content-Disposition')->attributes;
Returns the unfolded comment (part after a semi-colon) in a structureed
header-line. optionally after setting it to a new STRING first.
When undef
is specified as STRING, the comment is removed.
Whether the field is structured is defined by isStructured().
The comment part of a header field often contains attributes
. Often
it is preferred to use attribute() on them.
Study the header field in detail: turn on the full parsing and detailed understanding of the content of the fields. Mail::Message::Field::Fast and Mail::Message::Field::Fast objects will be transformed into any Mail::Message::Field::Full object.
my $subject = $msg->head->get('subject')->study; my $subject = $msg->head->study('subject'); # same my $subject = $msg->study('subject'); # same
Convert a timestamp into an rfc2822 compliant date format. This differs
from the default output of localtime
in scalar context. Without
argument, the localtime
is used to get the current time. $time can
be specified as one numeric (like the result of time()
) and as list
(like produced by c<localtime()> in list context).
Be sure to have your timezone set right, especially when this script runs automatically.
my $now = time; Mail::Message::Field->toDate($now); Mail::Message::Field->toDate(time); Mail::Message::Field->toDate(localtime); Mail::Message::Field->toDate; # same # returns someting like: # Wed, 28 Aug 2002 10:40:25 +0200
Returns the value which is related to this field as integer. A check is performed whether this is right.
The numeric value of a field is requested (for instance the Lines
or
Content-Length
fields should be numerical), however the data contains
weird characters.
Convert a STRING which represents and RFC compliant time string into
a timestamp like is produced by the time
function.
Accepts a whole field $line, or a pair with the field's $name and $body. In the latter case, the $body data may be specified as array of $objects which are stringified. Returned is a nicely formatted pair of two strings: the field's name and a folded body.
This method is called by new(), and usually not by an application program. The details about converting the $objects to a field content are explained in Specifying field data.
A new field is being created which does contain characters not permitted by the RFCs. Using this field in messages may break other e-mail clients or transfer agents, and therefore mutulate or extinguish your message.
Any field from any header for any message will have this default wrapping. This is maintained in one global variable. Without a specified $length, the current value is returned. The default is 78.
Make the header field with $name fold into multiple lines. Wrapping is performed by inserting newlines before a blanks in the $body, such that no line exceeds the $maxchars and each line is as long as possible.
The RFC requests for folding on nice spots, but this request is mainly ignored because it would make folding too slow.
Force the wrapping of this field to the specified $length characters. The wrapping is performed with fold() and the results stored within the field object.
$field->setWrapLength(99);
This method implements the translation of user supplied objects into ascii fields. The process is explained in Specifying field data.