Mail::...essage(3pm)

πŸ’– Mail::Box::Message πŸŽ€

User Contributed Perl Documentation β€” yep, this is the Mail::Box::Message page, and she's here to help you manage one message within a mail-folder. Bestie, let's get into it. πŸ’…


πŸ¦‹ NAME πŸ¦‹

Mail::Box::Message β€” manage one message within a mail-folder. That's it. That's the job. πŸ‘‘


🌸 INHERITANCE 🌸

Okay so the family tree, pay attention, it's giving royal lineage:

  • Mail::Box::Message
    • is a Mail::Message
    • is a Mail::Reporter
  • Mail::Box::Message is extended by
    • Mail::Box::Dir::Message
    • Mail::Box::File::Message
    • Mail::Box::Message::Destructed
    • Mail::Box::Net::Message

✨ SYNOPSIS ✨

Lowkey the most important part β€” here's the vibe:

# 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

No cap, that # and much more is doing a lot of heavy lifting, but she's right. πŸ’


πŸ’œ DESCRIPTION πŸ’œ

Okay so real talk: these pages only describe the methods that relate to folders. If you wanna poke at the actual knowledge of a message β€” the juicy content stuff β€” go read Mail::Message instead. Different page, different vibe. 🫢

During its life, a message will pass through certain stages. These stages were introduced to reduce the access-time to the folder. And here's the fun part β€” when a message changes from one stage, the message's body and head objects may change too. So like, it's not the same object the whole way through, it's evolving. Main character energy, honestly. πŸ¦‹

Extends "DESCRIPTION" in Mail::Message.


πŸ”₯ METHODS πŸ”₯

Extends "METHODS" in Mail::Message.


🧡 Constructors ✨

Extends "Constructors" in Mail::Message.

  • $obj->clone(%options) β€” Inherited πŸ’«, see "Constructors" in Mail::Message
  • $class->new(%options) β€” Inherited πŸ’«, see "Constructors" in Mail::Reporter

So new takes a whole lil menu of options, and here's the full spread, bestie β€” no skips, no "and so on":

  • body => $object β€” (defined in Mail::Message, default undef)
  • body_type β€” (default <from folder>) If the body of a message is used delay-loaded, the message must [know] 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 β€” (defined in Mail::Message, default false)
  • field_type => $class β€” (defined in Mail::Message, default undef)
  • folder => $folder β€” (default <required>) This is the $folder where this message appeared in. The argument is an instance of (a sub-class of) a Mail::Box. πŸ‘‘
  • head => $object β€” (defined in Mail::Message, default undef)
  • head_type => $class β€” (defined in Mail::Message, default Mail::Message::Head::Complete)
  • labels => @pairs|%settings β€” (defined in Mail::Message, default +{})
  • messageId => $id β€” (defined in Mail::Message, default undef)
  • message_id => $id β€” (defined in Mail::Message, default undef)
  • modified => BOOLEAN β€” (defined in Mail::Message, default false)
  • size => $bytes β€” (default undef) The size of the message, which includes head and body, but without the message separators which may be used by the folder type. So like, separators don't count, don't @ me. πŸ“
  • trusted => BOOLEAN β€” (defined in Mail::Message, default false)

πŸŽ€ Attributes πŸŽ€

Extends "Attributes" in Mail::Message.

  • $obj->bodyType() β€” Inherited πŸ’«, see "Attributes" in Mail::Message
  • $obj->fieldType() β€” Inherited πŸ’«, see "Attributes" in Mail::Message
  • $obj->folder([$folder]) β€” In which folder did we detect this message/dummy? This is a reference to the folder-object. πŸ“
  • $obj->headType() β€” Inherited πŸ’«, see "Attributes" in Mail::Message
  • $obj->messageId() β€” Inherited πŸ’«, see "Attributes" in Mail::Message
  • $obj->seqnr([$integer]) β€” Get the number of this message in the current folder. It starts counting from zero. ⚠️ Do not change the number. Like, don't. Just don't. πŸ™ˆ

🌈 Constructing a message 🌈

Extends "Constructing a message" in Mail::Message.

Every single one of these is inherited, so go read the page it points at:

  • $obj->bounce([<$rg_object|%options>]) β€” Inherited πŸ’«, see "Constructing a message" in Mail::Message::Construct::Bounce
  • $class->build([$message|$part|$body], @fields, %options) β€” Inherited πŸ’«, see "Constructing a message" in Mail::Message::Construct::Build
  • $class->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::Forward
  • $class->read($fh|$text|\$text|\@lines, %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|\@addrs|\@fields]) β€” Inherited πŸ’«, see "Constructing a message" in Mail::Message::Construct::Reply
  • $any->replySubject(STRING) β€” Inherited πŸ’«, see "Constructing a message" in Mail::Message::Construct::Reply

πŸ’Œ The message πŸ’Œ

Extends "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. Two messages, one you. ✨

The options for copyTo:

  • shallow => BOOLEAN β€” (default false) Used for clone(shallow).
  • shallow_body => BOOLEAN β€” (default false) Used for clone(shallow_body).
  • shallow_head => BOOLEAN β€” (default false) Used for clone(shallow_head).
  • share => BOOLEAN β€” (default false) 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 option will be silently ignored. 🀫

A lil example, since we love a demo:

my $draft = $mgr->open(folder => 'Draft');
$message->copyTo($draft, share => 1);
  • $obj->endsOnNewline() β€” Inherited πŸ’«, see "The message" in Mail::Message
  • $obj->isDummy() β€” Inherited πŸ’«, see "The message" in Mail::Message
  • $obj->isPart() β€” 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().

The options for moveTo:

  • shallow_body => BOOLEAN β€” (default undef) 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 β€” (default <true unless shallow_body exists>) 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. ⚠️ Careful with this one, bestie, it's the spooky one.

🌟 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;

Iconic, honestly. Same thing, two ways to say it. πŸ’…

  • $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->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::Message

🫢 The header 🫢

Extends "The header" in Mail::Message. All of these are inherited, every single one, we're not skipping anybody:

  • $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::Message

πŸ“ The body πŸ“

Extends "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::Message

🏷️ Flags 🏷️

Extends "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 bestie, so go read "Flags" in Mail::Message πŸ’–
  • $obj->statusToLabels() β€” also inherited, same spot: "Flags" in Mail::Message ✨

πŸ¦‹ The whole message as text πŸ¦‹

Extends "The whole message as text" in Mail::Message. iykyk, all the good stuff lives one level up πŸ’…

  • $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::Text

πŸ”§ Internals πŸ”§

Extends "Internals" in Mail::Message.

  • $obj->clonedFrom() β€” inherited, see "Internals" in Mail::Message
  • $class->coerce($message, %options) β€” inherited, see "Internals" in Mail::Message
  • $obj->diskDelete() β€” yeets a message off of disk. Lowkey important: this is not from the folder, it's everything else, like parts of the message that are stored outside from the folder. πŸ—‘οΈ
  • $obj->isDelayed() β€” inherited, see "Internals" in Mail::Message
  • $obj->isTrusted() β€” inherited, see "Internals" in Mail::Message
  • $obj->readBody( $parser, $head, [$bodytype] ) β€” okay so this one reads the body of one message. The $parser gives you access to the folder file. The $head has already been read with readHead(). The optional $bodytype supplies the class name of the body to be created β€” or, plot twist, a code reference to a routine that can produce a body type based on the head (which gets passed as first argument).

By default, the $bodytype will call Mail::Box::determineBodyType() where the message will be added to. Improves base, see "Internals" in Mail::Message 🫢

  • $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::Message

😭 Error handling 😭

Extends "Error handling" in Mail::Message.

  • $obj->AUTOLOAD() β€” inherited, see "METHODS" in Mail::Message::Construct
  • $obj->notImplemented() β€” inherited, see "Error handling" in Mail::Reporter
  • $any->shortSize( [$value] ) β€” inherited, see "Error handling" in Mail::Message
  • $obj->shortString() β€” inherited, see "Error handling" in Mail::Message

🧹 Cleanup 🧹

Extends "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.
⚠️ Bestie, be careful with the usage of this method. It is not a casual little thing to do. Improves base, see "Cleanup" in Mail::Message

πŸ’œ DETAILS πŸ’œ

Extends "DETAILS" in Mail::Message.


🚨 DIAGNOSTICS 🚨

  • Error: Cannot include forward source as $kind. β€” unknown alternative for the forward(include). Valid choices are "NO", "INLINE", "ATTACH", and "ENCAPSULATE". Cast by forward() πŸ’€
  • Error: No default mailer found to send message. β€” the message send() mechanism had not enough information to automatically find a mail transfer agent to sent this message. Specify a mailer explicitly using the "via" options. Cast by send()
  • Error: cannot coerce a $type object into a $me object. β€” cast by coerce()
  • Error: cannot include reply source as $kind. β€” unknown alternative for the "include" option of reply(). Valid choices are "NO", "INLINE", and "ATTACH". Cast by reply()
  • Error: cannot read message from a $source. β€” cast by read()
  • Error: class $package does not implement method $method. β€” fatal error, fr fr: 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. Cast by notImplemented()
  • Error: coercion starts with some object, not '$type'. β€” cast by coerce()
  • Error: method bounce requires To, Cc, or Bcc. β€” the message bounce() method forwards a received message off to someone else without modification; you must specified it's new destination. If you have the urge not to specify any destination, you probably are looking for reply(). When you wish to modify the content, use forward(). Cast by bounce() πŸ€
  • Error: method forwardAttach requires a preamble. β€” cast by forwardAttach()
  • Error: method forwardEncapsulate requires a preamble. β€” cast by forwardEncapsulate()
  • Error: method forwardNo requires a To. β€” cast by forwardNo()
  • Error: method forwardNo requires a body. β€” cast by forwardNo()
  • Error: no rebuild rule $name defined. β€” cast by rebuild()
  • Error: only build() Mail::Message's; they are not in a folder yet. β€” you may wish to construct a message to be stored in a some kind of folder, but you need to do that in two steps. First, create a normal Mail::Message, and then add it to the folder. During this Mail::Box::addMessage() process, the message will get coerce()-d into the right message type, adding storage information and the like. Cast by build()
  • Error: please install Email::Simple. β€” cast by coerce()
  • Error: please install MIME::Entity. β€” cast by coerce()
  • Error: please install Mail::Internet. β€” cast by coerce()
  • Error: select parts via '$what'? β€” cast by parts()
  • Warning: skipped unknown key '$key' in build. β€” cast by build()

🌈 SEE ALSO 🌈

This module is part of Mail-Box version 4.02, built on April 10, 2026. ✨

Website: http://perl.overmeer.net/CPAN/ 🫢


πŸ“œ LICENSE πŸ“œ

For contributors see file ChangeLog.

This software is copyright (c) 2001-2026 by Mark Overmeer. πŸ‘‘

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page bestie, you ate πŸ’… shoutout to perl v5.40.1, the 2026-05-09 date, and the page itself, Mail::...essage(3pm) β€” iconic, no notes πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from