Mail::...Message(3pm)

✨ NAME ✨

Mail::Box::Maildir::Message β€” literally one message, chilling inside a Maildir folder πŸ’Œ

(also hey, this is the Mail::Box::Maildir::Message(3pm) page from the User Contributed Perl Documentation, in case you were wondering where you wandered into 🧚)


🌸 INHERITANCE 🌸

okay bestie, here's the family tree, the whole lineage, the ancestry.com situation:

Mail::Box::Maildir::Message
  is a Mail::Box::Dir::Message
  is a Mail::Box::Message
  is a Mail::Message
  is a Mail::Reporter

so yeah she inherits from Mail::Box::Dir::Message, which inherits from Mail::Box::Message, which inherits from Mail::Message, which inherits from Mail::Reporter 😌 iconic bloodline honestly


πŸŽ€ SYNOPSIS πŸŽ€

the vibe check in code form:

my $folder  = Mail::Box::Maildir->new(...);
my $message = $folder->message(10);

like. make your folder, grab message number 10, boom. that's the whole thing 🫢


πŸ’… DESCRIPTION πŸ’…

so a Mail::Box::Maildir::Message represents one message inside a Mail::Box::Maildir folder β€” and the cute part? every single message gets its own separate file ✨ no sharing, no roommates, just main character energy, one message per file, periodt πŸ’€πŸ’–

this section extends the "DESCRIPTION" in Mail::Box::Dir::Message β€” so if you want the full lore, that's where the rest of the story lives πŸ‘‘

πŸ’– METHODS πŸ’–

Extends "METHODS" in Mail::Box::Dir::Message. So like, everything here is built on top of what the parent class already gives you β€” but there's so much inherited goodness, bestie, let's go through it method by method. 🫢


✨ Constructors ✨

Extends "Constructors" in Mail::Box::Dir::Message.

  • $obj->clone(%options) β€” Inherited, see "Constructors" in Mail::Message
  • $class->new(%options) β€” Inherited, see "Constructors" in Mail::Box::Dir::Message

🌸 Attributes 🌸

Extends "Attributes" in Mail::Box::Dir::Message.

  • $obj->bodyType() β€” Inherited, see "Attributes" in Mail::Message
  • $obj->fieldType() β€” Inherited, see "Attributes" in Mail::Message
  • $obj->filename( [$filename] ) β€” hands you back the current filename for this message. And if you actually pass in the $filename argument? Boom, a brand new filename gets set. For maildir messages this is immediate β€” like, the modification happens right then: there's a rename (a move, fr) from the old name to the new one. Labels may change inside the message object too. Improves base, see "Attributes" in Mail::Box::Dir::Message
  • $obj->fixHeader() β€” Inherited, see "Attributes" in Mail::Box::Dir::Message
  • $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::Dir::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::Dir::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::Dir::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() β€” ok so the filename of a Mail::Box::Maildir::Message has a timestamp baked in. This is a wild guess about when the message was actually sent: it's really the time of receipt, which can be off by seconds or even hours. But honestly? Still a pretty good guess... 😌 And when the message header isn't parsed yet, this date is what gets used. Improves base, 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::Dir::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::Dir::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::Dir::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

🏷️ Labels 🏷️

  • $obj->labelsToFilename() β€” when the labels on a message change, that can mean the message's filename changes too. And the change happens immediately, no waiting around. You get the new filename back (which, yeah, might be exactly the same as the old one). And if the rename is required but it fails? You get undef back. 😭

πŸ”§ Internals πŸ”§

Extends "Internals" in Mail::Box::Dir::Message.

  • $obj->accept( [BOOLEAN] ) β€” accepts a message for the folder. This moves it out of the "new" or "tmp" sub-directories and into the "cur" sub-directory (or back again, when the "BOOLEAN" is "false"). And if you try to accept a message that's already accepted? Literally nothing happens. Chill. 😌
  • $obj->clonedFrom() β€” Inherited, see "Internals" in Mail::Message
  • $class->coerce($message, %options) β€” Inherited, see "Internals" in Mail::Message
  • $obj->create($filename) β€” Inherited, see "Internals" in Mail::Box::Dir::Message
  • $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() β€” Inherited, see "Internals" in Mail::Box::Dir::Message
  • $obj->loadHead() β€” Inherited, see "Internals" in Mail::Box::Dir::Message
  • $obj->parser() β€” Inherited, see "Internals" in Mail::Box::Dir::Message
  • $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::Dir::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::Dir::Message.

  • $obj->DESTROY() β€” Inherited, see "Cleanup" in Mail::Reporter
  • $obj->destruct() β€” Inherited, see "Cleanup" in Mail::Box::Message

✨ DETAILS ✨

Extends "DETAILS" in Mail::Box::Dir::Message. πŸ’«

πŸŽ€ Structure of a Message

Extends "Structure of a Message" in Mail::Box::Dir::Message.

πŸŽ€ Message object implementation

Extends "Message object implementation" in Mail::Box::Dir::Message.

πŸŽ€ Message class implementation

Extends "Message class implementation" in Mail::Box::Dir::Message.

🏷️ Labels

Extends "Labels" in Mail::Box::Dir::Message.

✨ Predefined labels

Extends "Predefined labels" in Mail::Box::Dir::Message.

✨ Status and X-Status fields

Extends "Status and X-Status fields" in Mail::Box::Dir::Message.

πŸ¦‹ Flags in filename

okay so bestie, when new messages show up on the system and they gotta get stashed in a maildir folder, they get dropped into the new sub-directory of the folder β€” and the serve order is: created first in the tmp sub-directory, then immediately moved to new. iconic. the following info was found at <https://cr.yp.to/proto/maildir.html>.

Every message gets written into its very own separate file. The filename is constructed from the time-of-arrival, a hostname, a unique component, a syntax marker, and flags. For example 1014220791.meteor.42:2,DF. The filename must match:

my ($time, $unique, $hostname, $info) =
   $filename =~ m!^(\d+)\.(.*)\.(\w+)(\:.*)?$!;

my ($semantics, $flags) =
   $info =~ m!([12])\,([DFPRST]*)$!;

my @flags = split //, $flags;

When an application opens the folder, there may be messages sitting in new which are new arrivals, and messages in cur. The cur ones get labeled "accepted". And to move a message from new to cur, you've got two options that do literally the same thing, no cap:

$msg->accept;
$msg->label(accept => 1);

See accept(), label(), Mail::Box::Maildir::new(accept_new), and Mail::Box::Maildir::acceptMessages() πŸ’…

The messages get moved, and their name is immediately extended with flags. An example, because we love a visual:

new/897979431.meteor.42      may become
cur/897979431.meteor.42:2,FS

Those added characters ':2,' refer to the "second state of processing", where the message has been inspected. And the characters (which should be in alphabetic order, mind you) mean:

  • D => draft
  • F => flagged
  • R => replied (answered)
  • S => seen
  • T => deleted (tagged for deletion)

Some maildir clients support:

  • P => passed (resent/forwarded/bounced to someone else)

The flags will immediately change when label() or delete() is used, which differs from other message implementations: maildir is stateless, and should not break when applications crash. self-care behavior fr fr πŸ’–


🩺 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().
  • Fault: cannot rename file $from to $to: $! β€” Cast by filename().
  • Fault: cannot rename file $from to $to: $! β€” Cast by labelsToFilename().
  • Fault: cannot write message to $file: $! β€” When a modified or new message is written to disk, it is first written to a temporary file in the folder directory. For some reason, it is impossible to create this file. Cast by create().
  • Error: class $package does not implement method $method. β€” Fatal error: 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().
  • Fault: failed to rename file $from to $to: $! β€” When a modified or new message is written to disk, it is 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; 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().
  • 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. β€” 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. At first use, the messages are read from their file. Apperently, a message is used for the first time here, but has disappeared or is unreadible 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 a wrap bestie 🫢 you just read Mail::...Message(3pm) from the Perl v5.40.1 docs, dated 2026-05-09, straight outta the User Contributed Perl Documentation. go forth and maildir, angel πŸ’– πŸŽ€

πŸ“¦ where this page comes from