1Mail::Message::Body(3)User Contributed Perl DocumentationMail::Message::Body(3)
2
3
4

NAME

6       Mail::Message::Body - the data of a body in a message
7

INHERITANCE

9        Mail::Message::Body has extra code in
10          Mail::Message::Body::Construct
11          Mail::Message::Body::Encode
12
13        Mail::Message::Body
14          is a Mail::Reporter
15
16        Mail::Message::Body is extended by
17          Mail::Message::Body::File
18          Mail::Message::Body::Lines
19          Mail::Message::Body::Multipart
20          Mail::Message::Body::Nested
21          Mail::Message::Body::String
22
23        Mail::Message::Body is realized by
24          Mail::Message::Body::Delayed
25

SYNOPSIS

27        my Mail::Message $msg = ...;
28        my $body  = $msg->body;
29        my @text  = $body->lines;
30        my $text  = $body->string;
31        my $file  = $body->file;  # IO::File
32        $body->print(\*FILE);
33
34        my $content_type = $body->type;
35        my $transfer_encoding = $body->transferEncoding;
36        my $encoded = $body->encode(mime_type => 'text/html',
37           charset => 'us-ascii', transfer_encoding => 'none');\n";
38        my $decoded = $body->decoded;
39

DESCRIPTION

41       The encoding and decoding functionality of a Mail::Message::Body is
42       implemented in the Mail::Message::Body::Encode package.  That package
43       is automatically loaded when encoding and decoding of messages needs to
44       take place.  Methods to simply build an process body objects are
45       implemented in Mail::Message::Body::Construct.
46
47       The body of a message (a Mail::Message object) is stored in one of the
48       many body types.  The functionality of each body type is equivalent,
49       but there are performance differences.  Each body type has its own
50       documentation with details about its implementation.
51
52       Extends "DESCRIPTION" in Mail::Reporter.
53

OVERLOADED

55       overload: ""
56           (stringification) Returns the body as string --which will trigger
57           completion-- unless called to produce a string for "Carp".  The
58           latter to avoid deep recursions.
59
60           example: stringification of body
61
62            print $msg->body;   # implicit by print
63
64            my $body = $msg->body;
65            my $x    = "$body"; # explicit by interpolation
66
67       overload: '==' and '!='
68           (numeric comparison) compares if two references point to the same
69           message.  This only produces correct results is both arguments are
70           message references within the same folder.
71
72           example: use of numeric comparison on a body
73
74            my $skip = $folder->message(3);
75            foreach my $msg (@$folder)
76            {   next if $msg == $skip;
77                $msg->send;
78            }
79
80       overload: @{}
81           When a body object is used as being an array reference, the lines
82           of the body are returned.  This is the same as using lines().
83
84           example: using a body as array
85
86            print $body->lines->[1];  # second line
87            print $body->[1];         # same
88
89            my @lines = $body->lines;
90            my @lines = @$body;       # same
91
92       overload: bool
93           Always returns a true value, which is needed to have overloaded
94           objects to be used as in if($body).  Otherwise, "if(defined $body)"
95           would be needed to avoid a runtime error.
96

METHODS

98       Extends "METHODS" in Mail::Reporter.
99
100   Constructors
101       Extends "Constructors" in Mail::Reporter.
102
103       $obj->clone()
104           Return a copy of this body, usually to be included in a cloned
105           message. Use Mail::Message::clone() for a whole message.
106
107       Mail::Message::Body->new(%options)
108           BE WARNED that, what you specify here are encodings and such which
109           are already in place.  The options will not trigger conversions.
110           When you need conversions, first create a body with options which
111           tell what you've got, and then call encode() for what you need.
112
113            -Option           --Defined in     --Default
114             based_on                            undef
115             charset                             'PERL' or <undef>
116             checked                             <false>
117             content_id                          undef
118             data                                undef
119             description                         undef
120             disposition                         undef
121             eol                                 'NATIVE'
122             file                                undef
123             filename                            undef
124             log                Mail::Reporter   'WARNINGS'
125             message                             undef
126             mime_type                           'text/plain'
127             modified                            <false>
128             trace              Mail::Reporter   'WARNINGS'
129             transfer_encoding                   'none'
130
131           based_on => BODY
132             The information about encodings must be taken from the specified
133             BODY, unless specified differently.
134
135           charset => CHARSET|'PERL'
136             Defines the character-set which is used in the data.  Only useful
137             in combination with a "mime_type" which refers to "text" in any
138             shape, which does not contain an explicit charset already.  This
139             field is case-insensitive.
140
141             When a known CHARSET is provided and the mime type says "text",
142             then the data is expected to be bytes in that particular encoding
143             (see Encode).  When 'PERL' is given, then then the data is in
144             Perl's internal encoding (either latin1 or utf8, you shouldn't
145             know!) More details in "Character encoding PERL"
146
147           checked => BOOLEAN
148             Whether the added information has been check not to contain
149             illegal octets with respect to the transfer encoding and mime
150             type.  If not checked, and then set as body for a message, it
151             will be.
152
153           content_id => STRING
154             In multipart/related MIME content, the content_id is required to
155             allow access to the related content via a cid:<...> descriptor of
156             an inline disposition.
157
158             A "Content-ID" is supposed to be globally unique.  As such, it is
159             common to append '@computer.domain' to the end of some unique
160             string.  As other content in the multipart/related container also
161             needs to know what this "Content-ID" is, this should be left to
162             the imagination of the person making the content (for now).
163
164             As a MIME header field, the "Content-ID" string is expected to be
165             inside angle brackets
166
167           data => ARRAY-OF-LINES | STRING
168             The content of the body.  The only way to set the content of a
169             body is during the creation of the body.  So if you want to
170             modify the content of a message, you need to create a new body
171             with the new content and add that to the body.  The reason behind
172             this, is that correct encodings and body information must be
173             guaranteed.  It avoids your hassle in calculating the number of
174             lines in the body, and checking whether bad characters are
175             enclosed in text.
176
177             Specify a reference to an ARRAY of lines, each terminated by a
178             newline.  Or one STRING which may contain multiple lines,
179             separated and terminated by a newline.
180
181           description => STRING|FIELD
182             Informal information about the body content.  The data relates to
183             the "Content-Description" field.  Specify a STRING which will
184             become the field content, or a real FIELD.
185
186           disposition => STRING|FIELD
187             How this message can be decomposed.  The data relates to the
188             "Content-Disposition" field.  Specify a STRING which will become
189             the field content, or a real FIELD.
190
191             The content of this field is specified in RFC 1806.  The body of
192             the field can be "inline", to indicate that the body is intended
193             to be displayed automatically upon display of the message. Use
194             "attachment" to indicate that they are separate from the main
195             body of the mail message, and that their display should not be
196             automatic, but contingent upon some further action of the user.
197
198             The "filename" attribute specifies a name to which is suggested
199             to the reader of the message when it is extracted.
200
201           eol => 'CR'|'LF'|'CRLF'|'NATIVE'
202             Convert the message into having the specified string as line
203             terminator for all lines in the body.  "NATIVE" is used to
204             represent the "\n" on the current platform and will be translated
205             in the applicable one.
206
207             BE WARNED that folders with a non-native encoding may appear on
208             your platform, for instance in Windows folders handled from a
209             UNIX system.  The eol encoding has effect on the size of the
210             body!
211
212           file => FILENAME|FILEHANDLE|IOHANDLE
213             Read the data from the specified file, file handle, or object of
214             type "IO::Handle".
215
216           filename => FILENAME
217             [3.001] Overrule/set filename for content-disposition
218
219           log => LEVEL
220           message => MESSAGE
221             The message where this body belongs to.
222
223           mime_type => STRING|FIELD|MIME
224             The type of data which is added.  You may specify a content of a
225             header line as STRING, or a FIELD object.  You may also specify a
226             MIME::Type object.  In any case, it will be kept internally as a
227             real field (a Mail::Message::Field object).  This relates to the
228             "Content-Type" header field.
229
230             A mime-type specification consists of two parts: a general class
231             ("text", "image", "application", etc) and a specific sub-class.
232             Examples for specific classes with "text" are "plain", "html",
233             and "xml".  This field is case-insensitive but case preserving.
234             The default mime-type is "text/plain",
235
236           modified => BOOLEAN
237             Whether the body is flagged modified, directly from its creation.
238
239           trace => LEVEL
240           transfer_encoding => STRING|FIELD
241             The encoding that the data has.  If the data is to be encoded,
242             than you will have to call encode() after the body is created.
243             That will return a new encoded body.  This field is case-
244             insensitive and relates to the "Content-Transfer-Encoding" field
245             in the header.
246
247           example:
248
249            my $body = Mail::Message::Body::String->new(file => \*IN,
250               mime_type => 'text/html; charset="ISO-8859-1"');
251
252            my $body = Mail::Message::Body::Lines->new(data => ['first', $second],
253               charset => 'ISO-10646', transfer_encoding => 'none');
254
255            my $body = Mail::Message::Body::Lines->new(data => \@lines,
256               transfer_encoding => 'base64');
257
258            my $body = Mail::Message::Body::Lines->new(file => 'picture.gif',
259               mime_type => 'image/gif', content_id => '<12345@example.com>',
260               disposition => 'inline');
261
262   Constructing a body
263       $obj->attach($messages, %options)
264           Inherited, see "Constructing a body" in
265           Mail::Message::Body::Construct
266
267       $obj->check()
268           Inherited, see "Constructing a body" in Mail::Message::Body::Encode
269
270       $obj->concatenate($components)
271           Inherited, see "Constructing a body" in
272           Mail::Message::Body::Construct
273
274       $obj->decoded(%options)
275           Returns a body, an object which is (a sub-)class of a
276           Mail::Message::Body, which contains a simplified representation of
277           textual data.  The returned object may be the object where this is
278           called on, but may also be a new body of any type.
279
280            my $dec = $body->decoded;
281
282           is equivalent with
283
284            my $dec = $body->encode
285              ( mime_type         => 'text/plain'
286              , transfer_encoding => 'none'
287              , charset           => 'PERL'
288              );
289
290           The $dec which is returned is a body.  Ask with the mimeType()
291           method what is produced.  This $dec body is not related to a
292           header.
293
294            -Option     --Default
295             result_type  <same as current>
296
297           result_type => CLASS
298       $obj->encode(%options)
299           Inherited, see "Constructing a body" in Mail::Message::Body::Encode
300
301       $obj->encoded()
302           Inherited, see "Constructing a body" in Mail::Message::Body::Encode
303
304       $obj->eol( ['CR'|'LF'|'CRLF'|'NATIVE'] )
305           Returns the character (or characters) which are used to separate
306           lines within this body.  When a kind of separator is specified, the
307           body is translated to contain the specified line endings.
308
309           example:
310
311            my $body = $msg->decoded->eol('NATIVE');
312            my $char = $msg->decoded->eol;
313
314       $obj->foreachLine(CODE)
315           Inherited, see "Constructing a body" in
316           Mail::Message::Body::Construct
317
318       $obj->stripSignature(%options)
319           Inherited, see "Constructing a body" in
320           Mail::Message::Body::Construct
321
322       $obj->unify($body)
323           Inherited, see "Constructing a body" in Mail::Message::Body::Encode
324
325   The body
326       $obj->isDelayed()
327           Returns a true or false value, depending on whether the body of
328           this message has been read from file.  This can only false for a
329           Mail::Message::Body::Delayed.
330
331       $obj->isMultipart()
332           Returns whether this message-body contains parts which are messages
333           by themselves.
334
335       $obj->isNested()
336           Only true for a message body which contains exactly one sub-
337           message: the "Mail::Message::Body::Nested" body type.
338
339       $obj->message( [$message] )
340           Returns the message (or message part) where this body belongs to,
341           optionally setting it to a new $message first.  If "undef" is
342           passed, the body will be disconnected from the message.
343
344       $obj->partNumberOf($part)
345           Returns a string for multiparts and nested, otherwise an error.  It
346           is used in Mail::Message::partNumber().
347
348   About the payload
349       $obj->charset()
350           Returns the character set which is used in the text body as string.
351           This is part of the result of what the "type" method returns.
352
353       $obj->checked( [BOOLEAN] )
354           Returns whether the body encoding has been checked or not
355           (optionally after setting the flag to a new value).
356
357       $obj->contentId( [STRING|$field] )
358           Returns (optionally after setting) the id (unique reference) of a
359           message part.  The related header field is "Content-ID".  A
360           Mail::Message::Field object is returned (which stringifies into the
361           field content).  The field content will be "none" if no disposition
362           was specified.
363
364           The argument can be a STRING (which is converted into a field), or
365           a fully prepared header $field.
366
367       $obj->description( [STRING|$field] )
368           Returns (optionally after setting) the informal description of the
369           body content.  The related header field is "Content-Description".
370           A Mail::Message::Field object is returned (which stringifies into
371           the field content).  The field content will be "none" if no
372           disposition was specified.
373
374           The argument can be a STRING (which is converted into a field), or
375           a fully prepared header field.
376
377       $obj->disposition( [STRING|$field] )
378           Returns (optionally after setting) how the message can be disposed
379           (unpacked).  The related header field is "Content-Disposition".  A
380           Mail::Message::Field object is returned (which stringifies into the
381           field content).  The field content will be "none" if no disposition
382           was specified.
383
384           The argument can be a STRING (which is converted into a field), or
385           a fully prepared header field.
386
387       $obj->dispositionFilename( [$directory] )
388           Inherited, see "About the payload" in Mail::Message::Body::Encode
389
390       $obj->isBinary()
391           Inherited, see "About the payload" in Mail::Message::Body::Encode
392
393       $obj->isText()
394           Inherited, see "About the payload" in Mail::Message::Body::Encode
395
396       $obj->mimeType()
397           Returns a MIME::Type object which is related to this body's type.
398           This differs from the "type" method, which results in a
399           Mail::Message::Field.
400
401           example:
402
403            if($body->mimeType eq 'text/html') {...}
404            print $body->mimeType->simplified;
405
406       $obj->nrLines()
407           Returns the number of lines in the message body.  For multi-part
408           messages, this includes the header lines and boundaries of all the
409           parts.
410
411       $obj->size()
412           The total number of bytes in the message body. The size of the body
413           is computed in the shape it is in. For example, if this is a base64
414           encoded message, the size of the encoded data is returned; you may
415           want to call Mail::Message::decoded() first.
416
417       $obj->transferEncoding( [STRING|$field] )
418           Returns the transfer-encoding of the data within this body as
419           Mail::Message::Field (which stringifies to its content).  If it
420           needs to be changed, call the encode() or decoded() method.  When
421           no encoding is present, the field contains the text "none".
422
423           The optional STRING or $field enforces a new encoding to be set,
424           without the actual required translations.
425
426           example:
427
428            my $transfer = $msg->decoded->transferEncoding;
429            $transfer->print;   # --> Content-Encoding: base64
430            print $transfer;    # --> base64
431
432            if($msg->body->transferEncoding eq 'none') {...}
433
434       $obj->type( [STRING|$field] )
435           Returns the type of information the body contains as
436           Mail::Message::Field object.  The type is taken from the header
437           field "Content-Type". If the header did not contain that field,
438           then you will get a default field containing "text/plain".
439
440           You usually can better use mimeType(), because that will return a
441           clever object with type information.
442
443           example:
444
445            my $msg     = $folder->message(6);
446            $msg->get('Content-Type')->print;
447               # --> Content-Type: text/plain; charset="us-ascii"
448
449            my $content = $msg->decoded;
450            my $type    = $content->type;
451
452            print "This is a $type message\n";
453               # --> This is a text/plain; charset="us-ascii" message
454
455            print "This is a ", $type->body, "message\n";
456               # --> This is a text/plain message
457
458            print "Comment: ", $type->comment, "\n";
459               # --> Comment: charset="us-ascii"
460
461   Access to the payload
462       $obj->endsOnNewline()
463           Returns whether the last line of the body is terminated by a new-
464           line (in transport it will become a CRLF).  An empty body will
465           return true as well: the newline comes from the line before it.
466
467       $obj->file()
468           Return the content of the body as a file handle.  The returned
469           stream may be a real file, or a simulated file in any form that
470           Perl supports.  While you may not be able to write to the file
471           handle, you can read from it.
472
473           WARNING: Even if the file handle supports writing, do not write to
474           the file handle. If you do, some of the internal values of the
475           Mail::Message::Body may not be updated.
476
477       $obj->lines()
478           Return the content of the body as a list of lines (in LIST context)
479           or a reference to an array of lines (in SCALAR context).  In scalar
480           context the array of lines is cached to avoid needless copying and
481           therefore provide much faster access for large messages.
482
483           To just get the number of lines in the body, use the nrLines()
484           method, which is usually much more efficient.
485
486           BE WARNED: For some types of bodies the reference will refer to the
487           original data. You must not change the referenced data! If you do,
488           some of the essential internal variables of the Mail::Message::Body
489           may not be updated.
490
491           example:
492
493            my @lines    = $body->lines;     # copies lines
494            my $line3    = ($body->lines)[3] # only one copy
495            print $lines[0];
496
497            my $linesref = $body->lines;     # reference to originals
498            my $line3    = $body->lines->[3] # only one copy (faster)
499            print $linesref->[0];
500
501            print $body->[0];                # by overloading
502
503       $obj->print( [$fh] )
504           Print the body to the specified $fh (defaults to the selected
505           handle).  The handle may be a GLOB, an IO::File object, or... any
506           object with a print() method will do.  Nothing useful is returned.
507
508       $obj->printEscapedFrom($fh)
509           Print the body to the specified $fh but all lines which start with
510           'From ' (optionally already preceded by >'s) will habe an > added
511           in front.  Nothing useful is returned.
512
513       $obj->string()
514           Return the content of the body as a scalar (a single string).  This
515           is a copy of the internally kept information.
516
517           example:
518
519            my $text = $body->string;
520            print "Body: $body\n";     # by overloading
521
522       $obj->stripTrailingNewline()
523           Remove the newline from the last line, or the last line if it does
524           not contain anything else than a newline.
525
526       $obj->write(%options)
527           Write the content of the body to a file.  Be warned that you may
528           want to decode the body before writing it!
529
530            -Option  --Default
531             filename  <required>
532
533           filename => FILENAME
534
535           example: write the data to a file
536
537            use File::Temp;
538            my $fn = tempfile;
539            $message->decoded->write(filename => $fn)
540               or die "Couldn't write to $fn: $!\n";
541
542           example: using the content-disposition information to write
543
544            use File::Temp;
545            my $dir = tempdir; mkdir $dir or die;
546            my $fn  = $message->body->dispositionFilename($dir);
547            $message->decoded->write(filename => $fn)
548               or die "Couldn't write to $fn: $!\n";
549
550   Internals
551       $obj->addTransferEncHandler( $name, <$class|$object> )
552       Mail::Message::Body->addTransferEncHandler( $name, <$class|$object> )
553           Inherited, see "Internals" in Mail::Message::Body::Encode
554
555       $obj->contentInfoFrom($head)
556           Transfer the body related info from the header into this body.
557
558       $obj->contentInfoTo($head)
559           Copy the content information (the "Content-*" fields) into the
560           specified $head.  The body was created from raw data without the
561           required information, which must be added.  See also
562           contentInfoFrom().
563
564       $obj->fileLocation( [$begin, $end] )
565           The location of the body in the file.  Returned a list containing
566           begin and end.  The begin is the offsets of the first byte if the
567           folder used for this body.  The end is the offset of the first byte
568           of the next message.
569
570       $obj->getTransferEncHandler($type)
571           Inherited, see "Internals" in Mail::Message::Body::Encode
572
573       $obj->isModified()
574           Returns whether the body has changed.
575
576       $obj->load()
577           Be sure that the body is loaded.  This returns the loaded body.
578
579       $obj->modified( [BOOLEAN] )
580           Change the body modification flag.  This will force a re-write of
581           the body to a folder file when it is closed.  It is quite dangerous
582           to change the body: the same body may be shared between messages
583           within your program.
584
585           Especially be warned that you have to change the message-id when
586           you change the body of the message: no two messages should have the
587           same id.
588
589           Without value, the current setting is returned, although you can
590           better use isModified().
591
592       $obj->moveLocation( [$distance] )
593           Move the registration of the message to a new location over
594           $distance.  This is called when the message is written to a new
595           version of the same folder-file.
596
597       $obj->read( $parser, $head, $bodytype, [$chars, [$lines]] )
598           Read the body with the $parser from file. The implementation of
599           this method will differ between types of bodies.  The $bodytype
600           argument is a class name or a code reference of a routine which can
601           produce a class name, and is used in multipart bodies to determine
602           the type of the body for each part.
603
604           The $chars argument is the estimated number of bytes in the body,
605           or "undef" when this is not known.  This data can sometimes be
606           derived from the header (the "Content-Length" line) or file-size.
607
608           The second argument is the estimated number of $lines of the body.
609           It is less useful than the $chars but may be of help determining
610           whether the message separator is trustworthy.  This value may be
611           found in the "Lines" field of the header.
612
613   Error handling
614       Extends "Error handling" in Mail::Reporter.
615
616       $obj->AUTOLOAD()
617           When an unknown method is called on a message body object, this may
618           not be problematic.  For performance reasons, some methods are
619           implemented in separate files, and only demand-loaded.  If this
620           delayed compilation of additional modules does not help, an error
621           will be produced.
622
623       $obj->addReport($object)
624           Inherited, see "Error handling" in Mail::Reporter
625
626       $obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level,
627       $callback] )
628       Mail::Message::Body->defaultTrace( [$level]|[$loglevel,
629       $tracelevel]|[$level, $callback] )
630           Inherited, see "Error handling" in Mail::Reporter
631
632       $obj->errors()
633           Inherited, see "Error handling" in Mail::Reporter
634
635       $obj->log( [$level, [$strings]] )
636       Mail::Message::Body->log( [$level, [$strings]] )
637           Inherited, see "Error handling" in Mail::Reporter
638
639       $obj->logPriority($level)
640       Mail::Message::Body->logPriority($level)
641           Inherited, see "Error handling" in Mail::Reporter
642
643       $obj->logSettings()
644           Inherited, see "Error handling" in Mail::Reporter
645
646       $obj->notImplemented()
647           Inherited, see "Error handling" in Mail::Reporter
648
649       $obj->report( [$level] )
650           Inherited, see "Error handling" in Mail::Reporter
651
652       $obj->reportAll( [$level] )
653           Inherited, see "Error handling" in Mail::Reporter
654
655       $obj->trace( [$level] )
656           Inherited, see "Error handling" in Mail::Reporter
657
658       $obj->warnings()
659           Inherited, see "Error handling" in Mail::Reporter
660
661   Cleanup
662       Extends "Cleanup" in Mail::Reporter.
663
664       $obj->DESTROY()
665           Inherited, see "Cleanup" in Mail::Reporter
666

DETAILS

668   Access to the body
669       A body can be contained in a message, but may also live without a
670       message.  In both cases it stores data, and the same questions can be
671       asked: what type of data it is, how many bytes and lines, what encoding
672       is used.  Any body can be encoded and decoded, returning a new body
673       object.  However, bodies which are part of a message will always be in
674       a shape that they can be written to a file or send to somewhere: they
675       will be encoded if needed.
676
677       . Example
678
679        my $body    = Mail::Message::Body::String->new(mime_type => 'image/gif');
680        $body->print(\*OUT);    # this is binary image data...
681
682        my $encoded = $message->body($body);
683        $encoded->print(\*OUT); # ascii data, encoded image
684
685       Now encoded refers to the body of the $message which is the content of
686       $body in a shape that it can be transmitted.  Usually "base64" encoding
687       is used.
688
689   Body class implementation
690       The body of a message can be stored in many ways.  Roughly, the
691       implementations can be split in two groups: the data collectors and the
692       complex bodies. The primer implement various ways to access data, and
693       are full compatible: they only differ in performance and memory
694       footprint under different circumstances.  The latter are created to
695       handle complex multiparts and lazy extraction.
696
697       Data collector bodies
698
699       •   Mail::Message::Body::String
700
701           The whole message body is stored in one scalar.  Small messages can
702           be contained this way without performance penalties.
703
704       •   Mail::Message::Body::Lines
705
706           Each line of the message body is stored as single scalar.  This is
707           a useful representation for a detailed look in the message body,
708           which is usually line-organized.
709
710       •   Mail::Message::Body::File
711
712           The message body is stored in an external temporary file.  This
713           type of storage is especially useful when the body is large, the
714           total folder is large, or memory is limited.
715
716       •   Mail::Message::Body::InFolder
717
718           NOT IMPLEMENTED YET.  The message is kept in the folder, and is
719           only taken out when the content is changed.
720
721       •   Mail::Message::Body::External
722
723           NOT IMPLEMENTED YET.  The message is kept in a separate file,
724           usually because the message body is large.  The difference with the
725           "::External" object is that this external storage stays this way
726           between closing and opening of a folder. The "::External" object
727           only uses a file when the folder is open.
728
729       Complex bodies
730
731       •   Mail::Message::Body::Delayed
732
733           The message-body is not yet read, but the exact location of the
734           body is known so the message can be read when needed.  This is part
735           of the lazy extraction mechanism.  Once extracted, the object can
736           become any simple or complex body.
737
738       •   Mail::Message::Body::Multipart
739
740           The message body contains a set of sub-messages (which can contain
741           multipart bodies themselves).  Each sub-message is an instance of
742           Mail::Message::Part, which is an extension of Mail::Message.
743
744       •   Mail::Message::Body::Nested
745
746           Nested messages, like "message/rfc822": they contain a message in
747           the body.  For most code, they simply behave like multiparts.
748
749   Character encoding PERL
750       A body object can be part of a message, or stand-alone.  In case it is
751       a part of a message, the "transport encoding" and the content must be
752       in a shape that the data can be transported via SMTP.
753
754       However, when you want to process the body data in simple Perl (or when
755       you construct the body data from normal Perl strings), you need to be
756       aware of Perl's internal representation of strings. That can either be
757       latin1 or utf8 (not real UTF-8, but something alike, see the
758       perlunicode manual page)  So, before you start using the data from an
759       incoming message, do
760
761           my $body  = $msg->decoded;
762           my @lines = $body->lines;
763
764       Now, the body has character-set 'PERL' (when it is text)
765
766       When you create a new body which contains text content (the default),
767       it will be created with character-set 'PERL' unless you specify a
768       character-set explicitly.
769
770          my $body = Mail::Box::Body::Lines->new(data => \@lines);
771          # now mime=text/plain, charset=PERL
772
773          my $msg  = Mail::Message->buildFromBody($body);
774          $msg->body($body);
775          $msg->attach($body);   # etc
776          # these all will convert the charset=PERL into real utf-8
777

DIAGNOSTICS

779       Warning: Charset $name is not known
780           The encoding or decoding of a message body encounters a character
781           set which is not understood by Perl's Encode module.
782
783       Warning: No decoder defined for transfer encoding $name.
784           The data (message body) is encoded in a way which is not currently
785           understood, therefore no decoding (or recoding) can take place.
786
787       Warning: No encoder defined for transfer encoding $name.
788           The data (message body) has been decoded, but the required encoding
789           is unknown.  The decoded data is returned.
790
791       Error: Package $package does not implement $method.
792           Fatal error: the specific package (or one of its superclasses) does
793           not implement this method where it should. This message means that
794           some other related classes do implement this method however the
795           class at hand does not.  Probably you should investigate this and
796           probably inform the author of the package.
797
798       Warning: Unknown line terminator $eol ignored
799

SEE ALSO

801       This module is part of Mail-Message distribution version 3.012, built
802       on February 11, 2022. Website: http://perl.overmeer.net/CPAN/
803

LICENSE

805       Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>]. For other
806       contributors see ChangeLog.
807
808       This program is free software; you can redistribute it and/or modify it
809       under the same terms as Perl itself.  See http://dev.perl.org/licenses/
810
811
812
813perl v5.36.0                      2023-01-20            Mail::Message::Body(3)
Impressum