4.11.2.1. Configuring policies for IMAP requests and responses

Changing the default behaviour of requests is possible using the request attribute. This hash is indexed by the IMAP command name.

The response attribute is indexed as follows: The response attribute hash is a three-dimensional hash, indexed by the command name for which the response is sent; the type of the response (TAGGED or UNTAGGED); and the response name. Untagged responses are accepted when there is a command in the pending queue (i.e. no tagged response arrived to it yet). The following constants are defined for the response types:

NameValue
IMAP_TAG_UNTAGGED Untagged responses.
IMAP_TAG_ALL Both types of responses.
IMAP_TAG_TAGGED Tagged responses.

Table 4.27.  Constants for IMAP response types

The proxy looks up the hash value corresponding to the IMAP command name as the key. If the hash contains no entry for a command, the "*" entry is used. If there is no "*" entry in the hash, the command is denied.

The possible actions are described in the following tables.

ActionDescription
IMAP_REQ_ACCEPT Allow the command to pass.
IMAP_REQ_REJECT Reject the command and send an error message to the client.
IMAP_REQ_DROP Silently drop the command - reject the command without sending an error message.
IMAP_REQ_ABORT Terminate the connection.
IMAP_REQ_POLICY Call the function specified in the argument to make a decision about the event. See Section 4.11.2.1, Configuring policies for IMAP requests and responses for details.
IMAP_REQ_REWRITE Replace the request with a predefined one. See the example below.
IMAP_REQ_RESPOND Respond to the request instead of the server. The request is not sent to the server. This action requires two arguments: a string containing a tagged response for the request, and a string list containing the optional untagged responses.

Table 4.28.  Action codes for IMAP requests

ActionDescription
IMAP_RSP_ACCEPT Allow the response to pass.
IMAP_RSP_REJECT Reject the response and send an error message to the client.
IMAP_RSP_DROP Silently drop the response.
IMAP_RSP_ABORT Terminate the connection.
IMAP_RSP_POLICY Call the function specified to make a decision about the event. See Section 4.11.2.1, Configuring policies for IMAP requests and responses for details.
IMAP_RSP_REWRITE Replace the response containing the greeting string with a predefined one. See the example below.

Table 4.29.  Action codes for IMAP responses