<?xml version="1.0" encoding="US-ASCII"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>

<rfc category="std" number="8438" ipr="trust200902" submissionType="IETF" consensus="yes">


<front>
<title abbrev="IMAP STATUS=SIZE Extension">
  Internet Message Access Protocol (IMAP) - STATUS=SIZE Extension
</title>

<author fullname="Stephan Bosch" initials="S." surname="Bosch">
	<organization>Dovecot Oy</organization>
  <address>
    <postal>
      <street>Lars Sonckin Kaari 12</street>
      <code>02600</code>
      <city>Espoo</city>
      <country>Finland</country>
    </postal>
    <email>stephan.bosch@dovecot.fi</email>
  </address>
</author>

<date month="August" year="2018" />

<area>ART</area>
<workgroup>EXTRA</workgroup>
<keyword>imap</keyword>
<keyword>status</keyword>
<keyword>size</keyword>

<abstract>
<t>This document adds a new capability called "STATUS=SIZE" to the Internet
Message Access Protocol (IMAP). It allows retrieving the total storage size of a
mailbox with a single STATUS command rather than retrieving and summing the
sizes of all individual messages in that mailbox.
</t>
</abstract>
</front>

<middle>

<section title="Introduction">
<t>This document extends the Internet Message Access Protocol
(IMAP) <xref target="IMAP4rev1"/> with a new capability called "STATUS=SIZE".
To determine the total storage size of a mailbox, an IMAP client currently needs
to retrieve all message sizes individually using the FETCH command with the
RFC822.SIZE data item. The STATUS=SIZE capability provides a more efficient
means of achieving this. It extends the STATUS command with a new "SIZE" data
item, which indicates the total size of all messages in the target mailbox.
This way, this information can be queried with just one STATUS command. When the
LIST-STATUS IMAP capability <xref target="LIST-STATUS"/> is also available,
the SIZE data item can be queried for many mailboxes at once using just one LIST
command.</t>

<t>This capability is particularly useful for IMAP clients that do not cache the
state of the message store, such as most webmail clients. Without the
"STATUS=SIZE" capability, such clients need to fetch all message sizes from the
server when the size of an individual mailbox needs to be determined. For
example, a user may request detailed quota usage information for each mailbox to
find out which specific mailboxes consume most of the available storage
resources. Using this information, the user can get an overview of which
mailboxes need to be cleaned up to reduce quota usage. The QUOTA capability
<xref target="QUOTA"/> is no help in that scenario, since the provided QUOTAROOT
command can only yield the STORAGE resource usage of a whole quota root,
not each individual mailbox within that root.</t>
</section>

<section title="Conventions Used in This Document">
<t>In examples, "C:" indicates lines sent by a client that is connected
to a server.  "S:" indicates lines sent by the server to the client.
</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&nbsp;14 <xref target="KEYWORDS"/> <xref target="KEYWORDS2"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>



</section>

<section title="STATUS Command and Response Extensions">

<t>This extension defines one new status data item for the STATUS command and
response:
<list style="hanging">
  <t hangText="SIZE"><vspace blankLines="0"/>
  The total size of the mailbox in octets. This is not strictly required to be
  an exact value, but it MUST be equal to or greater than the sum of the values
  of the <xref target="IMAP4rev1">RFC822.SIZE FETCH message data item </xref> of
  all messages in the mailbox. When the QUOTA capability
  <xref target="QUOTA"/> is also supported, this value SHOULD be equal to the
  storage usage value used to enforce the STORAGE resource limit for this
  mailbox. This way, the client can directly infer the quota usage.</t>
</list>
</t>
<t>Since the total storage size of a mailbox can easily exceed 4 GB, clients
MUST be capable of receiving 63-bit SIZE data item values. The message size is
chosen to be at most 63 bits wide rather than 64 bits to make implementations
on various platforms (such as Java) easier.</t>

<t>Example:</t>
<?rfc needLines="4" ?>
<figure><artwork><![CDATA[
C: A01 STATUS frop (MESSAGES SIZE UIDNEXT)
S: * STATUS frop (MESSAGES 8 SIZE 44421 UIDNEXT 242344)
S: A01 OK STATUS completed
]]></artwork></figure>

<t>The same information can be obtained by using the following commands,
albeit less efficiently:</t>
<?rfc needLines="20" ?>
<figure><artwork><![CDATA[
C: A02 SELECT "frop"
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * 8 EXISTS
S: * 1 RECENT
S: * OK [UNSEEN 7] First unseen.
S: * OK [UIDVALIDITY 1364851417] UIDs valid
S: * OK [UIDNEXT 242344] Predicted next UID
S: * OK [HIGHESTMODSEQ 3914] Highest
S: A02 OK [READ-WRITE] Select completed.
C: A03 FETCH 1:* (RFC822.SIZE)
S: * 1 FETCH (RFC822.SIZE 3224)
S: * 2 FETCH (RFC822.SIZE 1222)
S: * 3 FETCH (RFC822.SIZE 444)
S: * 4 FETCH (RFC822.SIZE 4516)
S: * 5 FETCH (RFC822.SIZE 544)
S: * 6 FETCH (RFC822.SIZE 922)
S: * 7 FETCH (RFC822.SIZE 31126)
S: * 8 FETCH (RFC822.SIZE 2423)
S: A03 OK Fetch completed.
]]></artwork></figure>

<t>When the LIST-STATUS IMAP capability <xref target="LIST-STATUS"/> is
also available, the STATUS command can be combined with the LIST command to
further improve efficiency. This way, the sizes of many mailboxes can be
queried with just one LIST command.</t>

<t>Example:</t>
<?rfc needLines="7" ?>
<figure><artwork><![CDATA[
C: A04 LIST "" % RETURN (STATUS (MESSAGES SIZE))
S: * LIST () "." "INBOX"
S: * STATUS "INBOX" (MESSAGES 17 SIZE 16234)
S: * LIST () "." "frop"
S: * STATUS "frop" (MESSAGES 8 SIZE 44421)
S: A04 OK List completed.
]]></artwork></figure>

</section>

<section anchor="Syntax" title="Formal Syntax">
<t>The following syntax specification augments the grammar specified in
<xref target="IMAP4rev1"/> and <xref target="IMAP4-ABNF"/>. It uses the
Augmented Backus-Naur Form (ABNF) notation as specified in
<xref target="ABNF"/>. Elements not defined here are taken from
<xref target="IMAP4rev1"/> and <xref target="IMAP4-ABNF"/>.</t>

<?rfc needLines="2" ?>
<figure><artwork type="ABNF"><![CDATA[
capability     =/ "STATUS=SIZE"

status-att     =/ "SIZE"

status-att-val =/ "SIZE" SP number64

number64       = 1*DIGIT
                 ; Unsigned 63-bit integer
                 ; (0 <= n <= 9,223,372,036,854,775,807)

]]></artwork></figure>

</section>

<section anchor="Security" title="Security Considerations">
<t>There are no known additional security issues with this extension
beyond those described for the base protocol <xref target="IMAP4rev1"/> and the LIST-STATUS extension <xref target="LIST-STATUS"/>.</t>
</section>

<section anchor="IANA" title="IANA Considerations">
<t>IANA has added "STATUS=SIZE" to the "IMAP Capabilities"
registry located at
&lt;http://www.iana.org/assignments/imap-capabilities&gt;.</t>
</section>

</middle>


<back>


<references title="Normative References">

<reference  anchor='KEYWORDS' target='https://www.rfc-editor.org/info/rfc2119'>
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials='S.' surname='Bradner' fullname='S. Bradner'><organization /></author>
<date year='1997' month='March' />
</front>
<seriesInfo name='BCP' value='14'/>
<seriesInfo name='RFC' value='2119'/>
<seriesInfo name='DOI' value='10.17487/RFC2119'/>
</reference>

<reference  anchor='KEYWORDS2' target='https://www.rfc-editor.org/info/rfc8174'>
<front>
<title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
<author initials='B.' surname='Leiba' fullname='B. Leiba'><organization /></author>
<date year='2017' month='May' />
</front>
<seriesInfo name='BCP' value='14'/>
<seriesInfo name='RFC' value='8174'/>
<seriesInfo name='DOI' value='10.17487/RFC8174'/>
</reference>

<reference  anchor='ABNF' target='https://www.rfc-editor.org/info/rfc5234'>
<front>
<title>Augmented BNF for Syntax Specifications: ABNF</title>
<author initials='D.' surname='Crocker' fullname='D. Crocker' role='editor'><organization /></author>
<author initials='P.' surname='Overell' fullname='P. Overell'><organization /></author>
<date year='2008' month='January' />
</front>
<seriesInfo name='STD' value='68'/>
<seriesInfo name='RFC' value='5234'/>
<seriesInfo name='DOI' value='10.17487/RFC5234'/>
</reference>


<reference  anchor='IMAP4rev1' target='https://www.rfc-editor.org/info/rfc3501'>
<front>
<title>INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1</title>
<author initials='M.' surname='Crispin' fullname='M. Crispin'><organization /></author>
<date year='2003' month='March' />
</front>
<seriesInfo name='RFC' value='3501'/>
<seriesInfo name='DOI' value='10.17487/RFC3501'/>
</reference>



<reference  anchor='IMAP4-ABNF' target='https://www.rfc-editor.org/info/rfc4466'>
<front>
<title>Collected Extensions to IMAP4 ABNF</title>
<author initials='A.' surname='Melnikov' fullname='A. Melnikov'><organization /></author>
<author initials='C.' surname='Daboo' fullname='C. Daboo'><organization /></author>
<date year='2006' month='April' />
</front>
<seriesInfo name='RFC' value='4466'/>
<seriesInfo name='DOI' value='10.17487/RFC4466'/>
</reference>


<reference  anchor='LIST-STATUS' target='https://www.rfc-editor.org/info/rfc5819'>
<front>
<title>IMAP4 Extension for Returning STATUS Information in Extended LIST</title>
<author initials='A.' surname='Melnikov' fullname='A. Melnikov'><organization /></author>
<author initials='T.' surname='Sirainen' fullname='T. Sirainen'><organization /></author>
<date year='2010' month='March' />
</front>
<seriesInfo name='RFC' value='5819'/>
<seriesInfo name='DOI' value='10.17487/RFC5819'/>
</reference>


<reference  anchor='QUOTA' target='https://www.rfc-editor.org/info/rfc2087'>
<front>
<title>IMAP4 QUOTA extension</title>
<author initials='J.' surname='Myers' fullname='J. Myers'><organization /></author>
<date year='1997' month='January' />
</front>
<seriesInfo name='RFC' value='2087'/>
<seriesInfo name='DOI' value='10.17487/RFC2087'/>
</reference>


</references>


<section title="Acknowledgements" numbered="no">
<t>Thanks to Bron Gondwana, Alexey Melnikov, Stan Kalisch, and Michael Slusarz
for reviews and suggestions.</t>
</section>

</back>
</rfc>
