The following commands exist for manipulation and querying quotas.
-
Arguments:
-
quota root
-
Responses:
-
REQUIRED untagged responses: QUOTA
-
Result:
-
OK - getquota completed
NO - getquota error: no such quota root, permission denied
BAD - command unknown or arguments invalid
The GETQUOTA command takes the name of a quota root and returns the quota root's resource usage and limits in an untagged QUOTA response. (Names of quota roots applicable to a particular mailbox can be discovered by issuing the GETQUOTAROOT command; see
Section 4.1.2.) Note that the server is not required to support any specific resource type (as advertised in the CAPABILITY response, i.e., all capability items with the "QUOTA=RES-" prefix) for any particular quota root.
Example:
S: * CAPABILITY [...] QUOTA QUOTA=RES-STORAGE [...]
[...]
C: G0001 GETQUOTA "!partition/sda4"
S: * QUOTA "!partition/sda4" (STORAGE 104 10923847)
S: G0001 OK Getquota complete
-
Arguments:
-
mailbox name
-
Responses:
-
REQUIRED untagged responses: QUOTAROOT, QUOTA
-
Result:
-
OK - getquotaroot completed
NO - getquotaroot error: permission denied
BAD - command unknown or arguments invalid
The GETQUOTAROOT command takes a mailbox name and returns the list of quota roots for the mailbox in an untagged QUOTAROOT response. For each listed quota root, it also returns the quota root's resource usage and limits in an untagged QUOTA response.
Note that the mailbox name parameter doesn't have to reference an existing mailbox. This can be handy in order to determine which quota root would apply to a mailbox when it gets created.
Example:
S: * CAPABILITY [...] QUOTA QUOTA=RES-STORAGE QUOTA=RES-MESSAGE
[...]
[...]
C: G0002 GETQUOTAROOT INBOX
S: * QUOTAROOT INBOX "#user/alice" "!partition/sda4"
S: * QUOTA "#user/alice" (MESSAGE 42 1000)
S: * QUOTA "!partition/sda4" (STORAGE 104 10923847)
S: G0002 OK Getquotaroot complete
-
Arguments:
-
quota root list of resource limits
-
Responses:
-
untagged responses: QUOTA
-
Result:
-
OK - setquota completed
NO - setquota error: can't set that data
BAD - command unknown or arguments invalid
Note that unlike other command/responses/response codes defined in this document, support for the SETQUOTA command requires the server to advertise the "QUOTASET" capability.
The SETQUOTA command takes the name of a mailbox quota root and a list of resource limits. The resource limits for the named quota root are changed to the specified limits. Any previous resource limits for the named quota root are discarded, even resource limits not explicitly listed in the SETQUOTA command. (For example, if the quota root had both STORAGE and MESSAGE limits assigned to the quota root before the SETQUOTA is called and the SETQUOTA only includes the STORAGE limit, then the MESSAGE limit is removed from the quota root.)
If the named quota root did not previously exist, an implementation may optionally create it and change the quota roots for any number of existing mailboxes in an implementation-defined manner.
If the implementation chooses to change the quota roots for some existing mailboxes, such changes
SHOULD be announced with untagged QUOTA responses.
Example:
S: * CAPABILITY [...] QUOTA QUOTASET QUOTA=RES-STORAGE QUOTA=RES-
MESSAGE [...]
[...]
C: S0000 GETQUOTA "#user/alice"
S: * QUOTA "#user/alice" (STORAGE 54 111 MESSAGE 42 1000)
S: S0000 OK Getquota completed
C: S0001 SETQUOTA "#user/alice" (STORAGE 510)
S: * QUOTA "#user/alice" (STORAGE 58 512)
// The server has rounded the STORAGE quota limit requested to
the nearest 512 blocks of 1024 octets; otherwise, another client
has performed a near-simultaneous SETQUOTA using a limit of 512.
S: S0001 OK Rounded quota
C: S0002 SETQUOTA "!partition/sda4" (STORAGE 99999999)
S: * QUOTA "!partition/sda4" (STORAGE 104 10923847)
// The server has not changed the quota, since this is a
filesystem limit, and it cannot be changed. The QUOTA
response here is entirely optional.
S: S0002 NO Cannot change system limit
The DELETED and DELETED-STORAGE status data items allow for estimation of the amount of resources that could be freed by an EXPUNGE on a mailbox.
The DELETED status data item requests the server to return the number of messages with the \Deleted flag set. The DELETED status data item is only required to be implemented when the server advertises the "QUOTA=RES-MESSAGE" capability.
The DELETED-STORAGE status data item requests the server to return the amount of storage space that can be reclaimed by performing EXPUNGE on the mailbox. The server
SHOULD return the exact value; however, it is recognized that the server may have to do a non-trivial amount of work to calculate it. If the calculation of the exact value would take a long time, the server
MAY instead return the sum of the RFC822.SIZE of the messages with the \Deleted flag set. The DELETED-STORAGE status data item is only required to be implemented when the server advertises the "QUOTA=RES-STORAGE" capability.
Example:
S: * CAPABILITY [...] QUOTA QUOTA=RES-STORAGE QUOTA=RES-
MESSAGE [...]
[...]
C: S0003 STATUS INBOX (MESSAGES DELETED DELETED-STORAGE)
S: * STATUS INBOX (MESSAGES 12 DELETED 4 DELETED-STORAGE 8)
// 12 messages, 4 of which would be deleted when an EXPUNGE
happens.
S: S0003 OK Status complete.
The following responses may be sent by the server.
-
Data: quota root name
list of resource names, usages, and limits
This response occurs as a result of a GETQUOTA, GETQUOTAROOT, or SETQUOTA command. The first string is the name of the quota root for which this quota applies.
The name is followed by an S-expression format list of the resource usage and limits of the quota root. The list contains zero or more triplets. Each triplet contains a resource name, the current usage of the resource, and the resource limit.
Resources not named in the list are not limited in the quota root. Thus, an empty list means there are no administrative resource limits in the quota root.
Example:
S: * QUOTA "" (STORAGE 10 512)
-
Data: mailbox name
zero or more quota root names
This response occurs as a result of a GETQUOTAROOT command. The first string is the mailbox and the remaining strings are the names of the quota roots for the mailbox.
Examples:
S: * QUOTAROOT INBOX ""
// The INBOX mailbox is covered by a single quota root with
name "".
S: * QUOTAROOT comp.mail.mime
// The comp.mail.mime mailbox has no quota root associated
with it, but one can be created.
The OVERQUOTA response code
SHOULD be returned in the tagged NO response to an APPEND/COPY/MOVE when the addition of the message(s) puts the target mailbox over any one of its quota limits.
Example 1:
C: A003 APPEND saved-messages (\Seen) {326}
S: + Ready for literal data
C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
C: From: Fred Foobar <foobar@Blurdybloop.example>
C: Subject: afternoon meeting
C: To: mooch@owatagu.siam.edu.example
C: Message-Id: <B27397-0100000@Blurdybloop.example>
C: MIME-Version: 1.0
C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
C:
C: Hello Joe, do you think we can meet at 3:30 tomorrow?
C:
S: A003 NO [OVERQUOTA] APPEND Failed
The OVERQUOTA response code
MAY also be returned in an untagged NO response in the authenticated or the selected state when a mailbox exceeds soft quota. For example, such OVERQUOTA response codes might be sent as a result of an external event (e.g., Local Mail Transfer Protocol (LMTP) [
RFC 2033] delivery or COPY/MOVE/APPEND in another IMAP connection) that causes the currently selected mailbox to exceed soft quota. Note that such an OVERQUOTA response code might be ambiguous because it might relate to the target mailbox (as specified in COPY/MOVE/APPEND) or to the currently selected mailbox. (The EXTRA WG chose not to address this deficiency due to syntactic limitations of IMAP response codes and because such events are likely to be rare.) This form of the OVERQUOTA response codes
MUST NOT be returned if there is no mailbox selected and no command in progress that adds a message to a mailbox (e.g., APPEND).
Example 2:
C: A003 APPEND saved-messages (\Seen) {326}
S: + Ready for literal data
C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
C: From: Fred Foobar <foobar@Blurdybloop.example>
C: Subject: afternoon meeting
C: To: mooch@owatagu.siam.edu.example
C: Message-Id: <B27397-0100000@Blurdybloop.example>
C: MIME-Version: 1.0
C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
C:
C: Hello Joe, do you think we can meet at 3:30 tomorrow?
C:
S: * NO [OVERQUOTA] Soft quota has been exceeded
S: A003 OK [APPENDUID 38505 3955] APPEND completed
Example 3:
C: A004 COPY 2:4 MEETING
S: * NO [OVERQUOTA] Soft quota has been exceeded
S: A004 OK [COPYUID 38505 304,319:320 3956:3958] COPY
command completed