NAME
Mail::Message::Body::Multipart - body of a message with attachments
CLASS HIERARCHY
Mail::Message::Body::Multipart
is a Mail::Message::Body + ::Construct + ::Encode
is a Mail::Reporter
SYNOPSIS
See Mail::Message::Body, plus
if($body->isMultipart) {
my @attachments = $body->parts;
my $attachment3 = $body->part(2);
my $before = $body->preamble;
my $after = $body->epiloque;
$body->part(1)->delete;
}
DESCRIPTION
READ Mail::Message::Body
FIRST. This manual-page only describes the extentions to the default body functionality.
The body (content) of a message can be stored in various ways. In this manual-page you find the description of extra functionality you have when a message contains attachments (parts).
METHOD INDEX
Methods prefixed with an abbreviation are described in Mail::Reporter (MR), Mail::Message::Body (MMB), Mail::Message::Body::Construct (MMBC), Mail::Message::Body::Encode (MMBE).
The general methods for Mail::Message::Body::Multipart
objects:
attach MESSAGES|BODIES MMB lines
boundary [STRING] MR log [LEVEL [,STRINGS]]
MMB charset MMB message [MESSAGE]
MMBE check MMB mimeType
MMB checked [BOOLEAN] MMB modified [BOOL]
MMBC concatenate COMPONENTS new OPTIONS
MMB decoded OPTIONS MMB nrLines
MMB disposition [STRING|FIELD] part INDEX
MMBE encode OPTIONS parts
MMBE encoded preamble
MMB eol ['CR'|'LF'|'CRLF'|'NATI... MMB print [FILE]
epilogue MMB reply OPTIONS
MR errors MR report [LEVEL]
MMB file MR reportAll [LEVEL]
foreachComponent CODE MMB size
MMBC foreachLine CODE MMB string
MMBE isBinary stripSignature OPTIONS
MMB isDelayed MR trace [LEVEL]
MMB isMultipart MMB transferEncoding [STRING|FI...
MMB isNested MMB type
MMBE isText MR warnings
The extra methods for extension writers:
MR AUTOLOAD MMB load
MR DESTROY MR logPriority LEVEL
MMBE addTransferEncHandler NAME,... MR logSettings
MMB clone MMB moveLocation [DISTANCE]
MMB fileLocation [BEGIN,END] MR notImplemented
MMBE getTransferEncHandler TYPE MMB read PARSER, HEAD, BODYTYPE...
MR inGlobalDestruction MMBE unify BODY
METHODS
- new OPTIONS
-
OPTION DESCRIBED IN DEFAULT based_on Mail::Message::Body undef boundary Mail::Message::Body::Multipart undef charset Mail::Message::Body 'us-ascii' data Mail::Message::Body undef disposition Mail::Message::Body undef epilogue Mail::Message::Body::Multipart undef log Mail::Reporter 'WARNINGS' message Mail::Message::Body undef mime_type Mail::Message::Body 'multipart/mixed' modified Mail::Message::Body 0 parts Mail::Message::Body::Multipart undef preamble Mail::Message::Body::Multipart undef trace Mail::Reporter 'WARNINGS' transfer_encoding Mail::Message::Body 'NONE'
boundary => STRING
Seperatory to be used between parts of the message. This seperator must be unique in case the message contains nested multiparts (which are not unusual). If <undef>, a nice unique boundary will be generated.
epilogue => BODY
The text which is included in the main body after the final boundary. This is usually empty, and has no meaning.
parts => ARRAY-OF-(MESSAGES|BODIES)
Specifies an initial list of parts in this body. These may be full MESSAGES, or BODIES which transformed into messages before use. Each message is coerced into a
Mail::Message::Part
object.MIME::Entity
andMail::Internet
objects are acceptable in the list, because they are coerceable intoMail::Message::Part
's. Values ofundef
will be skipped silently.preamble => BODY
The text which is included in the body before the first part. It is common use to include a text to warn the user that the message is a multipart. However, this was useful in earlier days: most mail agents are very capable in warning the user themselves.
Example:
my $intro = Mail::Message::Body->new(data => ['part one']); my $pgp = Mail::Message::Body->new(data => ['part three']); my $body = Mail::Message::Body::Multipart->new ( boundary => time . '--it-s-mine' , parts => [ $intro, $folder->message(3)->decoded, $pgp ] );
- foreachComponent CODE
-
Execute the CODE for each component of the message: the preamble, the epilogue, and each of the parts.
Each component is a body and is passed as second argument to the CODE. The first argument is a reference to this multi-parted body. The CODE returns a body object. When any of the returned bodies differs from the body which was passed, then a new multi-part body will be returned. Reference to the not-changed bodies and the changed bodies will be included in that new multi-part.
Example:
my $checked = $multi->foreachComponent(sub {$_[1]->check});
- preamble
-
Returns the preamble (the text before the first message part --attachment), The preamble is stored in a BODY object, and its encoding is derived from the multipart header.
- epilogue
-
Returns the epilogue (the text after the last message part --attachment), The preamble is stored in a BODY object, and its encoding is derived from the multipart header.
- parts
-
In LIST context, the current list of parts (attachments) is returned, In SCALAR context the length of the list is returned, so the number of parts for this multiparted body. This is normal behavior of Perl.
Examples:
print "Number of attachments: ", scalar $message->body->parts; foreach my $part ($message->body->parts) { print "Type: ", $part->get('Content-Type'); }
- part INDEX
-
Returns only the part with the specified INDEX. You may use a negative value here, which counts from the back in the list.
Example:
$message->body->part(2)->print;
- boundary [STRING]
-
Returns the boundary which is used to separate the parts in this body. If none was read from file, then one will be assigned. With STRING you explicitly set the boundary to be used.
- attach MESSAGES|BODIES
-
Attach a list of MESSAGES to this multipart. A new body is returned. When you specify BODIES, they will first be translated into real messages.
MIME::Entity
andMail::Internet
objects may be specified too. In any case, the parts will be coerced intoMail::Message::Part
's. - stripSignature OPTIONS
-
Removes all parts which contains data usually defined as being signature. The
MIME::Type
module provides this knowledge. A new multipart is returned, containing the remaining parts. No OPTIONS are defined yet, although some may be specified, because this method overrules thestripSignature
method for normal bodies.
METHODS for extension writers
SEE ALSO
For support and additional documentation, see http://perl.overmeer.net/mailbox/
AUTHOR
Mark Overmeer (mailbox@overmeer.net). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
VERSION
This code is beta, version 2.015.
Copyright (c) 2001-2002 Mark Overmeer. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.