The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::IMAP::Server::DefaultModel - Encapsulates per-connection information about the layout of IMAP folders.

DESCRIPTION

This class represents an abstract model backend to the IMAP server; it it meant to be overridden by server implementations. Primarily, subclasses are expected to override "init" to set up their folder structure.

Methods in the model can die with messages which start with "NO" or "BAD", which will be propagated back to the client immediately. See "handle_command" in Net::IMAP::Server::Connection.

METHODS

new

This class is created when the client has successfully authenticated to the server.

init

Called when the class is instantiated, with no arguments. Subclasses should override this method to inspect the "auth" object, and determine what folders the user should have. The primary purpose of this method is to set "root" to the top level of the mailbox tree. The root is expected to contain a mailbox named INBOX.

root MAILBOX

Gets or sets the root Net::IMAP::Server::Mailbox for this model. The root mailbox should contain no messages, and have no name -- it exists purely to contain sub-mailboxes, like INBOX. The "init" method is responsible for setting up the appropriate root mailbox, and all sub-mailboxes for the model.

auth

Returns the Net::IMAP::Server::DefaultAuth object for this model; this is set by the connection when the model is created, and will always reference a valid authentication object.

close

Called when this model's connection closes, for any reason. By default, does nothing.

split PATH

Utility method which splits a given PATH according to the mailbox separator, as determined by the "separator" in Net::IMAP::Server::Mailbox of the "root". May die if the path (which is expected to be encoded using IMAP-UTF-7) is invalid. See Encode::IMAPUTF7. If the mailbox hierarchy is flat (i.e. the separator is undef), returns the name without change.

lookup PATH

Given a PATH, returns the Net::IMAP::Server::Mailbox for that path, or undef if none matches. May die if the path contains unvalid IMAP-UTF-7 (see "split").

namespaces

Returns the namespaces of this model, per RFC 2342. Defaults to "INBOX" being the personal namespace, with no "shared" or "other users" namespaces.