Mail::...aildir(3pm)
πΈ Mail::Box::Maildir πΈ
okay bestie, this is a page from the User Contributed Perl Documentation (yes, <italic>perl</italic> docs, iykyk) and it's about Mail::Box::Maildir β the thing that deals with Maildir folders. It's part 1 of 2, so buckle up, we are NOT done yet π
β¨ NAME β¨
Mail::Box::Maildir β handle Maildir folders π
𧬠INHERITANCE π§¬
so this class is the whole nepo baby of the Mail::Box universe, look at the family tree:
Mail::Box::Maildir
is a Mail::Box::Dir
is a Mail::Box
is a Mail::Reporter
π¦ SYNOPSIS π¦
the little taste test, fr fr:
use Mail::Box::Maildir;
my $folder = Mail::Box::Maildir->new(folder => $ENV{MAIL}, ...);
π DESCRIPTION π
This doc spills all the tea on how Maildir mailboxes work, and everything you can do with the Maildir folder object Mail::Box::Maildir.
β οΈ Maildir is not supported for Windows, because it creates filenames that the Windows system literally will not accept. Not our fault, not their fault, it's just a whole situation π
Extends "DESCRIPTION" in Mail::Box::Dir.
π OVERLOADED π
Extends "OVERLOADED" in Mail::Box::Dir.
- overload:
'""'stringification β Inherited, see "OVERLOADED" in Mail::Box - overload:
'@{}'use as ARRAY β Inherited, see "OVERLOADED" in Mail::Box - overload:
cmpstring comparison β Inherited, see "OVERLOADED" in Mail::Box
π οΈ METHODS π οΈ
Extends "METHODS" in Mail::Box::Dir.
π Constructors π
Extends "Constructors" in Mail::Box::Dir.
$class->new(%options)
Inherited, see "Constructors" in Mail::Box
here's the big menu of everything you can pass, with where it comes from and what it defaults to:
-Option --Defined in --Default
accept_new false
access Mail::Box 'r'
body_delayed_type Mail::Box Mail::Message::Body::Delayed
body_type Mail::Box Mail::Message::Body::Lines
coerce_options Mail::Box +[]
create Mail::Box false
directory Mail::Box::Dir <derived from folder name>
extract Mail::Box 10240
field_type Mail::Box undef
fix_headers Mail::Box false
folder Mail::Box $ENV{MAIL}
folderdir Mail::Box $ENV{HOME}/.maildir
head_delayed_type Mail::Box Mail::Message::Head::Delayed
head_type Mail::Box Mail::Message::Head::Complete
keep_dups Mail::Box false
lock_file Mail::Box <not used>
lock_timeout Mail::Box <not used>
lock_type Mail::Box 'NONE' (constant)
lock_wait Mail::Box <not used>
locker Mail::Box undef
manager Mail::Box undef
message_type Mail::Box <folder-class>::Message
multipart_type Mail::Box Mail::Message::Body::Multipart
remove_when_empty Mail::Box true
save_on_exit Mail::Box true
trusted Mail::Box <depends on folder location>
accept_new => BOOLEANβ When the folder is open, some messages may be stored in thenewsub-directory. By default, these messages are immediately moved to thecurdirectory when the folder is opened. Otherwise, you have to callacceptMessages()orMail::Box::Maildir::Message::accept(). π«Ά
and the rest of em, keepin it exact:
access => $mode
body_delayed_type => CLASS
body_type => CLASS|CODE
coerce_options => ARRAY
create => BOOLEAN
directory => $directory
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::Dir.
$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::Dir.
$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()β Inherited, see "The folder" in Mail::Box::Dir$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::Dir.
$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::Dir.
$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::Dir.
$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::Dir.
$obj->acceptMessages()β Accept all messages which are waiting in thenewdirectory to be moved to thecurdirectory. This will not rescan the directory for newly arrived messages, because that's a task forupdate().$class->appendMessage(%options)$obj->coerce($message, %options)β Inherited, see "Internals" in Mail::Box
$any->create($foldername, %options)
[4.000] Returns the created directory. Improves base, see "Internals" in Mail::Box
-Option --Defined in--Default
folderdir Mail::Box undef
folderdir => $directory
$any->createDirs($folderdir)
The $folderdir contains the absolute path of the location where the messages are kept. Maildir folders contain a tmp, new, and cur sub-directory within that folder directory as well. This method will ensure that all directories exist. Returns false on failure. π
$obj->determineBodyType($message, $head)β Inherited, see "Internals" in Mail::Box
$any->folderIsEmpty($folderdir)
Checks whether the folder whose directory is specified as absolute $folderdir is empty or not. A folder is empty when the tmp, new, and cur subdirectories are empty and some files which are left there by application programs. The maildir spec explicitly states: .qmail, bulletintime, bulletinlock and seriallock. If any other files are found, the directory is considered not-empty. wild, i know π«
$obj->folderToDirectory($foldername, $folderdir)β Inherited, see "Internals" in Mail::Box::Dir$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)β Inherited, see "Internals" in Mail::Box::Dir$obj->read(%options)β Inherited, see "Internals" in Mail::Box$obj->readMessageFilenames($directory)β Inherited, see "Internals" in Mail::Box::Dir$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()
Inherited, see "Internals" in Mail::Box
-Option --Defined in--Default
messages Mail::Box <required>
messages => ARRAY
π Other methods π
Extends "Other methods" in Mail::Box::Dir.
$any->timespan2seconds($time)β Inherited, see "Other methods" in Mail::Box
π¨ Error handling π¨
Extends "Error handling" in Mail::Box::Dir.
$obj->AUTOLOAD()β Inherited, see "Error handling" in Mail::Reporter$obj->notImplemented()β Inherited, see "Error handling" in Mail::Reporter
π§Ή Cleanup π§Ή
Extends "Cleanup" in Mail::Box::Dir.
$obj->DESTROY()β Inherited, see "Cleanup" in Mail::Box
π DETAILS π
okay so the explanation is complicated β but for normal use you should bother yourself with all the details, bestie. iykyk. π
Extends "DETAILS" in Mail::Box::Dir.
β¨ Different kinds of folders β¨
Extends "Different kinds of folders" in Mail::Box::Dir.
β¨ Available folder types β¨
Extends "Available folder types" in Mail::Box::Dir.
β¨ Folder class implementation β¨
Extends "Folder class implementation" in Mail::Box::Dir.
π How MAILDIR folders work π
Maildir-type folders use a directory to store the messages of one folder. each single message is stored in a separate file. and honestly? that seems useful, because changes in a folder change only a few of these small files β in contrast with file-based folders where changes in a folder cause rewrites of huge folder-files. no cap, that's the whole glow-up. β¨
However β and this is the part that's giving "it depends" energy β Maildir based folders perform very bad if you need header information of all messages. for instance, if you want to have full knowledge about all message-threads (see Mail::Box::Thread::Manager) in the folder, it requires reading all header lines in all message files. and usually, reading your messages as threads is desired. π Maildir maintains a tiny amount of info visible in the filename, which may make it perform just a little bit faster than MH. that's it. that's the tradeoff. π
π¨ DIAGNOSTICS π¨
vibe check time β here's everything that can go wrong and exactly why. read it, bestie.
- Error: Cannot append Maildir message in
$newto folder$self. β the message (or messages) could not be stored in the right directories for the Maildir folder. Cast byappendMessage() - Error: Cannot create Maildir message file
$new. β a message is converted from some other message format into a Maildir format by writing it to a file with a name which contains the status flags of the message. apparently, creating this file failed. Cast bycoerce() - Fault: Cannot create directory
$dir:$!β Cast byappendMessage() - Error: Folder
$nameis opened read-only β you can not write to this folder unless you have opened the folder to write or append withnew(access), or the"force"option is set"true". Cast bywrite() - Fault: cannot create Maildir directory
$dir:$!β a Maildir folder is represented by a directory, with some sub-directories. the top folder directory could not be created for the reason indicated. Cast bycreateDirs() - Fault: cannot create Maildir subdir
$dir:$!β each Maildir folder has three sub-directories for administration:"new","tmp", and"cur". the mentioned directory could not be created for the indicated reason. Cast bycreateDirs() - Fault: cannot create directory
$dir:$!β Cast bywriteMessages() - Fault: cannot create file
$file:$!β Cast bywriteMessages() - Fault: cannot rename
$fromto$to:$!β Cast bywriteMessages() - Warning: changes not written to read-only folder
$name. β you have opened the folder read-only (which is the default set bynew(access)π), made modifications, and now want to 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
$packagedoes 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: copying failed for one message. β for some reason, for instance disk full, removed by external process, or read-protection, it is impossible to copy one of the messages. copying will proceed for the other messages. Cast by
copyTo() - Error: destination folder
$nameis 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. two completely different things, bestie. 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
$namenot deleted: not writable. β the folder must be opened with write access vianew(access), otherwise removing it will be refused. so, 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() - 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 locking possible for maildir folders. β Cast by
new() - 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
moveToorcopyTo. β 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/
π 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, you made it to the end π«Ά this one came from perl v5.40.1, dated 2026-05-09, and it's the Mail::...aildir(3pm) manual β go forth and sort your mail, you absolute icon πβ¨
π¦ 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