See METHODS in Mail::Reporter
Option | Defined in | Default |
---|---|---|
autodetect |
| |
default_folder_type |
| |
folder_types | <all standard types> | |
folderdir |
| |
folderdirs | <synonym for | |
log | Mail::Reporter |
|
trace | Mail::Reporter |
|
Returns the default folder type, some class name.
Returns the list of currently defined folder types.
print join("\n", $manager->folderTypes), "\n";
In list context, this returns all folderdirs specified. In SCALAR context only the first.
With registerType
you can register one TYPE of folders. The CLASS
is compiled automatically, so you do not need to use
them in your own
modules. The TYPE is just an arbitrary name.
The added types are prepended to the list of known types, so they are checked first when a folder is opened in autodetect mode.
$manager->registerType(mbox => 'Mail::Box::Mbox', save_on_exit => 0, folderdir => '/tmp');
close
removes the specified folder from the list of open folders.
Indirectly it will update the files on disk if needed (depends on
the Mail::Box::new(save_on_exit) flag for each folder). OPTIONS are
passed to Mail::Box::close() of the folder.
The folder's messages will also be withdrawn from the known message threads. You may also close the folder directly. The manager will be informed about this event and take appropriate actions.
Option | Default |
---|---|
close_by_self | <false> |
my $inbox = $mgr->open('inbox'); $mgr->close($inbox); $inbox->close; # alternative
closeAllFolders
calls close() for each folder managed by
this object. It is called just before the program stops (before global
cleanup).
Returns true if the FOLDER is currently open.
print "Yes\n" if $mgr->isOpenFolder('Inbox');
Open a folder which name is specified as first parameter or with
the option flag folder
. The folder type is autodetected unless
the type
is specified.
open
carries options for the manager which are described here, but
may also have additional options for the folder type. For a
description of the folder options, see the options to the constructor
Mail::Box::new() for each type of mail box.
Option | Default |
---|---|
authenticate |
|
create | <false> |
folder |
|
folderdir |
|
type | <first, usually |
my $jack = $manager->open(folder => '=jack', type => 'mbox'); my $rcvd = $manager->open('myMail', type => 'Mail::Box::Mbox', access => 'rw'); my $inbox = $manager->open('Inbox') or die "Cannot open Inbox.\n"; my $pop = 'pop3://myself:secret@pop3.server.com:120/x'; my $send = $manager->open($url); my $send = $manager->open(folder => '/x', type => 'pop3', username => 'myself', password => 'secret' server_name => 'pop3.server.com', server_port => '120');
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, an Mail::Box::update() on one folder handle would influence the second, probably unexpectedly.
The folder does not exist and creating is not permitted (see open(create)) or did not succeed. When you do not have sufficient access rights to the folder (for instance wrong password for POP3), this warning will be produced as well.
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 which is related
to this report and provides more details about its cause. You may also
have a look at new(autodetect) and new(folder_types).
The specified folder type (see open(type), possibly derived from the folder name when specified as url) is not known to the manager. This may mean that you forgot to require the Mail::Box extension which implements this folder type, but probably it is a typo. Usually, the manager is able to figure-out which type to use by itself.
The folder name was specified as URL, but not according to the syntax. See decodeFolderURL() for an description of the syntax.
open()
needs a folder name as first argument (before the list of options),
or with the folder
option within the list. If no name was found, the
MAIL environment variable is checked. When even that does not result in
a usable folder, then this error is produced. The error may be caused by
an accidental odd-length option list.
You have set open(create), but only want to read the folder. Create is only useful for folders which have write or append access modes (see Mail::Box::new(access)).
Returns a list of all open folders.
Remove the named folder. The OPTIONS are the same as those for open().
The deletion of a folder can take some time. Dependent on the type of folder, the folder must be read first. For some folder-types this will be fast.
Option | Default |
---|---|
recursive | <folder's default> |
Append one or more messages to a folder (therefore, an appendMessages()
is defined as well). You may specify a FOLDERNAME or an opened folder
as the first argument. When the name is that of an open folder, it is
treated as if the folder-object was specified, and not directly access
the folder-files. You may also specify the foldername as part of the
options list.
If a message is added to an already opened folder, it is only added to the structure internally in the program. The data will not be written to disk until a write of that folder takes place. When the name of an unopened folder is given, the folder is opened, the messages stored on disk, and then the folder is closed.
A message must be an instance of a Mail::Message. The actual message type does not have to match the folder type--the folder will try to resolve the differences with minimal loss of information. The coerced messages (how the were actually written) are returned as list.
The OPTIONS is a list of key/values, which are added to (overriding) the default options for the detected folder type.
$mgr->appendMessage('=send', $message, folderdir => '/'); $mgr->appendMessage($received, $inbox->messages); my @appended = $mgr->appendMessages($inbox->messages, folder => 'Drafts'); $_->label(seen => 1) foreach @appended;
The folder where the message should be appended to is an object which is not a folder type which extends Mail::Box. Probably, it is not a folder at all.
The message is already part of a folder, and now it should be appended to a different folder. You need to decide between copy or move, which both will clone the message (not the body, because they are immutable).
Copy a message from one folder into another folder. If the destination folder is already opened, Mail::Box::copyTo() is used. Otherwise, Mail::Box::appendMessages() is called.
You need to specify a folder's name or folder object as the first argument, or in the options list. The options are the same as those which can be specified when opening a folder.
Option | Default |
---|---|
share | <false> |
my $drafts = $mgr->open(folder => 'Drafts'); my $outbox = $mgr->open(folder => 'Outbox'); $mgr->copyMessage($outbox, $drafts->message(0)); my @messages = $drafts->message(1,2); $mgr->copyMessage('=Trash', @messages, folderdir => '/tmp', create => 1); $mgr->copyMessage($drafts->message(1), folder => '=Drafts' folderdir => '/tmp', create => 1);
You do not need to copy this message into the folder, because you do not share the message between folders.
Move a message from one folder to another. Be warned that removals from a folder only take place when the folder is closed, so the message is only flagged to be deleted in the opened source folder.
$mgr->moveMessage($received, $inbox->message(1))
is equivalent to
$mgr->copyMessage($received, $inbox->message(1), share => 1); $inbox->message(1)->delete;
Option | Default |
---|---|
share | <true> |
Create a new object which keeps track of message threads. You can read about the possible options in Mail::Box::Thread::Manager. As OPTIONS specify one folder or an array of FOLDERS. It is also permitted to specify folders before the options.
my $t1 = $mgr->threads(folders => [ $inbox, $send ]); my $t2 = $mgr->threads($inbox); my $t3 = $mgr->threads($inbox, $send);
Try to decompose a folder name which is specified as URL (see open()) into separate options.
Signal to the manager that all thread managers which are using the specified folder must be informed that new messages are coming in.
Signal to the manager that all thread managers which are using the specified folder must be informed that new messages are or going out.