Mail::Box::Message โ manage one message within a mail-folder
| Use Case | Command | Description |
|---|---|---|
| ๐ Copy message to a folder | $msg->copyTo($folder, %options) | Copy message to an opened folder without deleting original |
| ๐ฆ Move message to a folder | $msg->moveTo($folder, %options) | Move message to a folder (copy + delete original) |
| ๐๏ธ Delete a message | $msg->delete | Mark message as deleted (inherited) |
| ๐ Get the folder of a message | $msg->folder | Return the folder object containing this message |
| ๐ Get message size | $msg->size | Return size of message (head + body) |
| ๐ข Get sequence number | $msg->seqnr | Get or set the message number in the folder |
| ๐งน Destruct a message | $msg->destruct | Free memory by detaching head and body |
# Usually these message objects are created indirectly
use Mail::Box::Manager;
my $manager = Mail::Box::Manager->new;
my $folder = $manager->open(folder => 'Mail/Drafts');
my $msg = $folder->message(1);
$msg->delete;
$msg->size; # and much more
These pages do only describe methods which relate to folders. If you access the knowledge of a message, then read Mail::Message.
During its life, a message will pass through certain stages. These stages were introduced to reduce the access-time to the folder. Changing from stage, the message's body and head objects may change.
Extends "DESCRIPTION" in Mail::Message.
Extends "METHODS" in Mail::Message.
Extends "Constructors" in Mail::Message.
$obj->clone(%options) โ Inherited, see "Constructors" in Mail::MessageMail::Box::Message->new(%options)
| Option | Defined in | Default |
|---|---|---|
body | Mail::Message | undef |
body_type | <from folder> | |
deleted | Mail::Message | <false> |
field_type | Mail::Message | undef |
folder | <required> | |
head | Mail::Message | undef |
head_type | Mail::Message | Mail::Message::Head::Complete |
labels | Mail::Message | {} |
log | Mail::Reporter | 'WARNINGS' |
messageId | Mail::Message | undef |
modified | Mail::Message | <false> |
size | undef | |
trace | Mail::Reporter | 'WARNINGS' |
trusted | Mail::Message | <false> |
body => OBJECT
body_type => CODE|CLASS โ If the body of a message is used delay-loaded, the message must what type of message to become when it finally gets parsed. The folder which is delaying the load must specify the algorithm to determine that type.
deleted => BOOLEAN
field_type => CLASS
folder => FOLDER โ The folder where this message appeared in. The argument is an instance of (a sub-class of) a Mail::Box.
head => OBJECT
head_type => CLASS
labels => ARRAY|HASH
log => LEVEL
messageId => STRING
modified => BOOLEAN
size => INTEGER โ The size of the message, which includes head and body, but without the message separators which may be used by the folder type.
trace => LEVEL
trusted => BOOLEAN
Extends "Constructing a message" in Mail::Message.
$obj->bounce( [<$rg_object|%options>] ) โ Inherited, see "Constructing a message" in Mail::Message::Construct::BounceMail::Box::Message->build( [$message|$part|$body], $content ) โ Inherited, see "Constructing a message" in Mail::Message::Construct::BuildMail::Box::Message->buildFromBody($body, [$head], $headers) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Build$obj->forward(%options) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Forward$obj->forwardAttach(%options) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Forward$obj->forwardEncapsulate(%options) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Forward$obj->forwardInline(%options) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Forward$obj->forwardNo(%options) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Forward$obj->forwardPostlude() โ Inherited, see "Constructing a message" in Mail::Message::Construct::Forward$obj->forwardPrelude() โ Inherited, see "Constructing a message" in Mail::Message::Construct::Forward$obj->forwardSubject(STRING) โ Inherited, see "Constructing a message" in Mail::Message::Construct::ForwardMail::Box::Message->read($fh|STRING|SCALAR|ARRAY, %options) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Read$obj->rebuild(%options) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Rebuild$obj->reply(%options) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Reply$obj->replyPrelude( [STRING|$field|$address|ARRAY-$of-$things] ) โ Inherited, see "Constructing a message" in Mail::Message::Construct::Reply$obj->replySubject(STRING) โ Inherited, see "Constructing a message" in Mail::Message::Construct::ReplyMail::Box::Message->replySubject(STRING) โ Inherited, see "Constructing a message" in Mail::Message::Construct::ReplyExtends "The message" in Mail::Message.
$obj->container() โ Inherited, see "The message" in Mail::Message$obj->copyTo($folder, %options) โ Copy the message to the indicated opened $folder, without deleting the original. The coerced message (the clone in the destination folder) is returned.
| Option | Default |
|---|---|
shallow | <false> |
shallow_body | <false> |
shallow_head | <false> |
share | <false> |
shallow => BOOLEAN โ Used for clone(shallow).
shallow_body => BOOLEAN โ Used for clone(shallow_body).
shallow_head => BOOLEAN โ Used for clone(shallow_head).
share => BOOLEAN โ Try to share the physical storage of the message between the two folders. Sometimes, they even may be of different types. When not possible, this options will be silently ignored.
Example:
my $draft = $mgr->open(folder => 'Draft');
$message->copyTo($draft, share => 1);
$obj->folder( [$folder] ) โ In with folder did we detect this message/dummy? This is a reference to the folder-object.$obj->isDummy() โ Inherited, see "The message" in Mail::Message$obj->isPart() โ Inherited, see "The message" in Mail::Message$obj->messageId() โ Inherited, see "The message" in Mail::Message$obj->moveTo($folder, %options) โ Move the message from this folder to the $folder specified. This will create a copy using clone() first. Then, this original message is flagged to get deleted. So until the source folder is closed, two copies of the message may stay in memory. The newly created message clone (part of the destination folder) is returned. All %options are passed to copyTo().
| Option | Default |
|---|---|
shallow_body | <undef> |
share | <true unless shallow_body exists> |
shallow_body => BOOLEAN โ Only create a shallow body, which means that the header can not be reused. A message can therefore not be shared in storage unless explicitly stated.
share => BOOLEAN โ When there is a chance that the original message can be undeleted, then this must be set to false. Otherwise a shallow clone will be made, which will share the header which can be modified in the undeleted message.
Example of moving a message:
my $trash = Mail::Box::Mbox->new(folder => 'trash');
my $t = $msg->moveTo($trash);
Is equivalent to:
my $t = $msg->copyTo($trash, share => 1);
$msg->delete;
$obj->partNumber() โ Inherited, see "The message" in Mail::Message$obj->print( [$fh] ) โ Inherited, see "The message" in Mail::Message$obj->send( [$mailer], %options ) โ Inherited, see "The message" in Mail::Message$obj->seqnr( [$integer] ) โ Get the number of this message is the current folder. It starts counting from zero. Do not change the number.$obj->size() โ Inherited, see "The message" in Mail::Message$obj->toplevel() โ Inherited, see "The message" in Mail::Message$obj->write( [$fh] ) โ Inherited, see "The message" in Mail::MessageExtends "The header" in Mail::Message.
$obj->bcc() โ Inherited, see "The header" in Mail::Message$obj->cc() โ Inherited, see "The header" in Mail::Message$obj->date() โ Inherited, see "The header" in Mail::Message$obj->destinations() โ Inherited, see "The header" in Mail::Message$obj->from() โ Inherited, see "The header" in Mail::Message$obj->get($fieldname) โ Inherited, see "The header" in Mail::Message$obj->guessTimestamp() โ Inherited, see "The header" in Mail::Message$obj->head( [$head] ) โ Inherited, see "The header" in Mail::Message$obj->nrLines() โ Inherited, see "The header" in Mail::Message$obj->sender() โ Inherited, see "The header" in Mail::Message$obj->study($fieldname) โ Inherited, see "The header" in Mail::Message$obj->subject() โ Inherited, see "The header" in Mail::Message$obj->timestamp() โ Inherited, see "The header" in Mail::Message$obj->to() โ Inherited, see "The header" in Mail::MessageExtends "The body" in Mail::Message.
$obj->body( [$body] ) โ Inherited, see "The body" in Mail::Message$obj->contentType() โ Inherited, see "The body" in Mail::Message$obj->decoded(%options) โ Inherited, see "The body" in Mail::Message$obj->encode(%options) โ Inherited, see "The body" in Mail::Message$obj->isMultipart() โ Inherited, see "The body" in Mail::Message$obj->isNested() โ Inherited, see "The body" in Mail::Message$obj->parts( [<'ALL'|'ACTIVE'|'DELETED'|'RECURSE'|$filter>] ) โ Inherited, see "The body" in Mail::MessageExtends "Flags" in Mail::Message.
$obj->delete() โ Inherited, see "Flags" in Mail::Message$obj->deleted( [BOOLEAN] ) โ Inherited, see "Flags" in Mail::Message$obj->isDeleted() โ Inherited, see "Flags" in Mail::Message$obj->isModified() โ Inherited, see "Flags" in Mail::Message$obj->label($label|PAIRS) โ Inherited, see "Flags" in Mail::Message$obj->labels() โ Inherited, see "Flags" in Mail::Message$obj->labelsToStatus() โ Inherited, see "Flags" in Mail::Message$obj->modified( [BOOLEAN] ) โ Inherited, see "Flags" in Mail::Message$obj->statusToLabels() โ Inherited, see "Flags" in Mail::MessageExtends "The whole message as text" in Mail::Message.
$obj->file() โ Inherited, see "The whole message as text" in Mail::Message::Construct::Text$obj->lines() โ Inherited, see "The whole message as text" in Mail::Message::Construct::Text$obj->printStructure( [$fh|undef],[$indent] ) โ Inherited, see "The whole message as text" in Mail::Message::Construct::Text$obj->string() โ Inherited, see "The whole message as text" in Mail::Message::Construct::TextExtends "Internals" in Mail::Message.
$obj->clonedFrom() โ Inherited, see "Internals" in Mail::MessageMail::Box::Message->coerce($message, %options) โ Inherited, see "Internals" in Mail::Message$obj->diskDelete() โ Remove a message from disk. This is not from the folder, but everything else, like parts of the message which are stored outside from the folder.$obj->isDelayed() โ Inherited, see "Internals" in Mail::Message$obj->readBody( $parser, $head, [$bodytype] ) โ Read the body of one message. The $parser gives access to the folder file. The $head has been read with readHead(). The optional $bodytype supplies the class name of the body to be created, or a code reference to a routine which can produce a body type based on the head (passed as first argument). By default, the $bodytype will call Mail::Box::determineBodyType() where the message will be added to.$obj->readFromParser( $parser, [$bodytype] ) โ Inherited, see "Internals" in Mail::Message$obj->readHead( $parser, [$class] ) โ Inherited, see "Internals" in Mail::Message$obj->recursiveRebuildPart($part, %options) โ Inherited, see "Internals" in Mail::Message::Construct::Rebuild$obj->storeBody($body) โ Inherited, see "Internals" in Mail::Message$obj->takeMessageId( [STRING] ) โ Inherited, see "Internals" in Mail::MessageExtends "Error handling" in Mail::Message.
$obj->AUTOLOAD() โ Inherited, see "METHODS" in Mail::Message::Construct$obj->addReport($object) โ Inherited, see "Error handling" in Mail::Reporter$obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) โ Inherited, see "Error handling" in Mail::ReporterMail::Box::Message->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) โ Inherited, see "Error handling" in Mail::Reporter$obj->errors() โ Inherited, see "Error handling" in Mail::Reporter$obj->log( [$level, [$strings]] ) โ Inherited, see "Error handling" in Mail::ReporterMail::Box::Message->log( [$level, [$strings]] ) โ Inherited, see "Error handling" in Mail::Reporter$obj->logPriority($level) โ Inherited, see "Error handling" in Mail::ReporterMail::Box::Message->logPriority($level) โ Inherited, see "Error handling" in Mail::Reporter$obj->logSettings() โ Inherited, see "Error handling" in Mail::Reporter$obj->notImplemented() โ Inherited, see "Error handling" in Mail::Reporter$obj->report( [$level] ) โ Inherited, see "Error handling" in Mail::Reporter$obj->reportAll( [$level] ) โ Inherited, see "Error handling" in Mail::Reporter$obj->shortSize( [$value] ) โ Inherited, see "Error handling" in Mail::MessageMail::Box::Message->shortSize( [$value] ) โ Inherited, see "Error handling" in Mail::Message$obj->shortString() โ Inherited, see "Error handling" in Mail::Message$obj->trace( [$level] ) โ Inherited, see "Error handling" in Mail::Reporter$obj->warnings() โ Inherited, see "Error handling" in Mail::ReporterExtends "Cleanup" in Mail::Message.
$obj->DESTROY() โ Inherited, see "Cleanup" in Mail::Reporter$obj->destruct() โ Removes most of the memory occupied by the message by detaching the header and body. Then, the object changes into a Mail::Box::Message::Destructed which will catch all attempts to access the header and body. Be careful with the usage of this method.Extends "DETAILS" in Mail::Message.
This module is part of Mail-Box distribution version 3.009, built on August 18, 2020. Website: http://perl.overmeer.net/CPAN/
Copyrights 2001-2020 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 http://dev.perl.org/licenses/
Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-27 05:34 @216.73.216.138
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format