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
- is a
Mail::Box::Messageis extended byMail::Box::Dir::MessageMail::Box::File::MessageMail::Box::Message::DestructedMail::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"inMail::Message$class->new(%options)β Inherited π«, see"Constructors"inMail::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 inMail::Message, defaultundef)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 inMail::Message, defaultfalse)field_type=> $class β (defined inMail::Message, defaultundef)folder=> $folder β (default<required>) This is the$folderwhere this message appeared in. The argument is an instance of (a sub-class of) aMail::Box. πhead=> $object β (defined inMail::Message, defaultundef)head_type=> $class β (defined inMail::Message, defaultMail::Message::Head::Complete)labels=> @pairs|%settings β (defined inMail::Message, default+{})messageId=> $id β (defined inMail::Message, defaultundef)message_id=> $id β (defined inMail::Message, defaultundef)modified=> BOOLEAN β (defined inMail::Message, defaultfalse)size=> $bytes β (defaultundef) 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 inMail::Message, defaultfalse)
π Attributes π
Extends "Attributes" in Mail::Message.
$obj->bodyType()β Inherited π«, see"Attributes"inMail::Message$obj->fieldType()β Inherited π«, see"Attributes"inMail::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"inMail::Message$obj->messageId()β Inherited π«, see"Attributes"inMail::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"inMail::Message::Construct::Bounce$class->build([$message|$part|$body], @fields, %options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Build$class->buildFromBody($body, [$head], $headers)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Build$obj->forward(%options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Forward$obj->forwardAttach(%options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Forward$obj->forwardEncapsulate(%options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Forward$obj->forwardInline(%options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Forward$obj->forwardNo(%options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Forward$obj->forwardPostlude()β Inherited π«, see"Constructing a message"inMail::Message::Construct::Forward$obj->forwardPrelude()β Inherited π«, see"Constructing a message"inMail::Message::Construct::Forward$obj->forwardSubject(STRING)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Forward$class->read($fh|$text|\$text|\@lines, %options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Read$obj->rebuild(%options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Rebuild$obj->reply(%options)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Reply$obj->replyPrelude([STRING|$field|$address|\@addrs|\@fields])β Inherited π«, see"Constructing a message"inMail::Message::Construct::Reply$any->replySubject(STRING)β Inherited π«, see"Constructing a message"inMail::Message::Construct::Reply
π The message π
Extends "The message" in Mail::Message.
$obj->container()β Inherited π«, see"The message"inMail::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 β (defaultfalse) Used forclone(shallow).shallow_body=> BOOLEAN β (defaultfalse) Used forclone(shallow_body).shallow_head=> BOOLEAN β (defaultfalse) Used forclone(shallow_head).share=> BOOLEAN β (defaultfalse) 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"inMail::Message$obj->isDummy()β Inherited π«, see"The message"inMail::Message$obj->isPart()β Inherited π«, see"The message"inMail::Message$obj->moveTo($folder, %options)β Move the message from this folder to the$folderspecified. This will create a copy usingclone()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%optionsare passed tocopyTo().
The options for moveTo:
shallow_body=> BOOLEAN β (defaultundef) 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"inMail::Message$obj->print([$fh])β Inherited π«, see"The message"inMail::Message$obj->send([$mailer], %options)β Inherited π«, see"The message"inMail::Message$obj->size()β Inherited π«, see"The message"inMail::Message$obj->toplevel()β Inherited π«, see"The message"inMail::Message$obj->write([$fh])β Inherited π«, see"The message"inMail::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"inMail::Message$obj->cc()β Inherited π«, see"The header"inMail::Message$obj->date()β Inherited π«, see"The header"inMail::Message$obj->destinations()β Inherited π«, see"The header"inMail::Message$obj->from()β Inherited π«, see"The header"inMail::Message$obj->get($fieldname)β Inherited π«, see"The header"inMail::Message$obj->guessTimestamp()β Inherited π«, see"The header"inMail::Message$obj->head([$head])β Inherited π«, see"The header"inMail::Message$obj->nrLines()β Inherited π«, see"The header"inMail::Message$obj->sender()β Inherited π«, see"The header"inMail::Message$obj->study($fieldname)β Inherited π«, see"The header"inMail::Message$obj->subject()β Inherited π«, see"The header"inMail::Message$obj->timestamp()β Inherited π«, see"The header"inMail::Message$obj->to()β Inherited π«, see"The header"inMail::Message
π The body π
Extends "The body" in Mail::Message.
$obj->body([$body])β Inherited π«, see"The body"inMail::Message$obj->contentType()β Inherited π«, see"The body"inMail::Message$obj->decoded(%options)β Inherited π«, see"The body"inMail::Message$obj->encode(%options)β Inherited π«, see"The body"inMail::Message$obj->isMultipart()β Inherited π«, see"The body"inMail::Message$obj->isNested()β Inherited π«, see"The body"inMail::Message$obj->parts([<'ALL'|'ACTIVE'|'DELETED'|'RECURSE'|$filter>])β Inherited π«, see"The body"inMail::Message
π·οΈ Flags π·οΈ
Extends "Flags" in Mail::Message.
$obj->delete()β Inherited π«, see"Flags"inMail::Message$obj->deleted([BOOLEAN])β Inherited π«, see"Flags"inMail::Message$obj->isDeleted()β Inherited π«, see"Flags"inMail::Message$obj->isModified()β Inherited π«, see"Flags"inMail::Message$obj->label($label|PAIRS)β Inherited π«, see"Flags"inMail::Message$obj->labels()β Inherited π«, see"Flags"inMail::Message$obj->labelsToStatus()β Inherited π«, see"Flags"inMail::Message$obj->modified( [BOOLEAN] )β inherited bestie, so go read "Flags" inMail::Messageπ$obj->statusToLabels()β also inherited, same spot: "Flags" inMail::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" inMail::Message::Construct::Text$obj->lines()β inherited, see "The whole message as text" inMail::Message::Construct::Text$obj->printStructure( [$fh|undef],[$indent] )β inherited, see "The whole message as text" inMail::Message::Construct::Text$obj->string()β inherited, see "The whole message as text" inMail::Message::Construct::Text
π§ Internals π§
Extends "Internals" in Mail::Message.
$obj->clonedFrom()β inherited, see "Internals" inMail::Message$class->coerce($message, %options)β inherited, see "Internals" inMail::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" inMail::Message$obj->isTrusted()β inherited, see "Internals" inMail::Message$obj->readBody( $parser, $head, [$bodytype] )β okay so this one reads the body of one message. The$parsergives you access to the folder file. The$headhas already been read withreadHead(). The optional$bodytypesupplies 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" inMail::Message$obj->readHead( $parser, [$class] )β inherited, see "Internals" inMail::Message$obj->recursiveRebuildPart($part, %options)β inherited, see "Internals" inMail::Message::Construct::Rebuild$obj->storeBody($body)β inherited, see "Internals" inMail::Message$obj->takeMessageId( [STRING] )β inherited, see "Internals" inMail::Message
π Error handling π
Extends "Error handling" in Mail::Message.
$obj->AUTOLOAD()β inherited, see "METHODS" inMail::Message::Construct$obj->notImplemented()β inherited, see "Error handling" inMail::Reporter$any->shortSize( [$value] )β inherited, see "Error handling" inMail::Message$obj->shortString()β inherited, see "Error handling" inMail::Message
π§Ή Cleanup π§Ή
Extends "Cleanup" in Mail::Message.
$obj->DESTROY()β inherited, see "Cleanup" inMail::Reporter$obj->destruct()β removes most of the memory occupied by the message by detaching the header and body. Then, the object changes into aMail::Box::Message::Destructedwhich 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 theforward(include). Valid choices are"NO","INLINE","ATTACH", and"ENCAPSULATE". Cast byforward()π - 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 bysend() - Error: cannot coerce a
$typeobject into a$meobject. β cast bycoerce() - Error: cannot include reply source as
$kind. β unknown alternative for the"include"option ofreply(). Valid choices are"NO","INLINE", and"ATTACH". Cast byreply() - Error: cannot read message from a
$source. β cast byread() - Error: class
$packagedoes 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 bynotImplemented() - Error: coercion starts with some object, not '
$type'. β cast bycoerce() - 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 forreply(). When you wish to modify the content, useforward(). Cast bybounce()π - 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
$namedefined. β cast byrebuild() - 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 thisMail::Box::addMessage()process, the message will get coerce()-d into the right message type, adding storage information and the like. Cast bybuild() - 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 byparts() - Warning: skipped unknown key '
$key' in build. β cast bybuild()
π 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
- ubuntu stonking: libmail-box-perl 4.02-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms