<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
  <!ENTITY rfc2087 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2087.xml'>
  <!ENTITY rfc2119 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'>
  <!ENTITY rfc3501 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3501.xml'>
  <!ENTITY rfc4314 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4314.xml'>
  <!ENTITY rfc5257 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5257.xml'>
  <!ENTITY rfc8174 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml'>
  <!ENTITY rfc9051 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.9051.xml'>
    
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt"?>
<rfc category="std" ipr="pre5378Trust200902" obsoletes="2087" docName="draft-ietf-extra-quota-10">
	<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
	<?rfc toc="yes" ?>
	<?rfc symrefs="yes" ?>
	<?rfc sortrefs="yes"?>
	<?rfc iprnotified="no" ?>
	<?rfc strict="yes" ?>
	<?rfc comments="yes" ?>
	<?rfc inline="yes" ?>
	<?rfc compact="yes"?>
	<?rfc subcompact="no"?>
	<front>
		<title abbrev="IMAP QUOTA">
			IMAP QUOTA Extension
		</title>
		<author initials="A." surname="Melnikov" fullname="Alexey Melnikov">
			<organization abbrev="Isode">
				Isode Limited
			</organization>
			<address>
				<email>alexey.melnikov@isode.com</email>
				<uri>https://www.isode.com</uri>
			</address>
		</author>
		<date year="2021"/>
		<abstract>
			<t>This document defines a QUOTA extension of the Internet Message Access Protocol (RFC 3501/RFC 9051)
			that permits administrative limits on resource usage (quotas) to be
			manipulated through the IMAP protocol.</t>
      
			<t>This document obsoletes RFC 2087, but attempts to remain backwards
			compatible whenever possible.</t>
		</abstract>
	</front>
	<middle>
		<section title="Document Conventions">
			<t>In protocol examples, this document uses a prefix of "C: " to denote lines sent by the client to the server, and
			"S: " for lines sent by the server to the client. Lines prefixed with "// " are comments explaining the previous protocol line.
			These prefixes and comments are not part of the protocol. Lines without any of these prefixes are continuations of the previous line,
			and no line break is present in the protocol before such lines unless specifically mentioned.</t>

			<t>
      The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
      "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
      "OPTIONAL" in this document are to be interpreted as described in BCP
      14 <xref target="RFC2119"/> <xref target="RFC8174"/>
      when, and only when, they appear in all capitals, as shown here.
      </t>

      <t>Other capitalised words are IMAP keywords <xref target="RFC3501"/><xref target="RFC9051"/>
      or keywords from this document.</t>
      
		</section>
    
		<section title="Introduction and Overview">

      <t>This document defines a couple of extensions to the Internet Message Access Protocol <xref target="RFC3501"/>
      for querying and manipulating administrative limits on resource usage (quotas).
      This extension is compatible with both IMAP4rev1 <xref target="RFC3501"/> and IMAP4rev2 <xref target="RFC9051"/>.</t>

      <t>The capability "QUOTA", denotes a <xref target="RFC2087">RFC2087</xref> compliant server.
      Some responses and response codes defined in this document are not present in such servers
      (see <xref target="changes-since"/> for more details),
      and clients MUST NOT rely on their presence in the absence of any capability beginning
      with "QUOTA=".</t>

      <t>Any server compliant with this document MUST also return at least one capability
      starting with "QUOTA=RES-" prefix, as described in <xref target="Quota-Resource"/>.</t>

      <t>Any server compliant with this document that implements the SETQUOTA command (see <xref target="SETQUOTA"/>)
      MUST also return the "QUOTASET" capability.
      </t>
		
      <t>This document also reserves all other capabilities starting with "QUOTA=" prefix
      for future IETF stream standard track, informational or experimental extensions to this document.</t>

      <t>Quotas can be used to restrict clients for administrative reasons,
      but the QUOTA extension can also be used to indicate system limits and current usage
      levels to clients.</t>

      <t>Although <xref target="RFC2087">RFC2087</xref> specified an IMAP4 QUOTA extension,
      and this has seen deployment in servers, it has seen little deployment in clients.
      Since the meaning of the resources was left implementation-dependent, it was impossible for a client
      implementation to determine which resources were supported, and
      <!--/////Is it possible now?-->impossible to determine which mailboxes were in a given quota root (see <xref target="quota-root"/>),
      without a priori knowledge of the implementation.</t>

		</section>
		<section title="Terms">
			<section anchor="Quota-Resource" title="Resource">
				<t>A resource has a name, a formal definition.</t>
				<section title="Name">
					<t>The resource name is an atom, as defined in <xref target="RFC3501">IMAP4rev1</xref>. These MUST be registered with IANA.</t>
					<t>Supported resource names MUST be advertised as a capability, by prepending the resource name with "QUOTA=RES-".
                    A server compliant with this specification is not required to support all reported resource types on all quota roots.</t>
				</section>
				<section title="Definition">
					<t>The resource definition or document containing it, while not visible through the protocol, SHOULD be registered with IANA.</t>
					<t>The usage of a resource MUST be represented as a 63 bit unsigned integer.
                    0 indicates that the resource is exhausted.
                    Usage integers don't necessarily represent proportional use, so clients MUST NOT compare
					available resource between two separate quota roots on the same or different servers.</t>
					<t>Limits will be specified as, and MUST be represented as, an integer. <!--////Alexey: Is this useful?-->0 indicates that any usage is prohibited.</t>
					<t>Limits may be hard or soft - that is, an implementation MAY choose, or be configured, to disallow any command if the limit 
					on a resource
					is or would be exceeded.</t>
					<t>All resources which the server handles MUST be advertised in a CAPABILITY response/response code consisting of the resource name prefixed by "QUOTA=RES-".
					</t>

					<t>The resources <xref target="STORAGE">STORAGE</xref>, <xref target="MESSAGE">MESSAGE</xref>, <xref target="MAILBOX">MAILBOX</xref>
          and <xref target="ANNOTATION-STORAGE">ANNOTATION-STORAGE</xref> are defined in this document.</t>

				</section>
			</section>
			<section title="Quota Root" anchor="quota-root">

        <t>This document introduces a concept of a "quota root", as resource limits can apply across multiple IMAP mailboxes.</t>
        
				<t>Each mailbox has zero or more implementation-defined named "quota roots".  Each quota root has zero or more resource limits (quotas). All mailboxes that share the same named quota root share the resource limits of the quota root.</t>
				<t>Quota root names need not be mailbox names, nor is there any relationship defined
				by this document between a quota root name and a mailbox name. A quota root name is an astring, as defined in <xref target="RFC3501">IMAP4</xref>.
        It SHOULD be treated as an opaque string by any clients<!--which do not have a priori knowledge of the server implementation-->.</t>
				<!--
					Stripped, this only works if the hierarchy fits a suitable model. Given that there are implementations which use a namespace of "" to indicate personal mailboxes,
					this is difficult.
					<t>It is RECOMMENDED that implementations model the quota root on the mailbox hierarchy.</t>
				-->
				<t>Quota roots are used since not all implementations may be able to calculate usage, or apply quotas, on arbitrary mailboxes or mailbox hierarchies.</t>
				<t>Not all resources may be limitable or calculable for all quota roots. Further, not all resources may support all limits - some limits may be
				present in the underlying system. A server implementation of this memo SHOULD advise the client of such inherent limits, by generating <xref target="QUOTA">QUOTA</xref> responses, and SHOULD advise the client
				of which resources are limitable for a particular quota root. A <xref target="SETQUOTA">SETQUOTA</xref> command MAY also round a quota limit in an implementation-dependent way, if the granularity
				of the underlying system demands it. A client MUST be prepared for a <xref target="SETQUOTA">SETQUOTA</xref> command to fail if a limit cannot be set.</t>

				<t>Implementation Notes:<vspace/>
				This means that, for example under UNIX, a quota root may have a <xref target="MESSAGE">MESSAGE</xref> quota always set due to the number of inodes
				available on the filesystem, and similarly <xref target="STORAGE">STORAGE</xref> may be rounded to the nearest block and limited by free filesystem space.
				</t>
			</section>
		</section>
		<section title="Definitions">
			<section title="Commands">
				<t>The following commands exist for manipulation and querying quotas.</t>
				<section anchor="GETQUOTA" title="GETQUOTA">
					<t>
						<list style="hanging">
							<t hangText="Arguments:">quota root</t>
							<t hangText="Responses:">REQUIRED untagged responses: QUOTA<vspace/></t>
							<t hangText="Result:   ">OK - getquota completed<vspace/>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NO - getquota error: no such quota root, permission denied<vspace/>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BAD - command unknown or arguments invalid</t>
						</list>
					</t>
					<t>
            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 <xref target="GETQUOTAROOT"/>.)
            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.</t>
					<t>
						<list style="empty">
							<t>Example:</t>
							<t>S: * CAPABILITY [...] QUOTA QUOTA=RES-STORAGE [...]<vspace/>
							[...]<vspace/>
							C: G0001 GETQUOTA "!partition/sda4"<vspace/>
							S: * QUOTA "!partition/sda4" (STORAGE 104 10923847)<vspace/>
							S: G0001 OK Getquota complete</t>
						</list>
					</t>
				</section>
				<section anchor="GETQUOTAROOT" title="GETQUOTAROOT">
					<t>
						<list style="empty">
							<t>Arguments:	mailbox name</t>
							<t>Responses:	REQUIRED untagged responses: QUOTAROOT, QUOTA</t>
							<t>Result:		OK - getquotaroot completed<vspace/>
											NO - getquotaroot error: permission denied
<vspace/>
											BAD - command unknown or arguments invalid</t>
						</list>
					</t>
					<t>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.</t>

          <t>Note that the mailbox name parameter doesn't have to reference an
					existing mailbox. This can be handy in order to determine which quotaroot
					would apply to a mailbox when it gets created.</t>

					<t>
						<list style="empty">
							<t>Example:</t>
							<t>S: * CAPABILITY [...] QUOTA QUOTA=RES-STORAGE QUOTA=RES-MESSAGE [...]<vspace/>
							[...]<vspace/>
							C: G0002 GETQUOTAROOT INBOX<vspace/>
							S: * QUOTAROOT INBOX "#user/alice" "!partition/sda4"<vspace/>
							S: * QUOTA "#user/alice" (MESSAGE 42 1000)<vspace/>
							S: * QUOTA "!partition/sda4" (STORAGE 104 10923847)<vspace/>
							S: G0002 OK Getquotaroot complete</t>
						</list>
					</t>
				</section>
				<section anchor="SETQUOTA" title="SETQUOTA">
					<t>
						<list style="empty">
							<t>Arguments:	quota root</t>
							<t>				list of resource limits</t>
							<t>Responses:	untagged responses: QUOTA</t>
							<t>Result:		OK - setquota completed<vspace/>
											NO - setquota error: can't set that data<vspace/>
											BAD - command unknown or arguments invalid</t>
						</list>
					</t>

          <t>Note that unlike other command/responses/response codes defined in this document,
          support for SETQUOTA command requires the server to advertise "QUOTASET" capability.</t>

          <t>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 be 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.)</t>

					<t>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.</t>

          <t>
          If the implementation chooses to change the quota roots for some existing mailboxes
          such changes SHOULD be announced with untagged QUOTA responses.
          </t>
          
					<t>
						<list style="empty">
							<t>Example:</t>
							<t>S: * CAPABILITY [...] QUOTA QUOTASET QUOTA=RES-STORAGE QUOTA=RES-MESSAGE [...]<vspace/>
							[...]<vspace/>
							C: S0000 GETQUOTA "#user/alice"<vspace/>
							S: * QUOTA "#user/alice" (STORAGE 54 111 MESSAGE 42 1000)<vspace/>
							S: S0000 OK Getquota completed<vspace/>
							C: S0001 SETQUOTA "#user/alice" (STORAGE 510)<vspace/>
							S: * QUOTA "#user/alice" (STORAGE 58 512)</t>
							<t>// The server has rounded the STORAGE quota limit requested to the nearest 512 blocks of 1024 octects, or
						else another client has performed a near simultaneous SETQUOTA, using a limit of 512.</t>
							<t>S: S0001 OK Rounded quota<vspace/>
							C: S0002 SETQUOTA "!partition/sda4" (STORAGE 99999999)<vspace/>
							S: * QUOTA "!partition/sda4" (STORAGE 104 10923847)</t>
							<t>// The server has not changed the quota, since this is a filesystem limit, and cannot be changed. The QUOTA response here is entirely optional.</t>
							<t>S: S0002 NO Cannot change system limit</t>
						</list>
					</t>
				</section>
				<section anchor="STATUS_RECOVERABLE" title="New STATUS attributes">
					<t>DELETED and DELETED-STORAGE status data items allow to estimate the amount of resource freed by an EXPUNGE on a mailbox.</t>
					<t>The DELETED status data item requests the server to return the number of
					messages with \Deleted flag set. The DELETED status data item is only required
					to be implemented when the server advertises QUOTA=RES-MESSAGE capability.</t>
					<t>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 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 RFC822.SIZEs of messages with
					the \Deleted flag set. The DELETED-STORAGE status data item is only required
					to be implemented when the server advertises QUOTA=RES-STORAGE capability.</t>
					<t>
						<list style="empty">
							<t>Example:</t>
							<t>S: * CAPABILITY [...] QUOTA QUOTA=RES-STORAGE QUOTA=RES-MESSAGE [...]<vspace/>
							[...]<vspace/>
							C: S0003 STATUS INBOX (MESSAGES DELETED DELETED-STORAGE)<vspace/>
							S: * STATUS INBOX (MESSAGES 12 DELETED 4 DELETED-STORAGE 8)</t>
							<t>// 12 messages, 4 of which would be deleted when an EXPUNGE happens.</t>
							<t>S: S0003 OK Status complete.</t>
						</list>
					</t>
				</section>
			</section>
			<section title="Responses">
				<t>The following responses may be sent by the server.</t>
				<section anchor="QUOTA" title="QUOTA">
					<t>
						<list style="empty">
							<t>Data:	quota root name<vspace/>
										list of resource names, usages, and limits</t>
						</list>
					</t>
					<t>This response occurs as a result of a GETQUOTA, a GETQUOTAROOT or a SETQUOTA command.
					 The first string is the name of the quota root for which this quota applies.</t>
					<t>The name is followed by a 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.</t>
					<t>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.</t>
					<t>Example:    S: * QUOTA "" (STORAGE 10 512)</t>
				</section>
				<section anchor="QUOTAROOT" title="QUOTAROOT">
					<t>
						<list style="empty">
							<t>Data:	mailbox name<vspace/>
										zero or more quota root names</t>
						</list>
					</t>
					<t>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.</t>
					<t>Examples:</t>
					<t>S: * QUOTAROOT INBOX ""</t>
          <t>// The INBOX mailbox is covered by a single quota root with name "".</t>
          <t>S: * QUOTAROOT comp.mail.mime</t>
          <t>// The comp.mail.mime mailbox has no quota root associated with it, but one can be created.</t>
        </section>
			</section>
			<section title="Response Codes">
				<section anchor="OVERQUOTA" title="OVERQUOTA">
					<t>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.</t>

<figure><artwork><![CDATA[
   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
]]></artwork></figure>
          
          <t>
          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 code might be sent as a result of
          an external event (e.g. LMTP delivery or COPY/MOVE/APPEND in another IMAP
          connection) that causes the currently selected mailbox to exceed soft quota.

          Note that such 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 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).
          </t>

		<!--/////Returning the following information is useful,
          but it might not work with response code syntax restrictions:
          <t>
            Should the exceeded quota resource type be added as a parameter?
          </t>
            -->

<figure><artwork><![CDATA[
   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
]]></artwork></figure>

<!--RFC Editor: can you make sure that this is indented in the same way
    as the other 2 examples in the same section.
	There might be an HTML rendering glitch?-->
<figure><artwork><![CDATA[
   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
]]></artwork></figure>

				</section>
			</section>
		</section>
		<section title="Resource Type Definitions">
			<t>The following resource types are defined in this memo. A server supporting a resource type MUST advertise this as a CAPABILITY with a name consisting of the resource name
			prefixed by "QUOTA=RES-". A server MAY support multiple resource types, and MUST advertise all resource types it supports.</t>
      
			<section anchor="STORAGE" title="STORAGE">
				<t>The physical space estimate, in units of 1024 octets, of the mailboxes governed by the quota root.
        		This MAY not be the same as the sum of the RFC822.SIZE of the messages.
        		Some implementations MAY include metadata sizes for the messages and mailboxes,
				other implementations MAY store messages in such a way that the physical space used is smaller, for example due to use of compression.
        		Additional messages might not increase the usage. Client MUST NOT use the usage figure for anything other than informational purposes,
        		for example, they MUST NOT refuse to APPEND a message if the limit less the usage is smaller than the RFC822.SIZE divided by 1024 of the message,
				but it MAY warn about such condition.</t>
				<t>The usage figure may change as a result of performing actions not associated with adding new messages to the mailbox, such as SEARCH,
				since this may increase the amount of metadata included in the calculations.</t>

				<t>When the server supports this resource type, it MUST also support the DELETED-STORAGE status data item.</t>

				<t>Support for this resource MUST be indicated by the server by advertising the CAPABILITY "QUOTA=RES-STORAGE".</t>

				<t>A resource named the same was also given as an example in <xref target="RFC2087">RFC2087</xref>.
        This document provides a more precise definition.</t>

			</section>
      
			<section anchor="MESSAGE" title="MESSAGE">
				<t>The number of messages stored within the mailboxes governed by the quota root. This MUST be an exact number, however, clients
				MUST NOT assume that a change in the usage indicates a change in the number of messages available, since the quota root may include mailboxes
				the client has no access to.<!--////Alexey: isn't this a security leak?--></t>

				<t>When the server supports this resource type, it MUST also support the DELETED status data item.</t>

				<t>Support for this resource MUST be indicated by the server by advertising the CAPABILITY "QUOTA=RES-MESSAGE".</t>

				<t>A resource named the same was also given as an example in <xref target="RFC2087">RFC2087</xref>.
        This document provides a more precise definition.</t>

			</section>
      
			<section anchor="MAILBOX" title="MAILBOX">
				<t>The number of mailboxes governed by the quota root. This MUST be an exact number, however, clients
				MUST NOT assume that a change in the usage indicates a change in the number of mailboxes, since the quota root may include mailboxes
				the client has no access to.<!--////Alexey: isn't this a security leak?--></t>
				<t>Support for this resource MUST be indicated by the server by advertising the CAPABILITY "QUOTA=RES-MAILBOX".</t>
			</section>

      <section anchor="ANNOTATION-STORAGE" title="ANNOTATION-STORAGE">
        <t>
        The maximum size of all annotations <xref target="RFC5257"/>, in units of 1024 octets, associated with all messages in the mailboxes governed by the quota root.
        </t>
        
        <t>Support for this resource MUST be indicated by the server by advertising the CAPABILITY "QUOTA=RES-ANNOTATION-STORAGE".</t>
      </section>
    </section>
    
		<section title="Interaction with IMAP ACL extension (RFC 4314)">

      <t>This section lists <xref target="RFC4314"/> rights required to execute quota related commands
      when both RFC 4314 and this document are implemented.</t>

      <texttable>
        <!--<preamble></preamble>-->

        <ttcol align='center'>Operations\Rights</ttcol>
        <ttcol align='center'>l</ttcol>
        <ttcol align='center'>r</ttcol>
        <ttcol align='center'>s</ttcol>
        <ttcol align='center'>w</ttcol>
        <ttcol align='center'>i</ttcol>
        <ttcol align='center'>c</ttcol>
        <ttcol align='center'>x</ttcol>
        <ttcol align='center'>t</ttcol>
        <ttcol align='center'>e</ttcol>
        <ttcol align='center'>a</ttcol>
        <ttcol align='center'>Any</ttcol>
        <ttcol align='center'>Non</ttcol>

<!--
Timo (paraphrased):
In Dovecot you can use GETQUOTAROOT for your own folders and for public folders. Quering quota of other users is disallowed.
GETQUOTA is always allowed for all quota roots that are accessible to users.

I think it could be thought of as a privacy concern if you can see whenever another user receives/expunges mails, even if they have shared some folders with you.
-->        
        
        <c>GETQUOTA</c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c>+</c>

        <c>GETQUOTAROOT</c>
        <c></c>
        <c>*</c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c>*</c>

        <c>SETQUOTA</c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c></c>
        <c>+</c>
        <c></c>
        <c></c>

        <postamble>See Section 4 of RFC 4314 for conventions used in this table.</postamble>
      </texttable>

      <t>Legend:
        <list style="hanging">
          <t hangText="+"> - The right is required</t>
          <t hangText="*"> - Only one of the rights marked with * is required</t>
          <t hangText='"Any"'> - at least one of the "l", "r", "i", "k", "x", "a" rights is required</t>
          <t hangText='"Non"'> - no rights required to perform the command</t>
        </list>
      </t>

      <t>
      Note that which permissions are needed in order to perform GETQUOTAROOT command depends on
      the quota resource type being requested.  For example, a quota on number of messages
      (MESSAGE resource type) or total size of messages (STORAGE resource type)
      requires "r" right on the mailbox in question, since the quota involved would reveal information
      about the number (or total size) of messages in the mailbox. By comparison, the MAILBOX resource type
      doesn't require any right.
      </t>

    </section>

    <section title="Formal syntax">
			<t>The following syntax specification uses the Augmented Backus-Naur Form (ABNF) notation as specified in <xref target="ABNF"/>.</t>
			<t>Non-terminals referenced but not defined below are as defined by <xref target="RFC3501">IMAP4</xref>.</t>
			<t>Except as noted otherwise, all alphabetic characters are case-insensitive.  The use of upper or lower case characters to define token strings is for editorial clarity only.  Implementations MUST accept these strings in a case-insensitive fashion.</t>
			<t>
			<list style="hanging" hangIndent="20">
			<t hangText="getquota           ="> "GETQUOTA" SP quota-root-name</t>
			<t hangText="getquotaroot       ="> "GETQUOTAROOT" SP mailbox</t>
			<t hangText="quota-list         ="> "(" quota-resource *(SP quota-resource) ")"</t>
			<t hangText="quota-resource     ="> resource-name SP resource-usage SP resource-limit</t>
			<t hangText="quota-response     ="> "QUOTA" SP quota-root-name SP quota-list</t>
			<t hangText="quotaroot-response ="> "QUOTAROOT" SP mailbox *(SP quota-root-name)</t>
			<t hangText="setquota           ="> "SETQUOTA" SP quota-root-name SP setquota-list</t>
			<t hangText="setquota-list      ="> "(" [setquota-resource *(SP setquota-resource)] ")"</t>
			<t hangText="setquota-resource  ="> resource-name SP resource-limit</t>
			<t hangText="quota-root-name    ="> astring</t>
			<t hangText="resource-limit     ="> number64</t>
			<t hangText="resource-name      ="> "STORAGE" / "MESSAGE" / "MAILBOX" /<vspace/>
                        "ANNOTATION-STORAGE" / resource-name-ext</t>
			<t hangText="resource-name-ext  ="> atom<vspace/>
                        ;; Future resource registrations</t>
			<t hangText="resource-usage     ="> number64<vspace/>
                        ;; must be less than corresponding resource-limit</t>
			<t hangText="capability-quota   ="> capa-quota-res / "QUOTASET" <vspace/>
                        ;; One or more capa-quota-res must be returned.<vspace/>
                        ;; Also "QUOTASET" can optionally be returned.</t>
			<t hangText="capa-quota-res     ="> "QUOTA=RES-" resource-name</t>
			<t hangText="status-att         =/"> "DELETED" / "DELETED-STORAGE"<vspace/>
                        ;; DELETED status data item MUST be supported<vspace/>
						;; when "QUOTA=RES-MESSAGE" capability is<vspace/>
						;; advertised.<vspace/>
                        ;; DELETED-STORAGE status data item MUST be<vspace/>
						;; supported when "QUOTA=RES-STORAGE" capability<vspace/>
						;; is advertised.</t>
      
      <!--Note that "status-att-val" is only defined in IMAP4rev2!-->
			<t hangText="status-att-val     =/"> status-att-deleted /<vspace/>
                        status-att-deleted-storage</t>
			<t hangText="status-att-deleted ="> "DELETED" SP number<vspace/>
                        ;; DELETED status data item MUST be supported<vspace/>
						;; when "QUOTA=RES-MESSAGE" capability is<vspace/>
						;; advertised.</t>
			<t hangText="status-att-deleted-storage ="> "DELETED-STORAGE" SP number64<vspace/>
                        ;; DELETED-STORAGE status data item MUST be<vspace/>
						;; supported when "QUOTA=RES-STORAGE" capability<vspace/>
						;; is advertised.</t>
        
     <!--/////We have a small problem below:
tag             = 1*<any ASTRING-CHAR except "+">

ASTRING-CHAR   = ATOM-CHAR / resp-specials

ATOM-CHAR       = <any CHAR except atom-specials>

atom-specials   = "(" / ")" / "{" / SP / CTL / list-wildcards /
                  quoted-specials / resp-specials

resp-specials   = "]"

     I.e., "]" is allowed in tags!!!
     -->
        
			<t hangText="resp-text-code     =/"> "OVERQUOTA"</t>
        
      <t hangText="number64           ="> &lt;Defined in RFC 9051&gt;</t>
        
			</list>
			</t>
		</section>

		<section title="Security Considerations">

      <t>
      Implementors should be careful to make sure the implementation of
      these commands does not violate the site's security policy. The
      resource usage of other users is likely to be considered confidential
      information and should not be divulged to unauthorized persons.
      In particular, no quota information should be disclosed to
      anonymous users.<!--///Add a ref to SASL ANONYMOUS?-->
      </t>

      <t>
      As for any resource shared across users (for example a quota root attached to a set of shared mailboxes),
      a user that can consume or render unusable the resource can affect the resources available
      to the other users; this might occur, for example, by a user with permission to
      execute SETQUOTA setting an artificially small value.
      </t>

      <t>
      Note that computing resource usage might incur a heavy load on the server.
      Server implementers should consider implementation techniques that
      lower load on servers, such as caching of resource usage information
      or usage of less precise computations when under heavy load.
      </t>

    </section>
		
		<section title="IANA Considerations">
      
      <section title="Changes/additions to the IMAP4 capabilities registry">
        
			<t>
				IMAP4 capabilities are registered by publishing a standards track or
				IESG approved Informational or Experimental RFC.
        The registry is currently located at:
			</t>

			<figure><artwork><![CDATA[
   https://www.iana.org/assignments/imap4-capabilities
    ]]></artwork></figure>

			<t>IANA is requested to update definition of the QUOTA extension to
			point to this document.
            IANA is also requested to add the "QUOTASET" capability to the IMAP4 capabilities registry,
            with this document as the reference.
            </t>

      <t>
        IANA is requested to reserve the prefix "QUOTA=RES-" in the IMAP4 capabilities registry and
        add a pointer to this document and to the IMAP quota resource type registry (see <xref target="iana-quota-res-types"/>).
      </t>

      <t>
        IANA is requested to reserve all other capabilities starting with "QUOTA=" prefix
        for future IETF Stream extensions to this document.
      </t>
      
      </section>

      <section title="IMAP quota resource type registry" anchor="iana-quota-res-types">
      
      <t>IANA is requested to create a new registry for IMAP quota resource types.
      Registration policy for this registry is "Specification Required". When registering
      a new quota resource type, the registrant need to provide the following:
      Name of the quota resource type, Author/Change Controller name and email address,
      short description, extra (if any) required and optional IMAP commands/responses,
      and a reference to a specification that describes the quota resource type in more details.</t>

      <t>Designated Experts should check that provided references are correct, that they
      describe the quota resource type being registered in sufficient details to be implementable,
      that syntax of any optional commands/responses is correct (e.g. ABNF validates),
      and their syntax/description complies with rules and limitations imposed by
      IMAP <xref target="RFC3501"/><xref target="RFC9051"/>.
      Designated Experts should avoid registering multiple identical quota resource types under
      different names and should provide advice to requestors about other possible
      quota resource types to use.
      </t>

      <t>
        This document includes initial registrations for the following IMAP quota resource type:
        STORAGE (<xref target="STORAGE"/>), MESSAGE (<xref target="MESSAGE"/>),
        MAILBOX (<xref target="MAILBOX"/>) and "ANNOTATION-STORAGE" (<xref target="ANNOTATION-STORAGE"/>).
        See <xref target="iana-quota-res-types-reg"/> for the registration templates. 
      </t>
        
      </section>

      <section title="Registrations of IMAP Quota Resource Types" anchor="iana-quota-res-types-reg">

        <t>
          <list style="hanging">
            <t hangText="Name of the quota resource type:">STORAGE</t>
            <t hangText="Author:">Alexey Melnikov &lt;alexey.melnikov@isode.com&gt;</t>
            <t hangText="Change Controller:">IESG &lt;iesg@ietf.org&gt;</t>
            <t hangText="Description:">The physical space estimate, in units of 1024 octets, of the mailboxes governed by the quota root.</t>
            <t hangText="Extra required IMAP commands/responses:">DELETED-STORAGE STATUS request data item and response data item</t>
            <t hangText="Extra optional IMAP commands/responses:">N/A</t>
            <t hangText="Reference:"><xref target="STORAGE"/> of RFCXXXX</t>
          </list>
        </t>

        <t>
          <list style="hanging">
            <t hangText="Name of the quota resource type:">MESSAGE</t>
            <t hangText="Author:">Alexey Melnikov &lt;alexey.melnikov@isode.com&gt;</t>
            <t hangText="Change Controller:">IESG &lt;iesg@ietf.org&gt;</t>
            <t hangText="Description:">The number of messages stored within the mailboxes governed by the quota root.</t>
            <t hangText="Extra required IMAP commands/responses:">DELETED STATUS request data item and response data item</t>
            <t hangText="Extra optional IMAP commands/responses:">N/A</t>
            <t hangText="Reference:"><xref target="MESSAGE"/> of RFCXXXX</t>
          </list>
        </t>

        <t>
          <list style="hanging">
            <t hangText="Name of the quota resource type:">MAILBOX</t>
            <t hangText="Author:">Alexey Melnikov &lt;alexey.melnikov@isode.com&gt;</t>
            <t hangText="Change Controller:">IESG &lt;iesg@ietf.org&gt;</t>
            <t hangText="Description:">The number of mailboxes governed by the quota root.</t>
            <t hangText="Extra required IMAP commands/responses:">N/A</t>
            <t hangText="Extra optional IMAP commands/responses:">N/A</t>
            <t hangText="Reference:"><xref target="MAILBOX"/> of RFCXXXX</t>
          </list>
        </t>

        <t>
          <list style="hanging">
            <t hangText="Name of the quota resource type:">ANNOTATION-STORAGE</t>
            <t hangText="Author:">Alexey Melnikov &lt;alexey.melnikov@isode.com&gt;</t>
            <t hangText="Change Controller:">IESG &lt;iesg@ietf.org&gt;</t>
            <t hangText="Description:">The maximum size of all annotations <xref target="RFC5257"/>,
            in units of 1024 octets, associated with all messages in the mailboxes governed by the quota root.
            </t>
            <t hangText="Extra required IMAP commands/responses:">N/A</t>
            <t hangText="Extra optional IMAP commands/responses:">N/A</t>
            <t hangText="Reference:"><xref target="ANNOTATION-STORAGE"/> of RFCXXXX</t>
          </list>
        </t>

<!--
        <t>
          <list style="hanging">
            <t hangText="Name of the quota resource type:"></t>
            <t hangText="Author:"></t>
            <t hangText="Change Controller:"></t>
            <t hangText="Description:"></t>
            <t hangText="Extra required IMAP commands/responses:">N/A</t>
            <t hangText="Extra optional IMAP commands/responses:">N/A</t>
            <t hangText="Reference:"></t>
          </list>
        </t>
-->
        
      </section>

    </section>

    <section title="Contributors">
      <t>
        Dave Cridland wrote lots of text in an earlier draft that became the basis for this document.
      </t>
    </section>

    <section title="Acknowledgments">
			<t>
				Editor of this document would like to thank the following people
				who provided useful comments or participated in discussions that
				lead to this update to RFC 2087:<vspace/>
        John Myers,<vspace/>
        Cyrus Daboo,<vspace/>
        Lyndon Nerenberg,<vspace/>
				Benjamin Kaduk,<vspace/>
				Roman Danyliw,<vspace/>
				Éric Vyncke.
			</t>

			<t>This document is a revision of RFC 2087. It borrows a lot of text
			from RFC 2087. Thus work of the RFC 2087 author John Myers is
			appreciated.
			</t>
		</section>
		
		<section title="Changes since RFC 2087" anchor="changes-since">
			<t>
			This document is a revision of RFC 2087. It tries to clarify the meaning
			of different terms used by RFC 2087. It also provides more examples,
			gives guidance on allowed server behaviour, defines IANA registry
			for quota resource types and provides initial registrations for 4 of
			them.</t>

			<t>
			When compared with RFC 2087, this document defines two more commonly
			used resource type, adds optional OVERQUOTA response code and
			defines two extra STATUS data items ("DELETED" and "DELETED-STORAGE").
			The DELETED STATUS data item must be implemented if the QUOTA=RES-MESSAGE capability
			is advertised. The DELETED-STORAGE STATUS data item must be implemented if
			the QUOTA=RES-STORAGE capability is advertised.
            For extensibility quota usage and quota limits are now 63 bit unsigned integers.
			</t>
		</section>
	</middle>
	<back>
		<references title="Normative References">
			&rfc2119;
      &rfc8174;
      &rfc3501;
      &rfc4314;
      &rfc5257;
      <reference anchor="ABNF">
				<front>
					<title>Augmented BNF for Syntax Specifications: ABNF</title>
					<author initials="D" surname="Crocker" fullname="Dave Crocker" role="editor">
						<organization />
					</author>
					<author initials="P" surname="Overell" fullname="Paul Overell" role="editor">
						<organization />
					</author>
					<date year="2008" month="January"/>
				</front>
				<seriesInfo name="RFC" value="5234" />
				<format type="TXT" target="https://www.rfc-editor.org/info/rfc5234" />
			</reference>

      &rfc9051;

    </references>
		<references title="Informative References">
			&rfc2087;
		</references>
	</back>
</rfc>
