Mail::...4::User(3pm)
π Mail::Server::IMAP4::User β the Perl man page, but make it make sense
User Contributed Perl Documentation Β· section 3pm Β· bestie edition β¨
okay so. you know how one (1) IMAP account can have folders? like, a LOT of folders? this module is the girlboss who keeps track of all of them for one user. it's the folder-manager of your dreams, and yes, she speaks IMAP.
πΈ NAME πΈ
Mail::Server::IMAP4::User β manage the folders of one user π
𧬠INHERITANCE π§¬
the family tree, and she ate:
Mail::Server::IMAP4::User
is a Mail::Box::Manage::User
is a Mail::Box::Manager
is a Mail::Reporter
β¨ SYNOPSIS β¨
the whole vibe in one line, no cap:
my $mgr = Mail::Server::IMAP4::User->new(...);
π DESCRIPTION π
this class takes a totally normal Mail::Box::Manager and adds IMAP protocol features to it. that's it, that's the girl. π
Extends "DESCRIPTION" in Mail::Box::Manage::User.
π οΈ METHODS π οΈ
Extends "METHODS" in Mail::Box::Manage::User.
π· Constructors π·
Extends "Constructors" in Mail::Box::Manage::User.
$class->new(%options)
Inherited, see "METHODS" in Mail::Box::Manage::User.
here's the whole options lineup, iconic behavior:
-Option --Defined in --Default
autodetect Mail::Box::Manager undef
collection_type Mail::Box::Manage::User Mail::Box::Collection
default_folder_type Mail::Box::Manager 'mbox'
delimiter Mail::Box::Manage::User "/"
folder_id_type Mail::Box::Manage::User Mail::Box::Identity
folder_types Mail::Box::Manager <all standard types>
folderdir Mail::Box::Manager [ '.' ]
folderdirs Mail::Box::Manager <synonym for C<folderdir>>
identity Mail::Box::Manage::User <required>
inbox Mail::Box::Manage::User undef
index_filename $folderdir/index
topfolder_name Mail::Box::Manage::User '='
autodetect=>$type|\@typescollection_type=>$classdefault_folder_type=>$type|CLASSdelimiter=>STRINGfolder_id_type=>CLASS|OBJECTfolder_types=>$typedef|\@typedefsfolderdir=>DIRECTORYfolderdirs=>[DIRECTORIES]identity=>OBJECTinbox=>$nameindex_filename=>FILENAMEtopfolder_name=>$name
π¦ Attributes π¦
Extends "Attributes" in Mail::Box::Manage::User.
$obj->defaultFolderType()β Inherited, see "Attributes" inMail::Box::Manager$obj->delimiter()β Inherited, see "Attributes" inMail::Box::Manage::User$obj->folderTypeDefs()β Inherited, see "Attributes" inMail::Box::Manager$obj->folderTypes()β Inherited, see "Attributes" inMail::Box::Manager$obj->folderdir()β Inherited, see "Attributes" inMail::Box::Manager$obj->identity()β Inherited, see "Attributes" inMail::Box::Manage::User$obj->inbox( [$name] )β Inherited, see "Attributes" inMail::Box::Manage::User$obj->indexFilename()β returns the filename of the index file. that's literally it. π$obj->registerType($type, $class, %options)β Inherited, see "Attributes" inMail::Box::Manager$obj->threads( [@params] )β Inherited, see "Attributes" inMail::Box::Manager$obj->topfolder()β Inherited, see "Attributes" inMail::Box::Manage::User
π Manage open folders π
Extends "Manage open folders" in Mail::Box::Manage::User.
$obj->close($folder, %options)β Inherited, see "Manage open folders" inMail::Box::Manager$obj->closeAllFolders(%options)β Inherited, see "Manage open folders" inMail::Box::Manager$obj->isOpenFolder($folder)β Inherited, see "Manage open folders" inMail::Box::Manager$obj->open( [$foldername], %options )β Inherited, see "Manage open folders" inMail::Box::Manager$obj->openFolders()β Inherited, see "Manage open folders" inMail::Box::Manager
ποΈ Manage existing folders ποΈ
Extends "Manage existing folders" in Mail::Box::Manage::User.
$obj->folder($name)β Inherited, see "Manage existing folders" inMail::Box::Manage::User$obj->folderCollection($name)β Inherited, see "Manage existing folders" inMail::Box::Manage::User$obj->rename($oldname, $newname, %options)β Inherited, see "Manage existing folders" inMail::Box::Manage::User
π Move messages to folders π
Extends "Move messages to folders" in Mail::Box::Manage::User.
$obj->appendMessage( [$folder|$foldername], $messages, %options )β Inherited, see "Move messages to folders" inMail::Box::Manager$obj->copyMessage( [$folder|$foldername], @messages, %options )β Inherited, see "Move messages to folders" inMail::Box::Manager$obj->moveMessage( [$folder|$foldername], @messages, %options )β Inherited, see "Move messages to folders" inMail::Box::Manager
π§΅ Manage message threads π§΅
Extends "Manage message threads" in Mail::Box::Manage::User.
$obj->discoverThreads( [@folders], %options )β Inherited, see "Manage message threads" inMail::Box::Manager
π§ Internals π§
Extends "Internals" in Mail::Box::Manage::User.
$obj->decodeFolderURL($url)β Inherited, see "Internals" inMail::Box::Manager$obj->toBeThreaded($folder, $messages)β Inherited, see "Internals" inMail::Box::Manager$obj->toBeUnthreaded($folder, $messages)β Inherited, see "Internals" inMail::Box::Manager
π Error handling π
Extends "Error handling" in Mail::Box::Manage::User.
$obj->AUTOLOAD()β Inherited, see "Error handling" inMail::Reporter$obj->notImplemented()β Inherited, see "Error handling" inMail::Reporter
π§Ή Cleanup π§Ή
Extends "Cleanup" in Mail::Box::Manage::User.
$obj->DESTROY()β Inherited, see "Cleanup" inMail::Reporter
π Manage folders π
$obj->create($name, %options)
makes you a brand new folder with the name you picked. you get back folder info, and she keeps it very simple. in the accidental little oopsie case where that folder already exists, you get a warning and the data of that existing folder back. improves base, see "Manage existing folders" in Mail::Box::Manage::User.
-Option --Defined in --Default
create_real Mail::Box::Manage::User true
create_supers Mail::Box::Manage::User false
deleted Mail::Box::Manage::User false
id_options Mail::Box::Manage::User []
create_real=>BOOLEANcreate_supers=>BOOLEANdeleted=>BOOLEANid_options=>ARRAY
$obj->delete($name, %options)
removes every sign of that folder from the file-system. messages still chilling in the folder? gone too, bestie. π³
this one returns a "true" value when the folder got removed or when it wasn't found in the first place β so "false" means failure. remember that, it's giving trick question.
you can also delete a folder via $folder->delete, which will call this method right here. the %options, which get used for some other folder types, are just ignored here: the user's index already holds the required details. improves base, see "Manage existing folders" in Mail::Box::Manage::User.
-Option --Defined in --Default
recursive Mail::Box::Manager <folder's default>
recursive=>BOOLEAN
Β» example: how to delete a folder
print "no xyz (anymore)\n" if $user->delete('xyz');
$obj->folderInfo($name)
hands you a hash full of folder info. normally this is cheap to get, because it's all cached in an index file. π
DO NOT modify the values you find in the hash, because that data may or may not be lost. seriously.
DO NOT trust on the existence of any field in the info: fields may get renamed, removed, or added over time. not all folder indexes will be generated by the same software release, so don't be surprised.
Β» example: how to get global info about a folder
my $info = $user->folderInfo($name); # get info
π DETAILS π
Extends "DETAILS" in Mail::Box::Manage::User.
π DIAGNOSTICS π
okay bestie, this is the part where the module yells at you. every one of these is a real message you might see, so let's go through them one by one β no skimming, fr fr.
Error: Folder $name is not a Mail::Box; cannot add a message.β the folder you tried to append a message to? it's an object that is not a folder type extendingMail::Box. lowkey it's probably not even a folder at all. cast byappendMessage().Error: Use appendMessage() to add messages which are not in a folder.β bestie you literally don't need to copy this message into the folder, because you are not sharing the message between folders. cast bycopyMessage().Warning: Use moveMessage() or copyMessage() to move between open folders.β the message is already part of a folder, and now you want it appended to a different folder. you gotta pick: copy or move. both of them will clone the message (not the body tho, because bodies are immutable π ). cast byappendMessage().Fault: cannot create folder directory $dir: $!β cast bycreate().Error: cannot rename folder $from to $to: higher levels are missing.β unless you setcreate(create_supers), all higher level folders have to exist before this new one can be created. cast byrename().Fault: cannot write name for folder in $file: $!β cast bycreate().Error: class $package does not implement method $method.β this one is a fatal error, so pay attention: the specific$package(or one of its superclasses) does not implement this method where it should. what it means: some other related classes do implement this method, but the class in front of you does not. probably you should investigate this, and probably inform the author of the package. cast bynotImplemented().Error: failed for folder default $class: $@β cast byopen().Fault: failed writing folder name to $file: $!β cast bycreate().Warning: folder $name already exists, creation skipped.β cast bycreate().Error: folder $name does not exist, failed opening $type.β the folder doesn't exist, and creating it is not permitted (peepopen(create)) or it just didn't succeed. and when you don't have sufficient access rights to the folder (like, wrong password for POP3), this warning gets produced too. the manager tried to open a folder of the specified type. it may help to explicitly state the type of your folder with the"type"option. there will probably be another warning or error message related to this report that gives you more detail about its cause. you may also have a look atnew(autodetect)andnew(folder_types). cast byopen().Error: folder $name is already open.β you cannot ask the manager for a folder which is already open. in some older releases (before MailBox 2.049) this was permitted, but then behaviour changed, because many nasty side-effects are to be expected. for instance, aMail::Box::update()on one folder handle would influence the second, probably unexpectedly. cast byopen().Error: folder $name not under top.β cast byfolderCollection().Warning: folder type $type is unknown, using autodetect.β the specified folder type (seeopen(type), possibly derived from the folder name when specified as url) is not known to the manager. this may mean you forgot torequirethe Mail::Box extension which implements this folder type β but probably it's a typo. usually the manager is able to figure-out which type to use by itself. cast byopen().Error: illegal folder URL '$url'.β the folder name was specified as URL, but not according to the syntax. seedecodeFolderURL()for an description of the syntax. cast byopen().Error: no foldername specified to open.βopen()needs a folder name as first argument (before the list of options), or with the"folder"option within that list. if no name was found, theMAILenvironment variable is checked. and when even that doesn't result in a usable folder, this error shows up. it may also be caused by an accidental odd-length option list. cast byopen().Error: source folder for rename does not exist: $from to $to.β cast byrename().Error: threader $class is not derived from $base.β cast bydiscoverThreads().Fault: unable to remove folder {$name}β cast bydelete().Error: unusable threader $class: $@β cast bydiscoverThreads().Warning: will never create a folder $name without having write access.β you setopen(create), but you only want to read the folder. create is only useful for folders which have write or append access modes (seeMail::Box::new(access)). cast byopen().Error: you need to pass a $base derived threader, got $class.β cast bydiscoverThreads().
β¨ SEE ALSO β¨
this module is part of Mail-Box-IMAP4 version 4.01, built on December 13, 2025. Website: http://perl.overmeer.net/CPAN/
π LICENSE π
for contributors, see file ChangeLog.
this software is copyright (c) 2001-2025 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. π«Ά
and that's the whole page, bestie!! π you made it to the end, main character energy fr. this one's from perl v5.40.1, dated 2026-01-21, and it's the Mail::...4::User(3pm) manual β go forth and open your folders responsibly πβ¨π
π¦ where this page comes from
- ubuntu resolute: libmail-box-imap4-perl 4.01-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmail-box-imap4-perl 4.01-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