NAME

Protocol::IMAP::Server - server support for the Internet Message Access Protocol.

SYNOPSIS

package Example::IMAP::Server;
use parent qw{Protocol::IMAP::Server};

package main;
Example::IMAP::Server->new;

DESCRIPTION

IMPLEMENTING SUBCLASSES

The Protocol::IMAP classes only provides the framework for handling IMAP data. Typically you would need to subclass these to get a usable IMAP implementation.

The following methods are required:

  • write - called at various points to send data back across to the other side of the IMAP connection

and just about anything relating to the storage and handling of messages.

new

read_command

Read a command from a single line input from the client.

If this is a supported command, calls the relevant request_XXX method with the following data as a hash:

  • tag - IMAP tag information for this command, used for the final response from the server

  • command - actual command requested

  • param - any additional parameters passed after the command

request_capability

Request a list of all capabilities provided by the server.

These will be returned in a single untagged response, followed by the usual status response.

Note that the capabilities may vary depending on the state of the connection - for example, before STARTTLS negotiation all login types may be disabled via LOGINDISABLED capability.

request_starttls

Instructs the client to begin STARTTLS negotiation.

All implementations should provide this.

request_authenticate

Requests SASL authentication. Didn't need it, haven't written it yet.

is_authenticated

Returns true if we are authenticated, false if not.

request_login

Process a login request - this will be delegated to the subclass validate_user method.

request_logout

Process a logout request.

request_noop

Handle a NOOP, which leaves state unchanged other than resetting any timers (as handled by the read_command method).

request_select

Select a mailbox.

request_examine

Select a mailbox, in readonly mode.

request_create

Create a new mailbox.

request_delete

Delete a given mailbox.

request_rename

Request renaming a mailbox to something else.

request_subscribe

Ask to subscribe to a mailbox.

request_unsubscribe

Ask to unsubscribe from a mailbox.

request_list

List mailboxes matching a specification.

request_lsub

List subscriptions matching a spec - see request_list for more details on how this is implemented.

on_multi_line

Called when we have multi-line data (fixed size in characters).

on_single_line

Called when there's more data to process for a single-line (standard mode) response.

configure

Set up any callbacks that were available.

add_capability

Add a new capability to the reported list.

validate_user

Validate the given user and password information, returning true if they have logged in successfully and false if they are invalid.

select_mailbox

Selects the given mailbox.

Expects a hashref indicating mailbox information, e.g.:

my $mailbox = {
	name => $args{mailbox},
	exists => 17,
	recent => 2,
};
return $mailbox;

create_mailbox

Creates the given mailbox on the server.

delete_mailbox

Deletes the given mailbox.

rename_mailbox

Renames the given mailbox.

subscribe_mailbox

Adds the given mailbox to the active subscription list.

unsubscribe_mailbox

Removes the given mailbox from the current user's subscription list.

list_mailbox

List mailbox information given a search spec.

list_subscription

List subscriptions given a search spec.