NAME
Mail::Message::Body::Multipart - body of a message with attachments
CLASS INHERITANCE
Mail::Message::Body::Multipart is a Mail::Message::Body 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->epilogue;
$body->part(1)->delete;
}
DESCRIPTION
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).
METHODS
Initiation
- new OPTIONS
-
OPTION DEFAULT based_on undef boundary undef charset 'us-ascii' checked <false> data undef disposition undef eol 'NATIVE' epilogue undef file undef log 'WARNINGS' message undef mime_type 'multipart/mixed' modified <false> parts undef preamble undef trace 'WARNINGS' transfer_encoding 'NONE'
- based_on => BODY
-
See Mail::Message::Body::new(based_on)
- boundary => STRING
-
Separator to be used between parts of the message. This separator must be unique in case the message contains nested multiparts (which are not unusual). If <undef>, a nice unique boundary will be generated.
- charset => STRING
-
See Mail::Message::Body::new(charset)
- checked => BOOLEAN
-
See Mail::Message::Body::new(checked)
- data => ARRAY-OF-LINES | STRING
-
See Mail::Message::Body::new(data)
- disposition => STRING|FIELD
-
See Mail::Message::Body::new(disposition)
- eol => 'CR'|'LF'|'CRLF'|'NATIVE'
-
See Mail::Message::Body::new(eol)
- epilogue => BODY
-
The text which is included in the main body after the final boundary. This is usually empty, and has no meaning.
- file => FILENAME|FILEHANDLE|IOHANDLE
-
See Mail::Message::Body::new(file)
- log => LEVEL
-
See Mail::Reporter::new(log)
- message => MESSAGE
-
See Mail::Message::Body::new(message)
- mime_type => STRING|FIELD|MIME
-
See Mail::Message::Body::new(mime_type)
- modified => BOOLEAN
-
See Mail::Message::Body::new(modified)
- 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 coercible into Mail::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.
- trace => LEVEL
-
See Mail::Reporter::new(trace)
- transfer_encoding => STRING|FIELD
-
See Mail::Message::Body::new(transfer_encoding)
Examples:
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 ] );
The Body
- clone
-
See Mail::Message::Body::clone()
- decoded OPTIONS
-
See Mail::Message::Body::decoded()
- isDelayed
-
See Mail::Message::Body::isDelayed()
- isMultipart
-
See Mail::Message::Body::isMultipart()
- isNested
-
See Mail::Message::Body::isNested()
- message [MESSAGE]
-
See Mail::Message::Body::message()
- modified [BOOL]
-
See Mail::Message::Body::modified()
- print [FILE]
-
See Mail::Message::Body::print()
About the Payload
- charset
-
See Mail::Message::Body::charset()
- checked [BOOLEAN]
-
See Mail::Message::Body::checked()
- disposition [STRING|FIELD]
-
See Mail::Message::Body::disposition()
- eol ['CR'|'LF'|'CRLF'|'NATIVE']
-
See Mail::Message::Body::eol()
- isBinary
-
See Mail::Message::Body::Encode::isBinary()
- isText
-
See Mail::Message::Body::Encode::isText()
- mimeType
-
See Mail::Message::Body::mimeType()
- nrLines
-
See Mail::Message::Body::nrLines()
- size
-
See Mail::Message::Body::size()
- transferEncoding [STRING|FIELD]
-
See Mail::Message::Body::transferEncoding()
- type
-
See Mail::Message::Body::type()
Access to the Payload
- 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.
- 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.
- file
-
See Mail::Message::Body::file()
- 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.
Examples:
my $checked = $multi->foreachComponent(sub {$_[1]->check});
- lines
-
See Mail::Message::Body::lines()
- 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. Parts which are flagged to be deleted are included in the count.
Example:
$message->body->part(2)->print; $body->part(1)->delete;
- parts ['ALL'|'ACTIVE'|'DELETED'|'RECURSE'|FILTER]
-
Return all parts by default, or when ALL is specified. ACTIVE returns the parts which are not flagged for deletion, as opposite to DELETED. RECURSE descents into all nested multiparts to collect all parts.
You may also specify a code reference which is called for each nested part. The first argument will be the message part. When the code returns true, the part is incorporated in the return list.
Examples:
print "Number of attachments: ", scalar $message->body->parts('ACTIVE'); foreach my $part ($message->body->parts) { print "Type: ", $part->get('Content-Type'); }
- 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.
- string
-
See Mail::Message::Body::string()
Constructing a Body
- addTransferEncHandler NAME, CLASS|OBJECT
-
See Mail::Message::Body::Encode::addTransferEncHandler()
- 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 into Mail::Message::Part's. - check
-
See Mail::Message::Body::Encode::check()
- concatenate COMPONENTS
-
See Mail::Message::Body::Construct::concatenate()
- encode OPTIONS
-
See Mail::Message::Body::Encode::encode()
- encoded
-
See Mail::Message::Body::Encode::encoded()
- foreachLine CODE
-
See Mail::Message::Body::Construct::foreachLine()
- getTransferEncHandler TYPE
-
See Mail::Message::Body::Encode::getTransferEncHandler()
- 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.OPTION DEFAULT max_lines 10 pattern qr/^--\s?$/ result_type <same as current>
- unify BODY
-
See Mail::Message::Body::Encode::unify()
Reading and Writing [internals]
- AUTOLOAD
-
See Mail::Message::Body::AUTOLOAD()
- fileLocation [BEGIN,END]
-
See Mail::Message::Body::fileLocation()
- load
-
See Mail::Message::Body::load()
- moveLocation [DISTANCE]
-
See Mail::Message::Body::moveLocation()
- read PARSER, HEAD, BODYTYPE [,CHARS [,LINES]]
-
See Mail::Message::Body::read()
Logging and Tracing
- defaultTrace [LEVEL, [LEVEL]
-
See Mail::Reporter::defaultTrace()
- errors
-
See Mail::Reporter::errors()
- log [LEVEL [,STRINGS]]
-
See Mail::Reporter::log()
- report [LEVEL]
-
See Mail::Reporter::report()
- reportAll [LEVEL]
-
See Mail::Reporter::reportAll()
- trace [LEVEL]
-
See Mail::Reporter::trace()
- warnings
-
See Mail::Reporter::warnings()
Other Methods
- DESTROY
-
See Mail::Reporter::DESTROY()
- inGlobalDestruction
-
See Mail::Reporter::inGlobalDestruction()
- logPriority LEVEL
-
See Mail::Reporter::logPriority()
- logSettings
-
See Mail::Reporter::logSettings()
- notImplemented
-
See Mail::Reporter::notImplemented()
SEE ALSO
A good start to read is Mail::Box-Overview. More documentation and a mailinglist are available from the project's website at http://perl.overmeer.net/mailbox/.
AUTHOR
Mark Overmeer (mark@overmeer.net) with the help of many.
VERSION
This code is beta, version 2.025.
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.