Mail::...Message(3pm)
๐ Mail::Box::Dir::Message ๐
okay bestie, so this is a page from the User Contributed Perl Documentation โ yes, the Mail::...Message(3pm) situation โ and it's all about Mail::Box::Dir::Message. Tea time. โโจ
๐ธ NAME ๐ธ
Mail::Box::Dir::Message โ literally just one message, sitting in a folder that's organized as a directory.
๐ฆ INHERITANCE ๐ฆ
the family tree, no cap ๐ณ
Mail::Box::Dir::Message
is a Mail::Box::Message
is a Mail::Message
is a Mail::Reporter
Mail::Box::Dir::Message is extended by
Mail::Box::MH::Message
Mail::Box::Maildir::Message
so it is a Mail::Box::Message, which is a Mail::Message, which is a Mail::Reporter. generational slay. ๐
โจ SYNOPSIS โจ
the vibe check, in code form:
my $folder = new Mail::Box::MH ...
my $message = $folder->message(10);
grab a folder, ask it for message number ten, boom. that's the whole plot. ๐
๐ DESCRIPTION ๐
Mail::Box::Dir::Message is the base class for one message inside a folder that's organized as a directory โ which means each message gets its own separate file. one file per message, we love a system with boundaries. ๐
heads up, bestie: there are no objects of type Mail::Box::Dir::Message. like, none. zero. it's abstract, okay? only the extensions are allowed to actually be created. it's giving "template, not a personality." ๐ญ
so at the moment, three of these extended message types are actually implemented:
Mail::Box::MH::Messageโ represents one message in aMail::Box::MHfolder. MH folders are *very, very simple*โฆ which is honestly why they're not sophisticated and also not fast. no shade, just facts. ๐Mail::Box::Maildir::Messageโ represents one message in aMail::Box::Maildirfolder. the flags are kept right there in the message's filename. and it's stateless, so you will never lose a message. not me being emotionally attached to a storage format ๐ฅนโจMail::Box::Netzwert::Messageโ represents one message in aMail::Box::Netzwertfolder. the advantage? it stores pre-parsed information in the message file. the disadvantage? the code is not GPLed (yet). ๐
Extends "DESCRIPTION" in Mail::Box::Message.
โฆmore parts incoming, don't go anywhere bestie ๐ซถ
โจ METHODS โจ
Extends "METHODS" in Mail::Box::Message. So yeah bestie, everything from the parent is in here too, plus the new stuff. ๐ซถ
๐๏ธ Constructors ๐๏ธ
Extends "Constructors" in Mail::Box::Message.
$obj->clone(%options)โ inherited, see "Constructors" inMail::Message. ๐$class->new(%options)โ makes you a message, in a directory-organized folder. It improves on the base version, so go peep "Constructors" inMail::Reportertoo.
Here's the whole option roster, no skips, no gatekeeping:
bodyโ defined inMail::Message, defaults toundef๐ธbody_typeโ defined inMail::Box::Message, defaults to<from folder>โจdeletedโ defined inMail::Message, defaults tofalse๐field_typeโ defined inMail::Message, defaults toundef๐ฆfilenameโ defaults toundef๐fix_headerโ defaults tofalse๐folderโ defined inMail::Box::Message, required (it's giving non-negotiable, bestie) ๐headโ defined inMail::Message, defaults toundefโญhead_typeโ defined inMail::Message, defaults toMail::Message::Head::Complete๐labelsโ defined inMail::Message, defaults to+{}๐messageIdโ defined inMail::Message, defaults toundef๐งmessage_idโ defined inMail::Message, defaults toundef๐modifiedโ defined inMail::Message, defaults tofalse๐ซถsizeโ defined inMail::Box::Message, defaults toundefโจtrustedโ defined inMail::Message, defaults tofalse๐ฅ
And now each one of those, in detail:
body => $objectโ the body, obviously, it's right there in the name. ๐ญbody_type => CODE|$classโ how you want the body typed up.deleted => BOOLEANโ is it deleted? Yes or no, boo.field_type => $classโ the class handling fields.filename => $fileโ the$filewhere the message is stored in. ๐fix_header => BOOLEANโ seeMail::Box::new(fix_headers).folder => $folderโ the folder. The whole point. โจhead => $objectโ the head object.head_type => $classโ which class the head should be.labels => \@pairs|\%settingsโ labels, as pairs or settings.messageId => $idโ the message id.message_id => $idโ also the message id. Not me writing it twice, that's just genuinely what it says. ๐modified => BOOLEANโ touched or untouched.size => $bytesโ size in bytes, periodt.trusted => BOOLEANโ do we trust it or nah.
๐ Attributes ๐
Extends "Attributes" in Mail::Box::Message.
$obj->bodyType()โ inherited, see "Attributes" inMail::Message.$obj->fieldType()โ inherited, see "Attributes" inMail::Message.$obj->filename( [$filename] )โ hands you the name of the file where this message is actually stored. And it returnsundefwhen the message isn't stored in a file at all. The way that is so honest of it. ๐ซถ$obj->fixHeader()โ returnstruewhen the folder is in fixing mode. โจ$obj->folder( [$folder] )โ inherited, see "Attributes" inMail::Box::Message.$obj->headType()โ inherited, see "Attributes" inMail::Message.$obj->messageId()โ inherited, see "Attributes" inMail::Message.$obj->seqnr( [$integer] )โ inherited, see "Attributes" inMail::Box::Message.
๐ Constructing a message ๐
Extends "Constructing a message" in Mail::Box::Message.
$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::Box::Message.
$obj->container()โ inherited, see "The message" inMail::Message.$obj->copyTo($folder, %options)โ inherited, see "The message" inMail::Box::Message.$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)โ inherited, see "The message" inMail::Box::Message.$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::Box::Message.
$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::Box::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::Box::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, see "Flags" inMail::Message.$obj->statusToLabels()โ inherited, see "Flags" inMail::Message.
๐ The whole message as text ๐
Extends "The whole message as text" in Mail::Box::Message.
$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::Box::Message.
$obj->clonedFrom()โ inherited, see "Internals" inMail::Message.$class->coerce($message, %options)โ inherited, see "Internals" inMail::Message.$obj->create($filename)โ creates the message in the file you point at. Okay so real talk: if the message already has a filename and it's not modified, then a move is attempted. Otherwise the message gets printed to the file. And if the$filenamealready exists for this message, literally nothing happens โ nothing is done. In any case, the new$filenamegets set as well. That's the whole deal. โจ$obj->diskDelete()โ inherited, see "Internals" inMail::Box::Message.$obj->isDelayed()โ inherited, see "Internals" inMail::Message.$obj->isTrusted()โ inherited, see "Internals" inMail::Message.$obj->loadBody()โ the autoloader calls this when the body of the message is needed. Main character timing. ๐$obj->loadHead()โ the autoloader calls this when the header of the message is needed. ๐ซถ$obj->parser()โ creates a parser for this message and returns it (-file). ๐ฅ$obj->readBody( $parser, $head, [$bodytype] )โ inherited, see "Internals" inMail::Box::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::Box::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::Box::Message.
$obj->DESTROY()โ inherited, see "Cleanup" inMail::Reporter.$obj->destruct()โ inherited, see "Cleanup" inMail::Box::Message.
๐ DETAILS ๐
Extends "DETAILS" in Mail::Box::Message.
๐ฉบ DIAGNOSTICS ๐ฉบ
okay bestie, these are the error messages this module throws at you when something goes sideways ๐. Each one has a cast location so you know who ratted you out โจ
Error: Cannot include forward source as $kind.โ you passed a forwardincludealternative that is simply not a thing ๐. The valid choices are"NO","INLINE","ATTACH", and"ENCAPSULATE". Cast byforward()๐Error: No default mailer found to send message.โ thesend()machinery looked around and just did not have enough info to auto-find a mail transfer agent for this message ๐ญ. So specify a mailer explicitly with theviaoptions. Cast bysend()๐ฎError: cannot coerce a $type object into a $me object.โ Cast bycoerce()๐ฆError: cannot include reply source as $kind.โ you gave theincludeoption ofreply()an alternative nobody knows โ. The valid choices are"NO","INLINE", and"ATTACH". Cast byreply()๐Error: cannot read message from a $source.โ Cast byread()๐Fault: cannot write message to $file: $!โ when a modified or new message gets written to disk, it's first written to a temporary file in the folder directory. For some reason, creating that file is impossible ๐ซ . Cast bycreate()๐Error: class $package does not implement method $method.โ fatal error time, no cap: that specific$package(or one of its superclasses) does not implement this method where it should ๐ค. What this message means is that some other related classes do implement this method, but 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()๐Fault: failed to rename file $from to $to: $!โ same deal as before, bestie: when a modified or new message is written to disk, it's first written to a temporary file in the folder directory โจ. Then the new file is moved to replace the existing file. Apparently the latter fails ๐. Cast bycreate()๐Error: method bounce requires To, Cc, or Bcc.โ the messagebounce()method forwards a received message off to someone else without modification, so you must specify its new destination, periodt ๐ . If you have the urge not to specify any destination, you probably are looking forreply()instead. And when you wish to modify the content, useforward(). Cast bybounce()๐Error: method forwardAttach requires a preamble.โ Cast byforwardAttach()๐ธError: method forwardEncapsulate requires a preamble.โ Cast byforwardEncapsulate()๐งError: method forwardNo requires a To.โ Cast byforwardNo()โ๏ธError: method forwardNo requires a body.โ Cast byforwardNo()๐ซถError: no rebuild rule $name defined.โ Cast byrebuild()๐งError: only build() Mail::Message's; they are not in a folder yet.โ so you may wish to construct a message that will be stored in some kind of folder, but you need to do that in two steps, bestie ๐ฏ. First, create a normalMail::Message, and then add it to the folder. During thisMail::Box::addMessage()process, the message will getcoerce()-d into the right message type, adding storage information and the like. Cast bybuild()๐Error: please install Email::Simple.โ Cast bycoerce()๐ฆError: please install MIME::Entity.โ Cast bycoerce()๐ฆError: please install Mail::Internet.โ Cast bycoerce()๐ฆError: select parts via '$what'?โ Cast byparts()๐คWarning: skipped unknown key '$key' in build.โ Cast bybuild()โ ๏ธError: unable to read delayed body for message $msgid.โ for some reason the header of the message could be read, but the body cannot ๐ญ. Probably the file has disappeared or the permissions were changed during the progress of the program. Cast byloadBody()๐Error: unable to read delayed head for message $msgid.โ soMail::Boxtries to be lazy with respect to parsing messages ๐ด. When a directory organized folder is opened, only the filenames of messages are collected. On first use, the messages are read from their file. Apparently, a message is used for the first time here, but has disappeared or is unreadable for some other reason. Cast byloadBody()๐ซ
๐ 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 ๐
okay that's literally the whole page bestie, you made it to the end and I'm so proud of you ๐ฅน๐
this was perl v5.40.1, dated 2026-05-09, and it's the Mail::...Message(3pm) manual โ go forth and slay those messages, no cap ๐โจ๐
๐ฆ 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