Mail::Box::Dir(3pm)

πŸ’– Mail::Box::Dir πŸ’–

the Mail::Box::Dir(3pm) page, from the User Contributed Perl Documentation era β€” bestie, we're reading Perl core docs and we're gonna understand them ✨


✨ NAME ✨

Mail::Box::Dir β€” handle folders with a file per message. Yes, one file per message, that's the whole vibe πŸ—‚οΈπŸ’…


🌈 INHERITANCE 🌈

Mail::Box::Dir
  is a Mail::Box
  is a Mail::Reporter

Mail::Box::Dir is extended by
  Mail::Box::MH
  Mail::Box::Maildir

So it's sitting in the middle of a whole family tree, fr fr. It is a Mail::Box, it is a Mail::Reporter, and then Mail::Box::MH and Mail::Box::Maildir extend it πŸ‘‘ (and don't worry, Mail::Box::Netzwert is in this bloodline too β€” we get to it in a sec).


πŸ¦‹ SYNOPSIS πŸ¦‹

# Do not instantiate this object

That's it. That's the synopsis. Not me with the one-liner πŸ’€ Do not instantiate this object, bestie. It's a base class, it's giving "look but don't touch" energy. Use one of the subclasses instead πŸŽ€


🌸 DESCRIPTION 🌸

Okay so this page is all about how directory-organized mailboxes work πŸ“βœ¨ Like, a folder that is literally a directory, and the messages live as files inside it. At the moment, this object is extended by:

  • Mail::Box::MH β€” MH folders! These are represented by a directory containing files which are sequentially numbered. Cute, order-coded, we love a numbered queen πŸ”’
  • Mail::Box::Maildir β€” Maildir folders! These live in a directory which has sub-directories named tmp, new, and cur. Each of these directories may contain files with names which are a combination of a numeric timestamp and some status flags. The classic trio πŸ§ΊπŸ’–
  • Mail::Box::Netzwert β€” this folder type was especially developed for Netzwert AG, optimized to run on a cluster of servers with folders on NFS. And bestie… the code is not publicly available (yet). Iconic, mysterious, gatekept πŸ™ˆ

Extends "DESCRIPTION" in Mail::Box. (So anything not re-explained here? Go read the parent page, iykyk 🫢)


πŸ’… OVERLOADED πŸ’…

Extends "OVERLOADED" in Mail::Box.

  • overload: '""' stringification β€” inherited, see "OVERLOADED" in Mail::Box
  • overload: '@{}' use as ARRAY β€” inherited, see "OVERLOADED" in Mail::Box
  • overload: cmp string comparison β€” inherited, see "OVERLOADED" in Mail::Box

All three are heirlooms from the parent πŸ’Ž nothing new here, no cap.


πŸ‘‘ METHODS πŸ‘‘

Extends "METHODS" in Mail::Box.

πŸŽ€ Constructors πŸŽ€

Extends "Constructors" in Mail::Box.

$class->new(%options)

Inherited, see "Constructors" in Mail::Box.

Here's the whole option menu with who defines it and what it defaults to. Every single one, bestie, nothing skipped ✨:

  • access β€” from Mail::Box, default 'r'
  • body_delayed_type β€” from Mail::Box, default Mail::Message::Body::Delayed
  • body_type β€” from Mail::Box, default Mail::Message::Body::Lines
  • coerce_options β€” from Mail::Box, default +[]
  • create β€” from Mail::Box, default false
  • directory β€” default <derived from folder name>
  • extract β€” from Mail::Box, default 10240
  • field_type β€” from Mail::Box, default undef
  • fix_headers β€” from Mail::Box, default false
  • folder β€” from Mail::Box, default $ENV{MAIL}
  • folderdir β€” from Mail::Box, default undef
  • head_delayed_type β€” from Mail::Box, default Mail::Message::Head::Delayed
  • head_type β€” from Mail::Box, default Mail::Message::Head::Complete
  • keep_dups β€” from Mail::Box, default false
  • lock_file β€” from Mail::Box, default <folder>/.lock
  • lock_timeout β€” from Mail::Box, default 1 hour
  • lock_type β€” from Mail::Box, default Mail::Box::Locker::DotLock
  • lock_wait β€” from Mail::Box, default 10 seconds
  • locker β€” from Mail::Box, default undef
  • manager β€” from Mail::Box, default undef
  • message_type β€” from Mail::Box, default <folder-class>::Message
  • multipart_type β€” from Mail::Box, default Mail::Message::Body::Multipart
  • remove_when_empty β€” from Mail::Box, default true
  • save_on_exit β€” from Mail::Box, default true
  • trusted β€” from Mail::Box, default <depends on folder location>

And now the same options again, one by one, because the page does that and we respect the page πŸ’–:

  • access => $mode
  • body_delayed_type => CLASS
  • body_type => CLASS|CODE
  • coerce_options => ARRAY
  • create => BOOLEAN
  • directory => $directory β€” for rare folder types, the $directory name may differ from the folder name. Noted, lowkey important πŸ“
  • extract => INTEGER|CODE|METHOD|'LAZY'|'ALWAYS'
  • field_type => $class
  • fix_headers => BOOLEAN
  • folder => $name
  • folderdir => $directory
  • head_delayed_type => $class
  • head_type => $class
  • keep_dups => BOOLEAN
  • lock_file => $file
  • lock_timeout => $seconds
  • lock_type => $class|$name|@names
  • lock_wait => $seconds
  • locker => $locker
  • manager => $manager
  • message_type => $class
  • multipart_type => CLASS
  • remove_when_empty => BOOLEAN
  • save_on_exit => BOOLEAN
  • trusted => BOOLEAN

🧚 Attributes 🧚

Extends "Attributes" in Mail::Box.

  • $obj->fixHeaders() β€” inherited, see "Attributes" in Mail::Box
  • $obj->folderdir( [$directory] ) β€” inherited, see "Attributes" in Mail::Box
  • $obj->isTrusted() β€” inherited, see "Attributes" in Mail::Box
  • $obj->name() β€” inherited, see "Attributes" in Mail::Box
  • $obj->removeEmpty() β€” inherited, see "Attributes" in Mail::Box
  • $obj->type() β€” inherited, see "Attributes" in Mail::Box

πŸ“ The folder πŸ“

Extends "The folder" in Mail::Box.

  • $obj->addMessage($message, %options) β€” inherited, see "The folder" in Mail::Box
  • $obj->addMessages(@messages) β€” inherited, see "The folder" in Mail::Box
  • $class->appendMessages(%options) β€” inherited, see "The folder" in Mail::Box
  • $obj->close(%options) β€” inherited, see "The folder" in Mail::Box
  • $obj->copyTo($folder, %options) β€” inherited, see "The folder" in Mail::Box
  • $obj->delete(%options) β€” inherited, see "The folder" in Mail::Box
  • $obj->directory() β€” returns the directory related to this folder πŸ“‚

Β» example:

print $folder->directory;
  • $obj->organization() β€” inherited, see "The folder" in Mail::Box
  • $obj->size() β€” inherited, see "The folder" in Mail::Box
  • $obj->update(%options) β€” inherited, see "The folder" in Mail::Box
  • $obj->url() β€” inherited, see "The folder" in Mail::Box

🚩 Folder flags 🚩

Extends "Folder flags" in Mail::Box.

  • $obj->access() β€” inherited, see "Folder flags" in Mail::Box
  • $obj->isModified() β€” inherited, see "Folder flags" in Mail::Box
  • $obj->modified( [BOOLEAN] ) β€” inherited, see "Folder flags" in Mail::Box
  • $obj->writable() β€” inherited, see "Folder flags" in Mail::Box

πŸ’Œ The messages πŸ’Œ

Extends "The messages" in Mail::Box.

  • $obj->current( [$number|$message|$message_id] ) β€” inherited, see "The messages" in Mail::Box
  • $obj->find($message_id) β€” inherited, see "The messages" in Mail::Box
  • $obj->findFirstLabeled( $label, [BOOLEAN, [\@msgs]] ) β€” inherited, see "The messages" in Mail::Box
  • $obj->message( $index, [$message] ) β€” inherited, see "The messages" in Mail::Box
  • $obj->messageId( $message_id, [$message] ) β€” inherited, see "The messages" in Mail::Box
  • $obj->messageIds() β€” inherited, see "The messages" in Mail::Box
  • $obj->messages( <'ALL'|$range|'ACTIVE'|'DELETED'|$label| !$label|$filter> ) β€” inherited, see "The messages" in Mail::Box
  • $obj->nrMessages(%options) β€” inherited, see "The messages" in Mail::Box
  • $obj->scanForMessages($message, $message_ids, $timespan, $window) β€” inherited, see "The messages" in Mail::Box

🫢 Sub-folders 🫢

Extends "Sub-folders" in Mail::Box.

  • $any->listSubFolders(%options) β€” inherited, see "Sub-folders" in Mail::Box
  • $any->nameOfSubFolder( $subname, [$parentname] ) β€” inherited, see "Sub-folders" in Mail::Box
  • $obj->openRelatedFolder(%options) β€” inherited, see "Sub-folders" in Mail::Box
  • $obj->openSubFolder($subname, %options) β€” inherited, see "Sub-folders" in Mail::Box
  • $any->topFolderWithMessages() β€” inherited, see "Sub-folders" in Mail::Box

πŸ”§ Internals πŸ”§

Extends "Internals" in Mail::Box.

  • $obj->coerce($message, %options) β€” inherited, see "Internals" in Mail::Box
  • $any->create($foldername, %options) β€” inherited, see "Internals" in Mail::Box
  • $obj->determineBodyType($message, $head) β€” inherited, see "Internals" in Mail::Box
  • $obj->folderToDirectory($foldername, $folderdir) β€” (class method) translate a foldername into a filename, with use of the $folderdir to replace a leading "=". Sneaky little translation step, we love a mapping πŸ”
  • $class->foundIn( [$foldername], %options ) β€” inherited, see "Internals" in Mail::Box
  • $obj->lineSeparator( [<STRING|'CR'|'LF'|'CRLF'>] ) β€” inherited, see "Internals" in Mail::Box
  • $obj->locker() β€” inherited, see "Internals" in Mail::Box
  • $obj->messageInFile($filename) β€” returns the folder message which is found the indicated $filename. This may be useful when some external tool reports filename to be opened πŸ‘€
  • $obj->read(%options) β€” inherited, see "Internals" in Mail::Box
  • $obj->readMessageFilenames($directory) β€” returns a list of all filenames which are found in this folder $directory and represent a message. The filenames are returned as relative path πŸ›£οΈ
  • $obj->readMessages(%options) β€” inherited, see "Internals" in Mail::Box
  • $obj->storeMessage($message) β€” inherited, see "Internals" in Mail::Box
  • $obj->toBeThreaded($messages) β€” inherited, see "Internals" in Mail::Box
  • $obj->toBeUnthreaded($messages) β€” inherited, see "Internals" in Mail::Box
  • $obj->updateMessages(%options) β€” inherited, see "Internals" in Mail::Box
  • $obj->write(%options) β€” inherited, see "Internals" in Mail::Box
  • $obj->writeMessages(%options) β€” inherited, see "Internals" in Mail::Box

⭐ Other methods ⭐

Extends "Other methods" in Mail::Box.

  • $any->timespan2seconds($time) β€” inherited, see "Other methods" in Mail::Box

😭 Error handling 😭

Extends "Error handling" in Mail::Box.

  • $obj->AUTOLOAD() β€” inherited, see "Error handling" in Mail::Reporter
  • $obj->notImplemented() β€” inherited, see "Error handling" in Mail::Reporter

🧼 Cleanup 🧼

Extends "Cleanup" in Mail::Box.

  • $obj->DESTROY() β€” inherited, see "Cleanup" in Mail::Box

πŸ”₯ DETAILS πŸ”₯

Extends "DETAILS" in Mail::Box.


⏳ okay bestie, that's part 1 done β€” but the page keeps going and so do we πŸ’œ

🩺 DIAGNOSTICS ✨

okay bestie, this is the part where the module yells at you. every single one of these messages is listed below with what it actually means, and which method is throwing it. no cap, read these, they're literally the group chat receipts of what went wrong πŸ’…

  • Error: Folder $name is opened read-only β€” bestie you cannot write to this folder unless you opened it for write or append via new(access), or unless the "force" option is set to "true". cast by write() 😭
  • Warning: Folder directory $directory is write-protected. β€” so the folder $directory does already exist and it's write protected, which may mess with the write access you asked for. fix it by changing new(access) or the permissions on the directory. cast by new() 🫢
  • Warning: changes not written to read-only folder $name. β€” you opened the folder read-only (which, fun fact, is the default set by new(access)), you made modifications, and now you wanna close it?? πŸ™ˆ set close(force) if you want to overrule the access mode, or close the folder with close(write) set to "NEVER". cast by close() ⭐
  • Error: class $package does not implement method $method. β€” fatal error time: the specific $package (or one of its superclasses) does not implement this method where it should. this message means 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: copying failed for one message. β€” for some reason β€” disk full, removed by external process, or read-protection, whatever the vibe is β€” it is impossible to copy one of the messages. copying will proceed for the other messages tho. cast by copyTo() πŸ’€
  • Error: destination folder $name is not writable. β€” the folder where the messages are copied to is not opened with write access (see new(access)). this has no relation with write permission to the folder which is controlled by your operating system. cast by copyTo() 😀
  • Warning: different messages with id $msgid. β€” the message id is discovered more than once within the same folder, but the content of the message seems to be different. this should not be possible: each message must be unique. cast by messageId() 🌸
  • Warning: folder $name not deleted: not writable. β€” the folder must be opened with write access via new(access), otherwise removing it will be refused. so like, you may have write-access according to the operating system, but that will not automatically mean that this "delete" method permits you to. the reverse remark is valid as well. cast by delete() ✨
  • Warning: folder directory $dir is write-protected β€” cast by new() πŸ¦‹
  • Error: invalid timespan '$span'. β€” the string does not follow the strict rules of the time span syntax which is permitted as parameter. cast by timespan2seconds() ⏳
  • Warning: message-id '$msgid' does not contain a domain. β€” according to the RFCs, message-ids need to contain a unique random part, then an "@", and then a domain name. this is made to avoid the creation of two messages with the same id. the warning emerges when the "@" is missing from the string. cast by messageId() πŸŽ€
  • Error: no directory $dir for folder of $type. β€” cast by new() 😭
  • Error: unknown value to folder->close(write => $when). β€” cast by close() πŸ’€
  • Error: you cannot add a message which is already part of a folder to a new one. Please use moveTo or copyTo. β€” cast by addMessage() πŸ™…β™€οΈ

πŸ‘€ SEE ALSO 🌈

this module is part of Mail-Box version 4.02, built on April 10, 2026.

Website: http://perl.overmeer.net/CPAN/ β€” go peek bestie, it's giving resources πŸ’–


πŸ“œ 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. slay πŸ’…


okay that's the whole page bestie, we did it 🫢 and lastly, the lil footer energy: this here manual page shipped with perl v5.40.1, dated 2026-05-09, and it's Mail::Box::Dir(3pm) β€” iconic, no notes, periodt πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from