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" inMail::Message$class->new(%options)β Inherited, see "Constructors" inMail::Box::Dir::Message
πΈ Attributes πΈ
Extends "Attributes" in Mail::Box::Dir::Message.
$obj->bodyType()β Inherited, see "Attributes" inMail::Message$obj->fieldType()β Inherited, see "Attributes" inMail::Message$obj->filename( [$filename] )β hands you back the current filename for this message. And if you actually pass in the$filenameargument? 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" inMail::Box::Dir::Message$obj->fixHeader()β Inherited, see "Attributes" inMail::Box::Dir::Message$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::Dir::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::Dir::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::Dir::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()β ok so the filename of aMail::Box::Maildir::Messagehas 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" 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::Dir::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::Dir::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::Dir::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
π·οΈ 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 getundefback. π
π§ 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" inMail::Message$class->coerce($message, %options)β Inherited, see "Internals" inMail::Message$obj->create($filename)β Inherited, see "Internals" inMail::Box::Dir::Message$obj->diskDelete()β Inherited, see "Internals" inMail::Box::Message$obj->isDelayed()β Inherited, see "Internals" inMail::Message$obj->isTrusted()β Inherited, see "Internals" inMail::Message$obj->loadBody()β Inherited, see "Internals" inMail::Box::Dir::Message$obj->loadHead()β Inherited, see "Internals" inMail::Box::Dir::Message$obj->parser()β Inherited, see "Internals" inMail::Box::Dir::Message$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::Dir::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::Dir::Message.
$obj->DESTROY()β Inherited, see "Cleanup" inMail::Reporter$obj->destruct()β Inherited, see "Cleanup" inMail::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=> draftF=> flaggedR=> replied (answered)S=> seenT=> 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 theforward(include). Valid choices are"NO","INLINE","ATTACH", and"ENCAPSULATE". Cast byforward(). πError: No default mailer found to send message.β The messagesend()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 $type object into a $me object.β 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().Fault: cannot rename file $from to $to: $!β Cast byfilename().Fault: cannot rename file $from to $to: $!β Cast bylabelsToFilename().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 bycreate().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 bynotImplemented().Error: coercion starts with some object, not '$type'.β Cast bycoerce().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 bycreate().Error: method bounce requires To, Cc, or Bcc.β The messagebounce()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 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.β 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 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.βMail::Boxtries 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 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 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
- 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