/usr/share/perl5/Mail/Message/Body.pod is in libmail-box-perl 2.099-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | =head1 NAME
Mail::Message::Body - the data of a body in a message
=head1 INHERITANCE
Mail::Message::Body has extra code in
Mail::Message::Body::Construct
Mail::Message::Body::Encode
Mail::Message::Body
is a Mail::Reporter
Mail::Message::Body is extended by
Mail::Message::Body::File
Mail::Message::Body::Lines
Mail::Message::Body::Multipart
Mail::Message::Body::Nested
Mail::Message::Body::String
Mail::Message::Body is realized by
Mail::Message::Body::Delayed
=head1 SYNOPSIS
my Mail::Message $msg = ...;
my $body = $msg->body;
my @text = $body->lines;
my $text = $body->string;
my $file = $body->file; # IO::File
$body->print(\*FILE);
my $content_type = $body->type;
my $transfer_encoding = $body->transferEncoding;
my $encoded = $body->encode(mime_type => 'text/html',
charset => 'us-ascii', transfer_encoding => 'none');\n";
my $decoded = $body->decoded;
=head1 DESCRIPTION
The encoding and decoding functionality of a L<Mail::Message::Body|Mail::Message::Body> is
implemented in the L<Mail::Message::Body::Encode|Mail::Message::Body::Encode> package. That package is
automatically loaded when encoding and decoding of messages needs to take
place. Methods to simply build an process body objects are implemented
in L<Mail::Message::Body::Construct|Mail::Message::Body::Construct>.
The body of a message (a L<Mail::Message|Mail::Message> object) is stored in one of the
many body types. The functionality of each body type is equivalent, but there
are performance differences. Each body type has its own documentation
with details about its implementation.
=head1 OVERLOADED
=over 4
=item overload: B<"">
(stringification) Returns the body as string --which will trigger
completion-- unless called to produce a string for C<Carp>. The latter
to avoid deep recursions.
example: stringification of body
print $msg->body; # implicit by print
my $body = $msg->body;
my $x = "$body"; # explicit by interpolation
=item overload: B<'==' and '!='>
(numeric comparison) compares if two references point to the
same message. This only produces correct results is both arguments
are message references B<within the same folder>.
example: use of numeric comparison on a body
my $skip = $folder->message(3);
foreach my $msg (@$folder)
{ next if $msg == $skip;
$msg->send;
}
=item overload: B<@{}>
When a body object is used as being an array reference, the lines of
the body are returned. This is the same as using L<lines()|Mail::Message::Body/"Access to the payload">.
example: using a body as array
print $body->lines->[1]; # second line
print $body->[1]; # same
my @lines = $body->lines;
my @lines = @$body; # same
=item overload: B<bool>
Always returns a true value, which is needed to have overloaded
objects to be used as in C<if($body)>. Otherwise, C<if(defined $body)>
would be needed to avoid a runtime error.
=back
=head1 METHODS
=head2 Constructors
=over 4
=item $obj-E<gt>B<clone>
Return a copy of this body, usually to be included in a cloned
message. Use L<Mail::Message::clone()|Mail::Message/"Constructors"> for a whole message.
=item Mail::Message::Body-E<gt>B<new>(OPTIONS)
BE WARNED that, what you specify here are encodings and such which are
already in place. The options will not trigger conversions. When you
need conversions, first create a body with options which tell what you've
got, and then call L<encode()|Mail::Message::Body::Encode/"Constructing a body"> for what you need.
-Option --Defined in --Default
based_on undef
charset 'PERL' or <undef>
checked <false>
data undef
description undef
disposition undef
eol 'NATIVE'
file undef
log Mail::Reporter 'WARNINGS'
message undef
mime_type 'text/plain'
modified <false>
trace Mail::Reporter 'WARNINGS'
transfer_encoding 'none'
=over 2
=item based_on => BODY
The information about encodings must be taken from the specified BODY,
unless specified differently.
=item charset => CHARSET|'PERL'
Defines the character-set which is used in the data. Only useful in
combination with a C<mime_type> which refers to C<text> in any shape,
which does not contain an explicit charset already. This field is
case-insensitive.
When a known CHARSET is provided and the mime type says "text", then the
data is expected to be bytes in that particular encoding (see Encode).
When 'PERL' is given, then then the data is in Perl's internal encoding
(either latin1 or utf8, you shouldn't know!) More details in
L</Character encoding PERL>
=item checked => BOOLEAN
Whether the added information has been check not to contain illegal
octets with respect to the transfer encoding and mime type. If not
checked, and then set as body for a message, it will be.
=item data => ARRAY-OF-LINES | STRING
The content of the body. The only way to set the content of a body
is during the creation of the body. So if you want to modify the content
of a message, you need to create a new body with the new content and
add that to the body. The reason behind this, is that correct encodings
and body information must be guaranteed. It avoids your hassle in
calculating the number of lines in the body, and checking whether bad
characters are enclosed in text.
Specify a reference to an ARRAY of lines, each terminated by a newline.
Or one STRING which may contain multiple lines, separated and terminated
by a newline.
=item description => STRING|FIELD
Informal information about the body content. The data relates to the
C<Content-Description> field. Specify a STRING which will become the
field content, or a real FIELD.
=item disposition => STRING|FIELD
How this message can be decomposed. The data relates to the
C<Content-Disposition> field. Specify a STRING which will become the
field content, or a real FIELD.
The content of this field is specified in RFC 1806. The body of the
field can be C<inline>, to indicate that the body is intended to be
displayed automatically upon display of the message. Use C<attachment>
to indicate that they are separate from the main body of the mail
message, and that their display should not be automatic, but contingent
upon some further action of the user.
The C<filename> attribute specifies a name to which is suggested to the
reader of the message when it is extracted.
=item eol => 'CR'|'LF'|'CRLF'|'NATIVE'
Convert the message into having the specified string as line terminator
for all lines in the body. C<NATIVE> is used to represent the C<\n>
on the current platform and will be translated in the applicable one.
BE WARNED that folders with a non-native encoding may appear on your
platform, for instance in Windows folders handled from a UNIX system.
The eol encoding has effect on the size of the body!
=item file => FILENAME|FILEHANDLE|IOHANDLE
Read the data from the specified file, file handle, or object of
type C<IO::Handle>.
=item log => LEVEL
=item message => MESSAGE
The message where this body belongs to.
=item mime_type => STRING|FIELD|MIME
The type of data which is added. You may specify a content of a header
line as STRING, or a FIELD object. You may also specify a L<MIME::Type|MIME::Type>
object. In any case, it will be kept internally as
a real field (a L<Mail::Message::Field|Mail::Message::Field> object). This relates to the
C<Content-Type> header field.
A mime-type specification consists of two parts: a general class (C<text>,
C<image>, C<application>, etc) and a specific sub-class. Examples for
specific classes with C<text> are C<plain>, C<html>, and C<xml>. This
field is case-insensitive but case preserving. The default mime-type
is C<text/plain>,
=item modified => BOOLEAN
Whether the body is flagged modified, directly from its creation.
=item trace => LEVEL
=item transfer_encoding => STRING|FIELD
The encoding that the data has. If the data is to be encoded, than you
will have to call L<encode()|Mail::Message::Body::Encode/"Constructing a body"> after the body is created. That will
return a new encoded body. This field is case-insensitive and relates
to the C<Content-Transfer-Encoding> field in the header.
=back
example:
my $body = Mail::Message::Body::String->new(file => \*IN,
mime_type => 'text/html; charset="ISO-8859-1"');
my $body = Mail::Message::Body::Lines->new(data => ['first', $second],
charset => 'ISO-10646', transfer_encoding => 'none');
my $body = Mail::Message::Body::Lines->new(data => \@lines,
transfer_encoding => 'base64');
my $body = Mail::Message::Body::Lines->new(file => 'picture.gif',
mime_type => 'image/gif');
=back
=head2 Constructing a body
=over 4
=item $obj-E<gt>B<attach>(MESSAGES, OPTIONS)
See L<Mail::Message::Body::Construct/"Constructing a body">
=item $obj-E<gt>B<check>
See L<Mail::Message::Body::Encode/"Constructing a body">
=item $obj-E<gt>B<concatenate>(COMPONENTS)
See L<Mail::Message::Body::Construct/"Constructing a body">
=item $obj-E<gt>B<decoded>(OPTIONS)
Returns a body, an object which is (a sub-)class of a L<Mail::Message::Body|Mail::Message::Body>,
which contains a simplified representation of textual data. The returned
object may be the object where this is called on, but may also be a new
body of any type.
my $dec = $body->decoded;
is equivalent with
my $dec = $body->encode
( mime_type => 'text/plain'
, transfer_encoding => 'none'
, charset => 'PERL'
);
The C<$dec> which is returned is a body. Ask with the L<mimeType()|Mail::Message::Body/"About the payload"> method
what is produced. This C<$dec> body is B<not related to a header>.
-Option --Default
result_type <same as current>
=over 2
=item result_type => CLASS
=back
=item $obj-E<gt>B<encode>(OPTIONS)
See L<Mail::Message::Body::Encode/"Constructing a body">
=item $obj-E<gt>B<encoded>
See L<Mail::Message::Body::Encode/"Constructing a body">
=item $obj-E<gt>B<eol>(['CR'|'LF'|'CRLF'|'NATIVE'])
Returns the character (or characters) which are used to separate lines
within this body. When a kind of separator is specified, the body is
translated to contain the specified line endings.
example:
my $body = $msg->decoded->eol('NATIVE');
my $char = $msg->decoded->eol;
=item $obj-E<gt>B<foreachLine>(CODE)
See L<Mail::Message::Body::Construct/"Constructing a body">
=item $obj-E<gt>B<stripSignature>(OPTIONS)
See L<Mail::Message::Body::Construct/"Constructing a body">
=item $obj-E<gt>B<unify>(BODY)
See L<Mail::Message::Body::Encode/"Constructing a body">
=back
=head2 The body
=over 4
=item $obj-E<gt>B<isDelayed>
Returns a true or false value, depending on whether the body of this
message has been read from file. This can only false for a
L<Mail::Message::Body::Delayed|Mail::Message::Body::Delayed>.
=item $obj-E<gt>B<isMultipart>
Returns whether this message-body contains parts which are messages
by themselves.
=item $obj-E<gt>B<isNested>
Only true for a message body which contains exactly one sub-message:
the C<Mail::Message::Body::Nested> body type.
=item $obj-E<gt>B<message>([MESSAGE])
Returns the message where this body belongs to, optionally setting it
to a new MESSAGE first. If C<undef> is passed, the body will be
disconnected from the message.
=back
=head2 About the payload
=over 4
=item $obj-E<gt>B<charset>
Returns the character set which is used in the text body as string. This
is part of the result of what the C<type> method returns.
=item $obj-E<gt>B<checked>([BOOLEAN])
Returns whether the body encoding has been checked or not (optionally
after setting the flag to a new value).
=item $obj-E<gt>B<description>([STRING|FIELD])
Returns (optionally after setting) the informal description of the body
content. The related header field is C<Content-Description>.
A L<Mail::Message::Field|Mail::Message::Field> object is returned (which stringifies into
the field content). The field content will be C<none> if no disposition
was specified.
The argument can be a STRING (which is converted into a field), or a
fully prepared header field.
=item $obj-E<gt>B<disposition>([STRING|FIELD])
Returns (optionally after setting) how the message can be disposed
(unpacked). The related header field is C<Content-Disposition>.
A L<Mail::Message::Field|Mail::Message::Field> object is returned (which stringifies into
the field content). The field content will be C<none> if no disposition
was specified.
The argument can be a STRING (which is converted into a field), or a
fully prepared header field.
=item $obj-E<gt>B<dispositionFilename>([DIRECTORY])
See L<Mail::Message::Body::Encode/"About the payload">
=item $obj-E<gt>B<isBinary>
See L<Mail::Message::Body::Encode/"About the payload">
=item $obj-E<gt>B<isText>
See L<Mail::Message::Body::Encode/"About the payload">
=item $obj-E<gt>B<mimeType>
Returns a L<MIME::Type|MIME::Type> object which is related to this body's type. This
differs from the C<type> method, which results in a L<Mail::Message::Field|Mail::Message::Field>.
example:
if($body->mimeType eq 'text/html') {...}
print $body->mimeType->simplified;
=item $obj-E<gt>B<nrLines>
Returns the number of lines in the message body. For multi-part messages,
this includes the header lines and boundaries of all the parts.
=item $obj-E<gt>B<size>
The total number of bytes in the message body. The size of the body
is computed in the shape it is in. For example, if this is a base64
encoded message, the size of the encoded data is returned; you may
want to call L<Mail::Message::decoded()|Mail::Message/"The body"> first.
=item $obj-E<gt>B<transferEncoding>([STRING|FIELD])
Returns the transfer-encoding of the data within this body as
L<Mail::Message::Field|Mail::Message::Field> (which stringifies to its content). If it
needs to be changed, call the L<encode()|Mail::Message::Body::Encode/"Constructing a body"> or L<decoded()|Mail::Message::Body/"Constructing a body"> method.
When no encoding is present, the field contains the text C<none>.
The optional STRING or FIELD enforces a new encoding to be set, without the
actual required translations.
example:
my $transfer = $msg->decoded->transferEncoding;
$transfer->print; # --> Content-Encoding: base64
print $transfer; # --> base64
if($msg->body->transferEncoding eq 'none') {...}
=item $obj-E<gt>B<type>([STRING|FIELD])
Returns the type of information the body contains as
L<Mail::Message::Field|Mail::Message::Field> object. The type is taken from the header
field C<Content-Type>. If the header did not contain that field,
then you will get a default field containing C<text/plain>.
You usually can better use L<mimeType()|Mail::Message::Body/"About the payload">, because that will return a
clever object with type information.
example:
my $msg = $folder->message(6);
$msg->get('Content-Type')->print;
# --> Content-Type: text/plain; charset="us-ascii"
my $content = $msg->decoded;
my $type = $content->type;
print "This is a $type message\n";
# --> This is a text/plain; charset="us-ascii" message
print "This is a ", $type->body, "message\n";
# --> This is a text/plain message
print "Comment: ", $type->comment, "\n";
# --> Comment: charset="us-ascii"
=back
=head2 Access to the payload
=over 4
=item $obj-E<gt>B<endsOnNewline>
Returns whether the last line of the body is terminated by a new-line
(in transport it will become a CRLF). An empty body will return true
as well: the newline comes from the line before it.
=item $obj-E<gt>B<file>
Return the content of the body as a file handle. The returned stream may
be a real file, or a simulated file in any form that Perl supports. While
you may not be able to write to the file handle, you can read from it.
WARNING: Even if the file handle supports writing, do not write
to the file handle. If you do, some of the internal values of the
L<Mail::Message::Body|Mail::Message::Body> may not be updated.
=item $obj-E<gt>B<lines>
Return the content of the body as a list of lines (in LIST context) or a
reference to an array of lines (in SCALAR context). In scalar context the
array of lines is cached to avoid needless copying and therefore provide
much faster access for large messages.
To just get the number of lines in the body, use the L<nrLines()|Mail::Message::Body/"About the payload"> method,
which is usually much more efficient.
BE WARNED: For some types of bodies the reference will refer to the
original data. You must not change the referenced data! If you do, some of
the essential internal variables of the L<Mail::Message::Body|Mail::Message::Body> may not be
updated.
example:
my @lines = $body->lines; # copies lines
my $line3 = ($body->lines)[3] # only one copy
print $lines[0];
my $linesref = $body->lines; # reference to originals
my $line3 = $body->lines->[3] # only one copy (faster)
print $linesref->[0];
print $body->[0]; # by overloading
=item $obj-E<gt>B<print>([FILEHANDLE])
Print the body to the specified FILEHANDLE (defaults to the selected handle).
The handle may be a GLOB, an IO::File object, or... any object with a
C<print()> method will do. Nothing useful is returned.
=item $obj-E<gt>B<printEscapedFrom>(FILEHANDLE)
Print the body to the specified FILEHANDLE but all lines which start
with 'From ' (optionally already preceded by E<gt>'s) will habe an E<gt>
added in front. Nothing useful is returned.
=item $obj-E<gt>B<string>
Return the content of the body as a scalar (a single string). This is
a copy of the internally kept information.
example:
my $text = $body->string;
print "Body: $body\n"; # by overloading
=item $obj-E<gt>B<stripTrailingNewline>
Remove the newline from the last line, or the last line if it does not
contain anything else than a newline.
=item $obj-E<gt>B<write>(OPTIONS)
Write the content of the body to a file. Be warned that you may want to
decode the body before writing it!
-Option --Default
filename <required>
=over 2
=item filename => FILENAME
=back
example: write the data to a file
use File::Temp;
my $fn = tempfile;
$message->decoded->write(filename => $fn)
or die "Couldn't write to $fn: $!\n";
example: using the content-disposition information to write
use File::Temp;
my $dir = tempdir; mkdir $dir or die;
my $fn = $message->body->dispositionFilename($dir);
$message->decoded->write(filename => $fn)
or die "Couldn't write to $fn: $!\n";
=back
=head2 Internals
=over 4
=item $obj-E<gt>B<addTransferEncHandler>(NAME, CLASS|OBJECT)
=item Mail::Message::Body-E<gt>B<addTransferEncHandler>(NAME, CLASS|OBJECT)
See L<Mail::Message::Body::Encode/"Internals">
=item $obj-E<gt>B<contentInfoFrom>(HEAD)
Transfer the body related info from the header into this body.
=item $obj-E<gt>B<contentInfoTo>(HEAD)
Copy the content information (the C<Content-*> fields) into the specified
HEAD. The body was created from raw data without the required information,
which must be added. See also L<contentInfoFrom()|Mail::Message::Body/"Internals">.
=item $obj-E<gt>B<fileLocation>([BEGIN,END])
The location of the body in the file. Returned a list containing begin and
end. The begin is the offsets of the first byte if the folder used for
this body. The end is the offset of the first byte of the next message.
=item $obj-E<gt>B<getTransferEncHandler>(TYPE)
See L<Mail::Message::Body::Encode/"Internals">
=item $obj-E<gt>B<isModified>
Returns whether the body has changed.
=item $obj-E<gt>B<load>
Be sure that the body is loaded. This returns the loaded body.
=item $obj-E<gt>B<modified>([BOOLEAN])
Change the body modification flag. This will force a re-write of the body
to a folder file when it is closed. It is quite dangerous to change the
body: the same body may be shared between messages within your program.
Especially be warned that you have to change the message-id when you
change the body of the message: no two messages should have the same id.
Without value, the current setting is returned, although you can better use
L<isModified()|Mail::Message::Body/"Internals">.
=item $obj-E<gt>B<moveLocation>([DISTANCE])
Move the registration of the message to a new location over DISTANCE. This
is called when the message is written to a new version of the same
folder-file.
=item $obj-E<gt>B<read>(PARSER, HEAD, BODYTYPE [,CHARS [,LINES]])
Read the body with the PARSER from file. The implementation of this method
will differ between types of bodies. The BODYTYPE argument is a class name
or a code reference of a routine which can produce a class name, and is
used in multipart bodies to determine the type of the body for each part.
The CHARS argument is the estimated number of bytes in the body, or
C<undef> when this is not known. This data can sometimes be derived from
the header (the C<Content-Length> line) or file-size.
The second argument is the estimated number of LINES of the body. It is less
useful than the CHARS but may be of help determining whether the message
separator is trustworthy. This value may be found in the C<Lines> field
of the header.
=back
=head2 Error handling
=over 4
=item $obj-E<gt>B<AUTOLOAD>
When an unknown method is called on a message body object, this may
not be problematic. For performance reasons, some methods are
implemented in separate files, and only demand-loaded. If this
delayed compilation of additional modules does not help, an error
will be produced.
=item $obj-E<gt>B<addReport>(OBJECT)
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<defaultTrace>([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
=item Mail::Message::Body-E<gt>B<defaultTrace>([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<errors>
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<log>([LEVEL [,STRINGS]])
=item Mail::Message::Body-E<gt>B<log>([LEVEL [,STRINGS]])
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<logPriority>(LEVEL)
=item Mail::Message::Body-E<gt>B<logPriority>(LEVEL)
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<logSettings>
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<notImplemented>
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<report>([LEVEL])
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<reportAll>([LEVEL])
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<trace>([LEVEL])
See L<Mail::Reporter/"Error handling">
=item $obj-E<gt>B<warnings>
See L<Mail::Reporter/"Error handling">
=back
=head2 Cleanup
=over 4
=item $obj-E<gt>B<DESTROY>
See L<Mail::Reporter/"Cleanup">
=item $obj-E<gt>B<inGlobalDestruction>
See L<Mail::Reporter/"Cleanup">
=back
=head1 DETAILS
=head2 Access to the body
A body can be contained in a message, but may also live without a message.
In both cases it stores data, and the same questions can be asked: what
type of data it is, how many bytes and lines, what encoding is used. Any
body can be encoded and decoded, returning a new body object. However,
bodies which are part of a message will always be in a shape that they can
be written to a file or send to somewhere: they will be encoded if needed.
=head2 Body class implementation
=head3 Data collector bodies
=over 4
=item * L<Mail::Message::Body::String|Mail::Message::Body::String>
The whole message body is stored in one scalar. Small messages can be
contained this way without performance penalties.
=item * L<Mail::Message::Body::Lines|Mail::Message::Body::Lines>
Each line of the message body is stored as single scalar. This is a
useful representation for a detailed look in the message body, which is
usually line-organized.
=item * L<Mail::Message::Body::File|Mail::Message::Body::File>
The message body is stored in an external temporary file. This type of
storage is especially useful when the body is large, the total folder is
large, or memory is limited.
=item * Mail::Message::Body::InFolder
NOT IMPLEMENTED YET.
The message is kept in the folder, and is only taken out when the
content is changed.
=item * Mail::Message::Body::External
NOT IMPLEMENTED YET.
The message is kept in a separate file, usually because the message body
is large. The difference with the C<::External> object is that this external
storage stays this way between closing and opening of a folder. The
C<::External> object only uses a file when the folder is open.
=back
=head3 Complex bodies
=over 4
=item * L<Mail::Message::Body::Delayed|Mail::Message::Body::Delayed>
The message-body is not yet read, but the exact location of the
body is known so the message can be read when needed. This is part of
the lazy extraction mechanism. Once extracted, the object can become
any simple or complex body.
=item * L<Mail::Message::Body::Multipart|Mail::Message::Body::Multipart>
The message body contains a set of sub-messages (which can contain
multipart bodies themselves). Each sub-message is an instance
of L<Mail::Message::Part|Mail::Message::Part>, which is an extension of L<Mail::Message|Mail::Message>.
=item * L<Mail::Message::Body::Nested|Mail::Message::Body::Nested>
Nested messages, like C<message/rfc822>: they contain a message in
the body. For most code, they simply behave like multiparts.
=back
The body of a message can be stored in many ways. Roughly, the
implementations can be split in two groups: the data collectors and
the complex bodies. The primer implement various ways to access data,
and are full compatible: they only differ in performance and memory
footprint under different circumstances. The latter are created to
handle complex multiparts and lazy extraction.
=head2 Character encoding PERL
A body object can be part of a message, or stand-alone. In case it
is a part of a message, the "transport encoding" and the content must
be in a shape that the data can be transported via SMTP.
However, when you want to process the body data in simple Perl (or when
you construct the body data from normal Perl strings), you need to be
aware of Perl's internal representation of strings. That can either be
latin1 or utf8 (not real UTF-8, but something alike, see the perlunicode
manual page) So, before you start using the data from an incoming message,
do
my $body = $msg->decoded;
my @lines = $body->lines;
Now, the body has character-set 'PERL' (when it is text)
When you create a new body which contains text content (the default),
it will be created with character-set 'PERL' unless you specify a
character-set explicitly.
my $body = Mail::Box::Body::Lines->new(data => \@lines);
# now mime=text/plain, charset=PERL
my $msg = Mail::Message->buildFromBody($body);
$msg->body($body);
$msg->attach($body); # etc
# these all will convert the charset=PERL into real utf-8
=head1 DIAGNOSTICS
=over 4
=item Warning: Charset $name is not known
The encoding or decoding of a message body encounters a character set which
is not understood by Perl's Encode module.
=item Warning: No decoder defined for transfer encoding $name.
The data (message body) is encoded in a way which is not currently understood,
therefore no decoding (or recoding) can take place.
=item Warning: No encoder defined for transfer encoding $name.
The data (message body) has been decoded, but the required encoding is
unknown. The decoded data is returned.
=item Error: Package $package does not implement $method.
Fatal error: the specific package (or one of its superclasses) does not
implement this method where it should. This message means that some other
related classes do implement this method however the class at hand does
not. Probably you should investigate this and probably inform the author
of the package.
=item Warning: Unknown line terminator $eol ignored
=back
=head1 SEE ALSO
This module is part of Mail-Box distribution version 2.099,
built on July 07, 2011. Website: F<http://perl.overmeer.net/mailbox/>
=head1 LICENSE
Copyrights 2001-2011 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>
|