4.13.2.4. The IMAP command structure in policies

When using functions in policies to evaluate IMAP commands, the commands are represented as a recursive tuple of tuples having the following structure. Every command is a tuple of length 3, containing the tag of the command, the name of the command and a tuple containing the arguments.

The following values are possible as arguments (IMAP command structure in the policy layer):

  • (int, string) -- Integer

  • (int, int) -- Range

  • <LITERAL> -- Literal Literals (the actual messages) in the requests/responses are represented by a string having the 'Literal' value. The reason for this is that literals can be very large, therefore they are not sent to (thus not available) the policy level.

  • string -- A string or an atom

  • (",", a1, a2...) -- Comma-separated list

  • ("[", a1, a2...) -- Bracketed list

  • ("(", a1, a2...) -- Parenthesized list

Of course, lists can contain other lists recursively.

When processing IMAP responses where a number argument precedes the response name (e.g.: 1094 EXISTS), the number counts as the first argument.

Below are some examples how the different argument types are used in the IMAP protocol.

Example 4.26.  IMAP arguments in use
Issued command: a0001 FETCH 1,2 RFC822
The command as processed by the IMAP proxy:
tag: "a0001"
command: "FETCH"
arguments: ((',', (1, '1'), (2, '2')), 'RFC822');
where (',', (1, '1'), (2, '2') is a comma separated list,
(1, '1') is an integer, and RFC822 is a string.
Issued command: a0002 FETCH 1:2 RFC822
The command as processed by the IMAP proxy:
tag: a0002
command: FETCH
arguments: ((1, 2), 'RFC822');
where (1, 2) is a range.
Received response: * 1 FETCH (RFC822 <literal>)
The command as processed by the IMAP proxy:
command: FETCH
arguments: ((1, '1'), ('(', 'RFC822', '<LITERAL>'));
where <LITERAL> is a literal represented by a string.