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 a Mail::Box::MH folder. 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 a Mail::Box::Maildir folder. 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 a Mail::Box::Netzwert folder. 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" in Mail::Message. ๐Ÿ’…
  • $class->new(%options) โ€” makes you a message, in a directory-organized folder. It improves on the base version, so go peep "Constructors" in Mail::Reporter too.

Here's the whole option roster, no skips, no gatekeeping:

  • body โ€” defined in Mail::Message, defaults to undef ๐ŸŒธ
  • body_type โ€” defined in Mail::Box::Message, defaults to <from folder> โœจ
  • deleted โ€” defined in Mail::Message, defaults to false ๐Ÿ’€
  • field_type โ€” defined in Mail::Message, defaults to undef ๐Ÿฆ‹
  • filename โ€” defaults to undef ๐ŸŽ€
  • fix_header โ€” defaults to false ๐Ÿ™ˆ
  • folder โ€” defined in Mail::Box::Message, required (it's giving non-negotiable, bestie) ๐Ÿ‘‘
  • head โ€” defined in Mail::Message, defaults to undef โญ
  • head_type โ€” defined in Mail::Message, defaults to Mail::Message::Head::Complete ๐ŸŒˆ
  • labels โ€” defined in Mail::Message, defaults to +{} ๐Ÿ“
  • messageId โ€” defined in Mail::Message, defaults to undef ๐Ÿงš
  • message_id โ€” defined in Mail::Message, defaults to undef ๐Ÿ’œ
  • modified โ€” defined in Mail::Message, defaults to false ๐Ÿซถ
  • size โ€” defined in Mail::Box::Message, defaults to undef โœจ
  • trusted โ€” defined in Mail::Message, defaults to false ๐Ÿ”ฅ

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 $file where the message is stored in. ๐Ÿ“
  • fix_header => BOOLEAN โ€” see Mail::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" in Mail::Message.
  • $obj->fieldType() โ€” inherited, see "Attributes" in Mail::Message.
  • $obj->filename( [$filename] ) โ€” hands you the name of the file where this message is actually stored. And it returns undef when the message isn't stored in a file at all. The way that is so honest of it. ๐Ÿซถ
  • $obj->fixHeader() โ€” returns true when the folder is in fixing mode. โœจ
  • $obj->folder( [$folder] ) โ€” inherited, see "Attributes" in Mail::Box::Message.
  • $obj->headType() โ€” inherited, see "Attributes" in Mail::Message.
  • $obj->messageId() โ€” inherited, see "Attributes" in Mail::Message.
  • $obj->seqnr( [$integer] ) โ€” inherited, see "Attributes" in Mail::Box::Message.

๐Ÿ’Œ Constructing a message ๐Ÿ’Œ

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

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

  • $obj->container() โ€” inherited, see "The message" in Mail::Message.
  • $obj->copyTo($folder, %options) โ€” inherited, see "The message" in Mail::Box::Message.
  • $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) โ€” inherited, see "The message" in Mail::Box::Message.
  • $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::Box::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::Message.

๐Ÿฆ‹ The body ๐Ÿฆ‹

Extends "The body" in Mail::Box::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::Box::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::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" 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::Box::Message.

  • $obj->clonedFrom() โ€” inherited, see "Internals" in Mail::Message.
  • $class->coerce($message, %options) โ€” inherited, see "Internals" in Mail::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 $filename already exists for this message, literally nothing happens โ€” nothing is done. In any case, the new $filename gets set as well. That's the whole deal. โœจ
  • $obj->diskDelete() โ€” inherited, see "Internals" in Mail::Box::Message.
  • $obj->isDelayed() โ€” inherited, see "Internals" in Mail::Message.
  • $obj->isTrusted() โ€” inherited, see "Internals" in Mail::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" in Mail::Box::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::Box::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::Box::Message.

  • $obj->DESTROY() โ€” inherited, see "Cleanup" in Mail::Reporter.
  • $obj->destruct() โ€” inherited, see "Cleanup" in Mail::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 forward include alternative that is simply not a thing ๐Ÿ™ˆ. The valid choices are "NO", "INLINE", "ATTACH", and "ENCAPSULATE". Cast by forward() ๐Ÿ’…
  • Error: No default mailer found to send message. โ€” the send() 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 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. โ€” you gave the include option of reply() an alternative nobody knows โœ‹. The valid choices are "NO", "INLINE", and "ATTACH". Cast by reply() ๐Ÿ’œ
  • Error: cannot read message from a $source. โ€” Cast by read() ๐Ÿ“–
  • 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 by create() ๐Ÿ’€
  • 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 by notImplemented() ๐Ÿ‘‘
  • Error: coercion starts with some object, not '$type'. โ€” Cast by coerce() ๐ŸŒˆ
  • 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 by create() ๐Ÿ“
  • Error: method bounce requires To, Cc, or Bcc. โ€” the message bounce() 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 for reply() instead. And 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. โ€” 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 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() โš ๏ธ
  • 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 by loadBody() ๐Ÿ’”
  • Error: unable to read delayed head for message $msgid. โ€” so Mail::Box tries 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 by loadBody() ๐Ÿซ 

๐Ÿ‘€ 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