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 namedtmp,new, andcur. 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" inMail::Box - overload:
'@{}'use as ARRAY β inherited, see "OVERLOADED" inMail::Box - overload:
cmpstring comparison β inherited, see "OVERLOADED" inMail::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β fromMail::Box, default'r'body_delayed_typeβ fromMail::Box, defaultMail::Message::Body::Delayedbody_typeβ fromMail::Box, defaultMail::Message::Body::Linescoerce_optionsβ fromMail::Box, default+[]createβ fromMail::Box, defaultfalsedirectoryβ default<derived from folder name>extractβ fromMail::Box, default10240field_typeβ fromMail::Box, defaultundeffix_headersβ fromMail::Box, defaultfalsefolderβ fromMail::Box, default$ENV{MAIL}folderdirβ fromMail::Box, defaultundefhead_delayed_typeβ fromMail::Box, defaultMail::Message::Head::Delayedhead_typeβ fromMail::Box, defaultMail::Message::Head::Completekeep_dupsβ fromMail::Box, defaultfalselock_fileβ fromMail::Box, default<folder>/.locklock_timeoutβ fromMail::Box, default1 hourlock_typeβ fromMail::Box, defaultMail::Box::Locker::DotLocklock_waitβ fromMail::Box, default10 secondslockerβ fromMail::Box, defaultundefmanagerβ fromMail::Box, defaultundefmessage_typeβ fromMail::Box, default<folder-class>::Messagemultipart_typeβ fromMail::Box, defaultMail::Message::Body::Multipartremove_when_emptyβ fromMail::Box, defaulttruesave_on_exitβ fromMail::Box, defaulttruetrustedβ fromMail::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=> $modebody_delayed_type=> CLASSbody_type=> CLASS|CODEcoerce_options=> ARRAYcreate=> BOOLEANdirectory=> $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=> $classfix_headers=> BOOLEANfolder=> $namefolderdir=> $directoryhead_delayed_type=> $classhead_type=> $classkeep_dups=> BOOLEANlock_file=> $filelock_timeout=> $secondslock_type=> $class|$name|@nameslock_wait=> $secondslocker=> $lockermanager=> $managermessage_type=> $classmultipart_type=> CLASSremove_when_empty=> BOOLEANsave_on_exit=> BOOLEANtrusted=> BOOLEAN
π§ Attributes π§
Extends "Attributes" in Mail::Box.
$obj->fixHeaders()β inherited, see "Attributes" inMail::Box$obj->folderdir( [$directory] )β inherited, see "Attributes" inMail::Box$obj->isTrusted()β inherited, see "Attributes" inMail::Box$obj->name()β inherited, see "Attributes" inMail::Box$obj->removeEmpty()β inherited, see "Attributes" inMail::Box$obj->type()β inherited, see "Attributes" inMail::Box
π The folder π
Extends "The folder" in Mail::Box.
$obj->addMessage($message, %options)β inherited, see "The folder" inMail::Box$obj->addMessages(@messages)β inherited, see "The folder" inMail::Box$class->appendMessages(%options)β inherited, see "The folder" inMail::Box$obj->close(%options)β inherited, see "The folder" inMail::Box$obj->copyTo($folder, %options)β inherited, see "The folder" inMail::Box$obj->delete(%options)β inherited, see "The folder" inMail::Box$obj->directory()β returns the directory related to this folder π
Β» example:
print $folder->directory;
$obj->organization()β inherited, see "The folder" inMail::Box$obj->size()β inherited, see "The folder" inMail::Box$obj->update(%options)β inherited, see "The folder" inMail::Box$obj->url()β inherited, see "The folder" inMail::Box
π© Folder flags π©
Extends "Folder flags" in Mail::Box.
$obj->access()β inherited, see "Folder flags" inMail::Box$obj->isModified()β inherited, see "Folder flags" inMail::Box$obj->modified( [BOOLEAN] )β inherited, see "Folder flags" inMail::Box$obj->writable()β inherited, see "Folder flags" inMail::Box
π The messages π
Extends "The messages" in Mail::Box.
$obj->current( [$number|$message|$message_id] )β inherited, see "The messages" inMail::Box$obj->find($message_id)β inherited, see "The messages" inMail::Box$obj->findFirstLabeled( $label, [BOOLEAN, [\@msgs]] )β inherited, see "The messages" inMail::Box$obj->message( $index, [$message] )β inherited, see "The messages" inMail::Box$obj->messageId( $message_id, [$message] )β inherited, see "The messages" inMail::Box$obj->messageIds()β inherited, see "The messages" inMail::Box$obj->messages( <'ALL'|$range|'ACTIVE'|'DELETED'|$label| !$label|$filter> )β inherited, see "The messages" inMail::Box$obj->nrMessages(%options)β inherited, see "The messages" inMail::Box$obj->scanForMessages($message, $message_ids, $timespan, $window)β inherited, see "The messages" inMail::Box
π«Ά Sub-folders π«Ά
Extends "Sub-folders" in Mail::Box.
$any->listSubFolders(%options)β inherited, see "Sub-folders" inMail::Box$any->nameOfSubFolder( $subname, [$parentname] )β inherited, see "Sub-folders" inMail::Box$obj->openRelatedFolder(%options)β inherited, see "Sub-folders" inMail::Box$obj->openSubFolder($subname, %options)β inherited, see "Sub-folders" inMail::Box$any->topFolderWithMessages()β inherited, see "Sub-folders" inMail::Box
π§ Internals π§
Extends "Internals" in Mail::Box.
$obj->coerce($message, %options)β inherited, see "Internals" inMail::Box$any->create($foldername, %options)β inherited, see "Internals" inMail::Box$obj->determineBodyType($message, $head)β inherited, see "Internals" inMail::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" inMail::Box$obj->lineSeparator( [<STRING|'CR'|'LF'|'CRLF'>] )β inherited, see "Internals" inMail::Box$obj->locker()β inherited, see "Internals" inMail::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" inMail::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" inMail::Box$obj->storeMessage($message)β inherited, see "Internals" inMail::Box$obj->toBeThreaded($messages)β inherited, see "Internals" inMail::Box$obj->toBeUnthreaded($messages)β inherited, see "Internals" inMail::Box$obj->updateMessages(%options)β inherited, see "Internals" inMail::Box$obj->write(%options)β inherited, see "Internals" inMail::Box$obj->writeMessages(%options)β inherited, see "Internals" inMail::Box
β Other methods β
Extends "Other methods" in Mail::Box.
$any->timespan2seconds($time)β inherited, see "Other methods" inMail::Box
π Error handling π
Extends "Error handling" in Mail::Box.
$obj->AUTOLOAD()β inherited, see "Error handling" inMail::Reporter$obj->notImplemented()β inherited, see "Error handling" inMail::Reporter
π§Ό Cleanup π§Ό
Extends "Cleanup" in Mail::Box.
$obj->DESTROY()β inherited, see "Cleanup" inMail::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 vianew(access), or unless the"force"option is set to"true". cast bywrite()πWarning: Folder directory $directory is write-protected.β so the folder$directorydoes already exist and it's write protected, which may mess with the write access you asked for. fix it by changingnew(access)or the permissions on the directory. cast bynew()π«ΆWarning: changes not written to read-only folder $name.β you opened the folder read-only (which, fun fact, is the default set bynew(access)), you made modifications, and now you wanna close it?? π setclose(force)if you want to overrule the access mode, or close the folder withclose(write)set to"NEVER". cast byclose()β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 bynotImplemented()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 bycopyTo()πError: destination folder $name is not writable.β the folder where the messages are copied to is not opened with write access (seenew(access)). this has no relation with write permission to the folder which is controlled by your operating system. cast bycopyTo()π€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 bymessageId()πΈWarning: folder $name not deleted: not writable.β the folder must be opened with write access vianew(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 bydelete()β¨Warning: folder directory $dir is write-protectedβ cast bynew()π¦Error: invalid timespan '$span'.β the string does not follow the strict rules of the time span syntax which is permitted as parameter. cast bytimespan2seconds()β³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 bymessageId()πError: no directory $dir for folder of $type.β cast bynew()πError: unknown value to folder->close(write => $when).β cast byclose()πError: you cannot add a message which is already part of a folder to a new one. Please use moveTo or copyTo.β cast byaddMessage()π βοΈ
π 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
- 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