<?xml version='1.0' encoding='utf-8'?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" category="std" docName="draft-ietf-mailmaint-imap-uidbatches-22" number="10022" ipr="trust200902" obsoletes="" updates="" submissionType="IETF" xml:lang="en" sortRefs="true" symRefs="true" consensus="true" tocInclude="true" prepTime="2026-07-31T21:07:31" indexInclude="true" scripts="Common,Latin" tocDepth="3">
  <link href="https://datatracker.ietf.org/doc/draft-ietf-mailmaint-imap-uidbatches-22" rel="prev"/>
  <link href="https://dx.doi.org/10.17487/rfc10022" rel="alternate"/>
  <link href="urn:issn:2070-1721" rel="alternate"/>
  <front>
    <title>IMAP UIDBATCHES Extension</title>
    <seriesInfo name="RFC" value="10022" stream="IETF"/>
    <author fullname="Daniel Eggert" initials="D." role="editor" surname="Eggert">
      <organization showOnFrontPage="true">Apple Inc</organization>
      <address>
        <postal>
          <street>One Apple Park Way</street>
          <city>Cupertino</city>
          <region>CA</region>
          <code>95014</code>
          <country>United States of America</country>
        </postal>
        <email>deggert@apple.com</email>
      </address>
    </author>
    <date month="07" year="2026"/>
    <area>ART</area>
    <workgroup>mailmaint</workgroup>
    <keyword>IMAP</keyword>
    <abstract pn="section-abstract">
      <t indent="0" pn="section-abstract-1">The <tt>UIDBATCHES</tt> extension of the Internet Message Access Protocol (IMAP) allows clients to retrieve Unique Identifier (UID) ranges that partition a mailbox's messages into equally sized batches. This enables clients to perform operations such as FETCH, SEARCH, and STORE on specific message batches, providing better control over resource usage and response sizes. The extension is particularly useful with the UIDONLY mode where sequence numbers are unavailable.</t>
    </abstract>
    <boilerplate>
      <section anchor="status-of-memo" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.1">
        <name slugifiedName="name-status-of-this-memo">Status of This Memo</name>
        <t indent="0" pn="section-boilerplate.1-1">
            This is an Internet Standards Track document.
        </t>
        <t indent="0" pn="section-boilerplate.1-2">
            This document is a product of the Internet Engineering Task Force
            (IETF).  It represents the consensus of the IETF community.  It has
            received public review and has been approved for publication by
            the Internet Engineering Steering Group (IESG).  Further
            information on Internet Standards is available in Section 2 of 
            RFC 7841.
        </t>
        <t indent="0" pn="section-boilerplate.1-3">
            Information about the current status of this document, any
            errata, and how to provide feedback on it may be obtained at
            <eref target="https://www.rfc-editor.org/info/rfc10022" brackets="none"/>.
        </t>
      </section>
      <section anchor="copyright" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.2">
        <name slugifiedName="name-copyright-notice">Copyright Notice</name>
        <t indent="0" pn="section-boilerplate.2-1">
            Copyright (c) 2026 IETF Trust and the persons identified as the
            document authors. All rights reserved.
        </t>
        <t indent="0" pn="section-boilerplate.2-2">
            This document is subject to BCP 78 and the IETF Trust's Legal
            Provisions Relating to IETF Documents
            (<eref target="https://trustee.ietf.org/license-info" brackets="none"/>) in effect on the date of
            publication of this document. Please review these documents
            carefully, as they describe your rights and restrictions with
            respect to this document. Code Components extracted from this
            document must include Revised BSD License text as described in
            Section 4.e of the Trust Legal Provisions and are provided without
            warranty as described in the Revised BSD License.
        </t>
      </section>
    </boilerplate>
    <toc>
      <section anchor="toc" numbered="false" removeInRFC="false" toc="exclude" pn="section-toc.1">
        <name slugifiedName="name-table-of-contents">Table of Contents</name>
        <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1">
          <li pn="section-toc.1-1.1">
            <t indent="0" keepWithNext="true" pn="section-toc.1-1.1.1"><xref derivedContent="1" format="counter" sectionFormat="of" target="section-1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-introduction">Introduction</xref></t>
          </li>
          <li pn="section-toc.1-1.2">
            <t indent="0" keepWithNext="true" pn="section-toc.1-1.2.1"><xref derivedContent="2" format="counter" sectionFormat="of" target="section-2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-document-conventions">Document Conventions</xref></t>
          </li>
          <li pn="section-toc.1-1.3">
            <t indent="0" pn="section-toc.1-1.3.1"><xref derivedContent="3" format="counter" sectionFormat="of" target="section-3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-the-uidbatches-extension">The UIDBATCHES Extension</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.3.2">
              <li pn="section-toc.1-1.3.2.1">
                <t indent="0" pn="section-toc.1-1.3.2.1.1"><xref derivedContent="3.1" format="counter" sectionFormat="of" target="section-3.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-uidbatches-command">UIDBATCHES Command</xref></t>
                <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.3.2.1.2">
                  <li pn="section-toc.1-1.3.2.1.2.1">
                    <t indent="0" keepWithNext="true" pn="section-toc.1-1.3.2.1.2.1.1"><xref derivedContent="3.1.1" format="counter" sectionFormat="of" target="section-3.1.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-example-usage">Example Usage</xref></t>
                  </li>
                  <li pn="section-toc.1-1.3.2.1.2.2">
                    <t indent="0" pn="section-toc.1-1.3.2.1.2.2.1"><xref derivedContent="3.1.2" format="counter" sectionFormat="of" target="section-3.1.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-response-format">Response Format</xref></t>
                  </li>
                  <li pn="section-toc.1-1.3.2.1.2.3">
                    <t indent="0" pn="section-toc.1-1.3.2.1.2.3.1"><xref derivedContent="3.1.3" format="counter" sectionFormat="of" target="section-3.1.3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-batch-sizes">Batch Sizes</xref></t>
                  </li>
                  <li pn="section-toc.1-1.3.2.1.2.4">
                    <t indent="0" pn="section-toc.1-1.3.2.1.2.4.1"><xref derivedContent="3.1.4" format="counter" sectionFormat="of" target="section-3.1.4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-uids">UIDs</xref></t>
                  </li>
                  <li pn="section-toc.1-1.3.2.1.2.5">
                    <t indent="0" pn="section-toc.1-1.3.2.1.2.5.1"><xref derivedContent="3.1.5" format="counter" sectionFormat="of" target="section-3.1.5"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-batch-ranges">Batch Ranges</xref></t>
                  </li>
                  <li pn="section-toc.1-1.3.2.1.2.6">
                    <t indent="0" pn="section-toc.1-1.3.2.1.2.6.1"><xref derivedContent="3.1.6" format="counter" sectionFormat="of" target="section-3.1.6"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-empty-responses">Empty Responses</xref></t>
                  </li>
                  <li pn="section-toc.1-1.3.2.1.2.7">
                    <t indent="0" pn="section-toc.1-1.3.2.1.2.7.1"><xref derivedContent="3.1.7" format="counter" sectionFormat="of" target="section-3.1.7"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-large-mailboxes">Large Mailboxes</xref></t>
                  </li>
                </ul>
              </li>
              <li pn="section-toc.1-1.3.2.2">
                <t indent="0" pn="section-toc.1-1.3.2.2.1"><xref derivedContent="3.2" format="counter" sectionFormat="of" target="section-3.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-interaction-with-messagelim">Interaction with MESSAGELIMIT Extension</xref></t>
              </li>
              <li pn="section-toc.1-1.3.2.3">
                <t indent="0" pn="section-toc.1-1.3.2.3.1"><xref derivedContent="3.3" format="counter" sectionFormat="of" target="section-3.3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-interaction-with-uidonly-ex">Interaction with UIDONLY Extension</xref></t>
              </li>
              <li pn="section-toc.1-1.3.2.4">
                <t indent="0" pn="section-toc.1-1.3.2.4.1"><xref derivedContent="3.4" format="counter" sectionFormat="of" target="section-3.4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-interaction-with-searchres-">Interaction with SEARCHRES Extension</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.4">
            <t indent="0" pn="section-toc.1-1.4.1"><xref derivedContent="4" format="counter" sectionFormat="of" target="section-4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-formal-syntax">Formal Syntax</xref></t>
          </li>
          <li pn="section-toc.1-1.5">
            <t indent="0" pn="section-toc.1-1.5.1"><xref derivedContent="5" format="counter" sectionFormat="of" target="section-5"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-operational-considerations">Operational Considerations</xref></t>
          </li>
          <li pn="section-toc.1-1.6">
            <t indent="0" pn="section-toc.1-1.6.1"><xref derivedContent="6" format="counter" sectionFormat="of" target="section-6"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-security-considerations">Security Considerations</xref></t>
          </li>
          <li pn="section-toc.1-1.7">
            <t indent="0" pn="section-toc.1-1.7.1"><xref derivedContent="7" format="counter" sectionFormat="of" target="section-7"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-iana-considerations">IANA Considerations</xref></t>
          </li>
          <li pn="section-toc.1-1.8">
            <t indent="0" pn="section-toc.1-1.8.1"><xref derivedContent="8" format="counter" sectionFormat="of" target="section-8"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-references">References</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.8.2">
              <li pn="section-toc.1-1.8.2.1">
                <t indent="0" pn="section-toc.1-1.8.2.1.1"><xref derivedContent="8.1" format="counter" sectionFormat="of" target="section-8.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-normative-references">Normative References</xref></t>
              </li>
              <li pn="section-toc.1-1.8.2.2">
                <t indent="0" pn="section-toc.1-1.8.2.2.1"><xref derivedContent="8.2" format="counter" sectionFormat="of" target="section-8.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-informative-references">Informative References</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.9">
            <t indent="0" pn="section-toc.1-1.9.1"><xref derivedContent="Appendix A" format="default" sectionFormat="of" target="section-appendix.a"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-comparison-with-existing-co">Comparison with Existing Commands and Extensions</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.9.2">
              <li pn="section-toc.1-1.9.2.1">
                <t indent="0" pn="section-toc.1-1.9.2.1.1"><xref derivedContent="A.1" format="counter" sectionFormat="of" target="section-appendix.a.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-similarity-to-uid-search-co">Similarity to UID SEARCH Command</xref></t>
              </li>
              <li pn="section-toc.1-1.9.2.2">
                <t indent="0" pn="section-toc.1-1.9.2.2.1"><xref derivedContent="A.2" format="counter" sectionFormat="of" target="section-appendix.a.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-similarity-to-partial-exten">Similarity to PARTIAL Extension</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.10">
            <t indent="0" pn="section-toc.1-1.10.1"><xref derivedContent="" format="none" sectionFormat="of" target="section-appendix.b"/><xref derivedContent="" format="title" sectionFormat="of" target="name-authors-address">Author's Address</xref></t>
          </li>
        </ul>
      </section>
    </toc>
  </front>
  <middle>
    <section numbered="true" removeInRFC="false" toc="include" pn="section-1">
      <name slugifiedName="name-introduction">Introduction</name>
      <t indent="0" pn="section-1-1">This document defines an extension to the Internet Message Access Protocol (IMAP) <xref target="RFC9051" format="default" sectionFormat="of" derivedContent="RFC9051"/> that enables clients to retrieve UID ranges that partition a mailbox's messages into evenly sized batches. This extension is compatible with both IMAP4rev1 <xref target="RFC3501" format="default" sectionFormat="of" derivedContent="RFC3501"/> and IMAP4rev2 <xref target="RFC9051" format="default" sectionFormat="of" derivedContent="RFC9051"/>.</t>
      <t indent="0" pn="section-1-2">The primary purpose of this extension is to allow clients to predetermine UID ranges that limit the number of messages each command operates on. This capability is especially beneficial when used with the UIDONLY mode <xref target="RFC9586" format="default" sectionFormat="of" derivedContent="RFC9586"/>, where sequence numbers are unavailable to the client, making it difficult to create message batches using conventional methods.</t>
    </section>
    <section numbered="true" removeInRFC="false" toc="include" pn="section-2">
      <name slugifiedName="name-document-conventions">Document Conventions</name>
      <t indent="0" pn="section-2-1">In protocol examples, "C:" indicates lines sent by a client that is connected to a server and "S:" indicates lines sent by the server to the client. These prefixes are not part of the protocol. Long lines in examples are wrapped using "The Single Backslash Strategy" described in <xref target="RFC8792" format="default" sectionFormat="of" derivedContent="RFC8792"/>.</t>
      <t indent="0" pn="section-2-2">
    The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
    "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
    described in BCP 14 <xref target="RFC2119" format="default" sectionFormat="of" derivedContent="RFC2119"/> <xref target="RFC8174" format="default" sectionFormat="of" derivedContent="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
      </t>
      <t indent="0" pn="section-2-3">Other capitalized words are IMAP keywords <xref target="RFC9051" format="default" sectionFormat="of" derivedContent="RFC9051"/> or keywords from this document.</t>
    </section>
    <section anchor="uidbatches-extension" numbered="true" removeInRFC="false" toc="include" pn="section-3">
      <name slugifiedName="name-the-uidbatches-extension">The UIDBATCHES Extension</name>
      <t indent="0" pn="section-3-1">An IMAP server advertises support for the <tt>UIDBATCHES</tt> extension by including the <tt>UIDBATCHES</tt> capability in the CAPABILITY response / response code.</t>
      <section anchor="command" numbered="true" removeInRFC="false" toc="include" pn="section-3.1">
        <name slugifiedName="name-uidbatches-command">UIDBATCHES Command</name>
        <dl newline="true" indent="3" spacing="normal" pn="section-3.1-1">
          <dt pn="section-3.1-1.1">Arguments:</dt>
          <dd pn="section-3.1-1.2">
            <t indent="0" pn="section-3.1-1.2.1">Message count per batch.</t>
            <t indent="0" pn="section-3.1-1.2.2"><bcp14>OPTIONAL</bcp14> batch range.</t>
          </dd>
          <dt pn="section-3.1-1.3">Responses:</dt>
          <dd pn="section-3.1-1.4">
            <bcp14>REQUIRED</bcp14> untagged response: <tt>UIDBATCHES</tt></dd>
          <dt pn="section-3.1-1.5">Result:</dt>
          <dd pn="section-3.1-1.6">
            <t indent="0" pn="section-3.1-1.6.1">OK uidbatches completed</t>
            <t indent="0" pn="section-3.1-1.6.2"><tt>NO</tt> command exceeds limits</t>
            <t indent="0" pn="section-3.1-1.6.3">BAD command unknown or arguments invalid</t>
          </dd>
        </dl>
        <t indent="0" pn="section-3.1-2">The <tt>UIDBATCHES</tt> command requests UID ranges that partition the messages in the currently selected mailbox into equally sized batches. The server returns these ranges in descending UID order, with batch 1 containing the highest UIDs (most recent messages), batch 2 containing the next highest set of UIDs, and so on.</t>
        <t indent="0" pn="section-3.1-3">For a mailbox with M messages, requesting batches of size N returns UID ranges corresponding to the following sequence number ranges (where sequence numbers are ordered from 1 to M, with M being the most recent message):</t>
        <sourcecode markers="false" pn="section-3.1-4">
Batch 1: M:(M-N+1)     // Most recent N messages
Batch 2: (M-N):(M-2*N+1)  // Next N messages
Batch 3: (M-2*N):(M-3*N+1) // Next N messages
...and so on</sourcecode>
        <section anchor="example-usage" numbered="true" removeInRFC="false" toc="include" pn="section-3.1.1">
          <name slugifiedName="name-example-usage">Example Usage</name>
          <t indent="0" pn="section-3.1.1-1">The following example demonstrates how a client uses <tt>UIDBATCHES</tt> to partition a mailbox into manageable batches:</t>
          <sourcecode markers="false" pn="section-3.1.1-2">
========== NOTE: '\' line wrapping per RFC 8792 ===========

C: A142 SELECT INBOX
S: * 6823 EXISTS
S: * 1 RECENT
S: * OK [UNSEEN 12] Message 12 is first unseen
S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: * OK [UIDNEXT 215296] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited
S: A142 OK [READ-WRITE] SELECT completed
C: A143 UIDBATCHES 2000
S: * UIDBATCHES (TAG "A143") \
       215295:99696,99695:20351,20350:7830,7829:1
S: A143 OK UIDBATCHES Completed</sourcecode>
          <t indent="0" pn="section-3.1.1-3">The server's response provides four UID ranges:</t>
          <ol type="1" group="reqs" start="1" indent="adaptive" spacing="normal" pn="section-3.1.1-4">
            <li pn="section-3.1.1-4.1" derivedCounter="1.">215295:99696</li>
            <li pn="section-3.1.1-4.2" derivedCounter="2.">99695:20351</li>
            <li pn="section-3.1.1-4.3" derivedCounter="3.">20350:7830</li>
            <li pn="section-3.1.1-4.4" derivedCounter="4.">7829:1</li>
          </ol>
          <t indent="0" pn="section-3.1.1-5">Each range contains up to 2,000 messages, except the last range, which contains the remaining 823 messages.</t>
          <t indent="0" pn="section-3.1.1-6">As new messages cannot appear within these UID ranges, the number of messages in each range will not increase. However, it may decrease as messages are deleted.</t>
          <t indent="0" pn="section-3.1.1-7">It is only appropriate to resend <tt>UIDBATCHES</tt> if one of the following conditions is met:</t>
          <ol type="1" group="conditions" start="1" indent="adaptive" spacing="normal" pn="section-3.1.1-8">
            <li pn="section-3.1.1-8.1" derivedCounter="1.">A different mailbox has been selected</li>
            <li pn="section-3.1.1-8.2" derivedCounter="2.">More than N/2 messages have been expunged from the mailbox (where N is the batch size)</li>
            <li pn="section-3.1.1-8.3" derivedCounter="3.">More than N/2 new messages have been received into the mailbox</li>
          </ol>
          <t indent="0" pn="section-3.1.1-9">To prevent server overload, the client <bcp14>MUST NOT</bcp14> resend <tt>UIDBATCHES</tt> otherwise.</t>
          <t indent="0" pn="section-3.1.1-10">Computing message batches may be resource-intensive for servers.</t>
          <t indent="0" pn="section-3.1.1-11">The client can keep track of the number of <tt>EXPUNGE</tt> or <tt>VANISHED</tt> messages and re-run <tt>UIDBATCHES</tt> if many messages are deleted.</t>
          <t indent="0" pn="section-3.1.1-12">As new messages arrive into the mailbox, the client should add these to a new message batch (starting at UID 215296 in the above example). Once N/2 or more new messages have been added to the mailbox, the client <bcp14>MAY</bcp14> ask for updated batches by re-running the <tt>UIDBATCHES</tt> command.</t>
          <t indent="0" pn="section-3.1.1-13">The server <bcp14>SHOULD</bcp14> reject <tt>UIDBATCHES</tt> commands with a <tt>NO</tt> response with the <tt>LIMIT</tt> response code if the client exceeds this limit. Servers <bcp14>MAY</bcp14> choose to track client requests and mailbox state changes to enforce these restrictions and prevent resource abuse.</t>
        </section>
        <section anchor="response-format" numbered="true" removeInRFC="false" toc="include" pn="section-3.1.2">
          <name slugifiedName="name-response-format">Response Format</name>
          <t indent="0" pn="section-3.1.2-1">The server <bcp14>MUST</bcp14> reply with a <tt>UIDBATCHES</tt> response, even if no ranges are returned (see <xref target="empty-responses" format="default" sectionFormat="of" derivedContent="Section 3.1.6"/>). The <tt>UIDBATCHES</tt> response <bcp14>MUST</bcp14> include the tag of the command it relates to (similar to an <tt>ESEARCH</tt> response defined in <xref target="RFC4731" format="default" sectionFormat="of" derivedContent="RFC4731"/>).</t>
          <t indent="0" pn="section-3.1.2-2">The UID ranges in the response <bcp14>MUST</bcp14> be ordered in descending sequence, from the highest to the lowest UIDs.</t>
        </section>
        <section anchor="batch-sizes" numbered="true" removeInRFC="false" toc="include" pn="section-3.1.3">
          <name slugifiedName="name-batch-sizes">Batch Sizes</name>
          <t indent="0" pn="section-3.1.3-1">To ensure efficient server operation and prevent abuse, this extension enforces constraints on batch sizes. The design balances server efficiency requirements with the primary use case of working effectively with the UIDONLY mode <xref target="RFC9586" format="default" sectionFormat="of" derivedContent="RFC9586"/>, without creating a mechanism that circumvents the sequence number restrictions of that mode.</t>
          <section anchor="batch-size-overview" numbered="true" removeInRFC="false" toc="exclude" pn="section-3.1.3.1">
            <name slugifiedName="name-batch-size-summary">Batch Size Summary</name>
            <t indent="0" pn="section-3.1.3.1-1">The following table provides a quick reference for batch size constraints:</t>
            <table anchor="batch-size-constraints-table" align="center" pn="table-1">
              <name slugifiedName="name-batch-size-constraints">Batch Size Constraints</name>
              <thead>
                <tr>
                  <th align="left" colspan="1" rowspan="1">Constraint</th>
                  <th align="left" colspan="1" rowspan="1">Client Request</th>
                  <th align="left" colspan="1" rowspan="1">Server Response</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td align="left" colspan="1" rowspan="1">Minimum</td>
                  <td align="left" colspan="1" rowspan="1">500 messages</td>
                  <td align="left" colspan="1" rowspan="1">Aim for &gt;= 90% of requested size</td>
                </tr>
                <tr>
                  <td align="left" colspan="1" rowspan="1">Maximum</td>
                  <td align="left" colspan="1" rowspan="1">No limit</td>
                  <td align="left" colspan="1" rowspan="1">Never exceed requested size</td>
                </tr>
                <tr>
                  <td align="left" colspan="1" rowspan="1">Exception</td>
                  <td align="left" colspan="1" rowspan="1">-</td>
                  <td align="left" colspan="1" rowspan="1">May be smaller during mailbox changes</td>
                </tr>
              </tbody>
            </table>
            <t indent="0" pn="section-3.1.3.1-3">Key principles:</t>
            <ul bare="false" empty="false" indent="3" spacing="normal" pn="section-3.1.3.1-4">
              <li pn="section-3.1.3.1-4.1">Clients <bcp14>MUST</bcp14> request at least 500 messages per batch (see Sections <xref target="batch-size-rationale" format="counter" sectionFormat="of" derivedContent="3.1.3.4"/> and <xref target="interaction-uidonly" format="counter" sectionFormat="of" derivedContent="3.3"/>)</li>
              <li pn="section-3.1.3.1-4.2">Servers <bcp14>MUST NOT</bcp14> return more messages than requested</li>
              <li pn="section-3.1.3.1-4.3">Servers <bcp14>SHOULD</bcp14> return batches close to the requested size (&gt;= 90% when possible)</li>
              <li pn="section-3.1.3.1-4.4">Exact batch sizes may vary due to implementation efficiency or mailbox changes</li>
            </ul>
          </section>
          <section anchor="batch-size-requirements" numbered="true" removeInRFC="false" toc="exclude" pn="section-3.1.3.2">
            <name slugifiedName="name-minimum-batch-size">Minimum Batch Size</name>
            <t indent="0" pn="section-3.1.3.2-1">The server <bcp14>MUST</bcp14> support batch sizes of 500 messages or larger. This minimum size prevents clients from misusing the extension to effectively reconstruct sequence numbers while still allowing reasonable batch operations.</t>
            <t indent="0" pn="section-3.1.3.2-2">Note that clients <bcp14>MUST</bcp14> be prepared to handle batches smaller than requested, as detailed in <xref target="batch-size-flexibility" format="default" sectionFormat="of" derivedContent="Section 3.1.3.3"/>.</t>
            <t indent="0" pn="section-3.1.3.2-3">The server <bcp14>MUST</bcp14> respond with <tt>NO</tt> and a response code <tt>TOOFEW</tt> if the client uses a batch size smaller than the minimum allowed by the server:</t>
            <sourcecode markers="false" pn="section-3.1.3.2-4">
S: A302 NO [TOOFEW] Minimum batch size is 500</sourcecode>
          </section>
          <section anchor="batch-size-flexibility" numbered="true" removeInRFC="false" toc="exclude" pn="section-3.1.3.3">
            <name slugifiedName="name-server-response-flexibility">Server Response Flexibility</name>
            <t indent="0" pn="section-3.1.3.3-1">While servers <bcp14>SHOULD</bcp14> return batches that correspond exactly to the requested size, they have flexibility in specific circumstances to enable efficient implementations.</t>
            <section anchor="batch-size-hard-constraints" numbered="true" removeInRFC="false" toc="exclude" pn="section-3.1.3.3.1">
              <name slugifiedName="name-hard-constraints">Hard Constraints</name>
              <t indent="0" pn="section-3.1.3.3.1-1">The server <bcp14>MUST NOT</bcp14> return ranges that contain more than the number of messages per batch requested by the client. This is a strict upper bound that cannot be exceeded.</t>
              <t indent="0" pn="section-3.1.3.3.1-2">If the requested batch size equals or exceeds the total number of messages in the mailbox, the server <bcp14>MUST</bcp14> return a single UID range spanning all messages.</t>
            </section>
            <section anchor="batch-size-permitted-variations" numbered="true" removeInRFC="false" toc="exclude" pn="section-3.1.3.3.2">
              <name slugifiedName="name-permitted-variations">Permitted Variations</name>
              <t indent="0" pn="section-3.1.3.3.2-1">Servers <bcp14>MAY</bcp14> return fewer messages per range in two specific circumstances:</t>
              <ol indent="adaptive" spacing="normal" start="1" type="1" pn="section-3.1.3.3.2-2">
                      <li pn="section-3.1.3.3.2-2.1" derivedCounter="1.">When doing so makes the implementation substantially simpler and/or more efficient</li>
                <li pn="section-3.1.3.3.2-2.2" derivedCounter="2.">When there are changes in mailbox state during the execution of the <tt>UIDBATCHES</tt> command, particularly when messages are expunged</li>
              </ol>
              <t indent="0" pn="section-3.1.3.3.2-3">However, servers <bcp14>SHOULD NOT</bcp14> return batches that are substantially smaller than requested and <bcp14>SHOULD</bcp14> aim to stay within 90% of the requested size. This guideline reflects the fact that clients typically choose batch sizes based on their intended use, such as displaying a specific number of messages to users.</t>
            </section>
            <section anchor="batch-size-dynamic-changes" numbered="true" removeInRFC="false" toc="exclude" pn="section-3.1.3.3.3">
              <name slugifiedName="name-dynamic-changes">Dynamic Changes</name>
              <t indent="0" pn="section-3.1.3.3.3-1">Mailbox state changes during <tt>UIDBATCHES</tt> execution can result in servers returning substantially fewer messages in each batch, particularly when message expungement reduces the overall mailbox size. Clients can detect these situations through the <tt>EXPUNGE</tt>, <tt>VANISHED</tt>, or <tt>EXISTS</tt> responses they receive.</t>
            </section>
            <section anchor="batch-size-practical-implications" numbered="true" removeInRFC="false" toc="exclude" pn="section-3.1.3.3.4">
              <name slugifiedName="name-practical-implications">Practical Implications</name>
              <t indent="0" pn="section-3.1.3.3.4-1">Due to these flexibility provisions, servers may return batches of varying sizes. For instance, when returning 3 batches of a requested size of 1,000, one might contain 990 messages, another 977, and the third 1,000 messages. Clients <bcp14>MUST</bcp14> be prepared to handle such variations.</t>
              <t indent="0" pn="section-3.1.3.3.4-2">When the total number of messages is not evenly divisible by the requested batch size, the final batch will contain the remainder. Therefore, the last batch in the mailbox (containing the lowest UIDs) will typically have fewer messages than requested.</t>
            </section>
          </section>
          <section anchor="batch-size-rationale" numbered="true" removeInRFC="false" toc="exclude" pn="section-3.1.3.4">
            <name slugifiedName="name-design-rationale">Design Rationale</name>
            <t indent="0" pn="section-3.1.3.4-1">These restrictions provide servers with implementation flexibility while preventing clients from misusing the extension to effectively reconstruct sequence numbers. <xref target="similarity-to-uid-search" format="default" sectionFormat="of" derivedContent="Appendix A.1"/> also outlines some reasoning for these limitations.</t>
            <t indent="0" pn="section-3.1.3.4-2">The flexibility regarding batch sizes is designed to enable efficient server implementations while maintaining predictable behavior for clients. This leeway is not intended as a general permission to return arbitrarily sized batches but rather to accommodate implementation constraints and dynamic mailbox changes.</t>
          </section>
        </section>
        <section anchor="uids" numbered="true" removeInRFC="false" toc="include" pn="section-3.1.4">
          <name slugifiedName="name-uids">UIDs</name>
          <t indent="0" pn="section-3.1.4-1">The server <bcp14>MAY</bcp14> return UID ranges with UIDs that do not exist on the server. As a result, the client <bcp14>MUST NOT</bcp14> make assumptions about the existence of messages. If the server returns the response:</t>
          <sourcecode markers="false" pn="section-3.1.4-2">
========== NOTE: '\' line wrapping per RFC 8792 ===========

S: * UIDBATCHES (TAG "A302") \
       163886:99703,99696:20358,20351:7841,7830:1
S: A302 OK UIDBATCHES Completed</sourcecode>
          <t indent="0" pn="section-3.1.4-3">there may not be any messages on the server with the UIDs such as 163886, 99703, 99696, etc.</t>
          <t indent="0" pn="section-3.1.4-4">The range <tt>163886:99703</tt> will span approximately the requested number of messages (may be less, see <xref target="batch-sizes" format="default" sectionFormat="of" derivedContent="Section 3.1.3"/>), but its start and end UIDs may not correspond to messages on the server.</t>
          <t indent="0" pn="section-3.1.4-5">This gives the server implementation some flexibility as to which UID ranges to return. They might, e.g., return <tt>163886:99697</tt> and <tt>99696:20358</tt> instead of <tt>163886:99703</tt> and <tt>99696:20358</tt> -- assuming that there are no messages in the range <tt>99702:99697</tt>.</t>
          <t indent="0" pn="section-3.1.4-6">If there are fewer messages in the mailbox than the requested batch size, the server would return a single batch that contains all messages in the mailbox.</t>
          <t indent="0" pn="section-3.1.4-7">When applying the flexibility described above to the last batch in the mailbox, ending that batch with UID 1 makes it unambiguous to the client that this range is in fact the last range. For example, if the message with the lowest UID is 302, the server can return <tt>7829:1</tt> instead of <tt>7829:302</tt>.</t>
        </section>
        <section anchor="batch-ranges" numbered="true" removeInRFC="false" toc="include" pn="section-3.1.5">
          <name slugifiedName="name-batch-ranges">Batch Ranges</name>
          <t indent="0" pn="section-3.1.5-1">A client can optionally provide a batch range. The server limits its response to UID ranges corresponding to the specified batch indices. For example, if the client sends:</t>
          <sourcecode markers="false" pn="section-3.1.5-2">
C: A302 UIDBATCHES 2000 10:20</sourcecode>
          <t indent="0" pn="section-3.1.5-3">for a mailbox with 100,000 messages, the server would return the 10th to 20th batches. The 10th batch would correspond to message sequence numbers `82000:80001` and the 20th batch would correspond to message sequence numbers `62000:60001`.</t>
          <t indent="0" pn="section-3.1.5-4">Batches start at the highest UIDs, i.e., batch 1 is the batch with the highest UIDs.</t>
          <t indent="0" pn="section-3.1.5-5">The UID ranges that the server returns would still split the mailbox's messages into batches of the requested size (2,000 in the example).</t>
          <t indent="0" pn="section-3.1.5-6">If the client requests more batches than exist on the server, the server would return those that do exist. For example, if the client sends:</t>
          <sourcecode markers="false" pn="section-3.1.5-7">
C: A302 UIDBATCHES 2000 1:5</sourcecode>
          <t indent="0" pn="section-3.1.5-8">and the selected mailbox has 7,000 messages, the server would then return a <tt>UIDBATCHES</tt> response with only 4 UID ranges.</t>
          <t indent="0" pn="section-3.1.5-9">Batch ranges such as <tt>1:4</tt> in the above example <bcp14>MUST</bcp14> be ordered lowest to highest, i.e., be sent as <tt>1:4</tt> and not as <tt>4:1</tt>. Servers <bcp14>MUST</bcp14> reject batch ranges that are in the wrong order with <tt>BAD</tt> and a response code <tt>CLIENTBUG</tt>:</t>
          <sourcecode markers="false" pn="section-3.1.5-10">
C: A302 UIDBATCHES 2000 4:1
S: A302 BAD [CLIENTBUG] Invalid batch range</sourcecode>
          <t indent="0" pn="section-3.1.5-11">If the client requests a range of batches that do not exist on the server, the server <bcp14>MUST</bcp14> still return an empty response. See <xref target="empty-responses" format="default" sectionFormat="of" derivedContent="Section 3.1.6"/>.</t>
          <t indent="0" pn="section-3.1.5-12">The number of messages per batch returned by the server may be approximate, as detailed in <xref target="batch-sizes" format="default" sectionFormat="of" derivedContent="Section 3.1.3"/>. As a result, if the client needs to request consecutive batch ranges such as 1:100, 101:200, 201:300, and so on, the client may want to make these batch ranges overlap by, e.g., requesting 1:100, 100:200, and 200:300. While the UIDs returned may not correspond to existing messages (as described in <xref target="uids" format="default" sectionFormat="of" derivedContent="Section 3.1.4"/>) and mailbox state can change between requests, checking whether the returned UID ranges overlap can help clients detect potential inconsistencies, though how to handle such situations depends on the specific client implementation requirements.</t>
          <t indent="0" pn="section-3.1.5-13">Clients <bcp14>MUST NOT</bcp14> request batch ranges that span more than 100,000 messages, i.e., the number of batches multiplied by the batch size <bcp14>MUST NOT</bcp14> be larger than 100,000. This restriction applies only when a batch range is specified; when no batch range is provided, the client is requesting all batches but the server may limit its response as described in <xref target="large-mailboxes" format="default" sectionFormat="of" derivedContent="Section 3.1.7"/>. The server <bcp14>MAY</bcp14> reject <tt>UIDBATCHES</tt> commands with a <tt>NO</tt> response with the <tt>TOOMANY</tt> response code if the client exceeds this limit.</t>
          <sourcecode markers="false" pn="section-3.1.5-14">
C: A302 UIDBATCHES 2000 1:100
S: A302 NO [TOOMANY] Too many messages</sourcecode>
        </section>
        <section anchor="empty-responses" numbered="true" removeInRFC="false" toc="include" pn="section-3.1.6">
          <name slugifiedName="name-empty-responses">Empty Responses</name>
          <t indent="0" pn="section-3.1.6-1">When the client issues any valid <tt>UIDBATCHES</tt> command and the mailbox is empty, the server <bcp14>MUST</bcp14> reply with a <tt>UIDBATCHES</tt> response, for example:</t>
          <sourcecode markers="false" pn="section-3.1.6-2">
S: * UIDBATCHES (TAG "A302")
S: A302 OK UIDBATCHES Completed</sourcecode>
          <t indent="0" pn="section-3.1.6-3">If the client requests a range of batches that do not exist, the server <bcp14>MUST</bcp14> reply with an empty <tt>UIDBATCHES</tt> response. If the mailbox has 7,000 messages, and the client sends:</t>
          <sourcecode markers="false" pn="section-3.1.6-4">
C: A302 UIDBATCHES 2000 6:8</sourcecode>
          <t indent="0" pn="section-3.1.6-5">the server would respond with:</t>
          <sourcecode markers="false" pn="section-3.1.6-6">
S: * UIDBATCHES (TAG "A302")
S: A302 OK UIDBATCHES Completed</sourcecode>
        </section>
        <section anchor="large-mailboxes" numbered="true" removeInRFC="false" toc="include" pn="section-3.1.7">
          <name slugifiedName="name-large-mailboxes">Large Mailboxes</name>
          <t indent="0" pn="section-3.1.7-1">The server may not be able to return all UID ranges if the mailbox contains an extremely large number of messages.</t>
          <t indent="0" pn="section-3.1.7-2">The server <bcp14>MUST</bcp14> at least support returning UID ranges spanning 100,000 messages. See <xref target="batch-ranges" format="default" sectionFormat="of" derivedContent="Section 3.1.5"/> for details on this limit.</t>
          <t indent="0" pn="section-3.1.7-3">If the server cannot return all of the requested UID ranges, it <bcp14>MUST</bcp14> respond with a <tt>NO</tt> response with the <tt>TOOMANY</tt> response code. Notably, when the client requests all UID ranges and the mailbox has more than 100,000 messages, the server <bcp14>MAY</bcp14> reply with a <tt>NO</tt> response. For example:</t>
          <sourcecode markers="false" pn="section-3.1.7-4">
C: A302 UIDBATCHES 2000
S: A302 NO [TOOMANY] Too many messages in mailbox</sourcecode>
          <t indent="0" pn="section-3.1.7-5">The client should know what the message count in the mailbox is, and if the message count exceeds 100,000, it may choose to always request batch ranges as discussed in <xref target="batch-ranges" format="default" sectionFormat="of" derivedContent="Section 3.1.5"/> instead of requesting all batches.</t>
        </section>
      </section>
      <section anchor="message-limit" numbered="true" removeInRFC="false" toc="include" pn="section-3.2">
        <name slugifiedName="name-interaction-with-messagelim">Interaction with MESSAGELIMIT Extension</name>
        <t indent="0" pn="section-3.2-1">When the server supports both the MESSAGELIMIT <xref target="RFC9738" format="default" sectionFormat="of" derivedContent="RFC9738"/> and <tt>UIDBATCHES</tt> extension, the client <bcp14>SHOULD</bcp14> request batches no larger than the specified maximum number of messages that can be processed in a single command. The client <bcp14>MAY</bcp14> choose to use a smaller batch size.</t>
        <t indent="0" pn="section-3.2-2">Additionally, since servers <bcp14>MAY</bcp14> limit the number of UIDs returned in response to <tt>UIDBATCHES</tt>, it is reasonable to assume that they would at most return N UIDs, where N is the limit the server announced as its MESSAGELIMIT.</t>
      </section>
      <section anchor="interaction-uidonly" numbered="true" removeInRFC="false" toc="include" pn="section-3.3">
        <name slugifiedName="name-interaction-with-uidonly-ex">Interaction with UIDONLY Extension</name>
        <t indent="0" pn="section-3.3-1">The <tt>UIDBATCHES</tt> extension allows clients to create UID ranges for message batches even when the connection operates in UIDONLY mode, which otherwise doesn't allow for using message sequence numbers.</t>
        <t indent="0" pn="section-3.3-2">This interaction is particularly important because the UIDONLY extension disallows the use of sequence numbers. While the PARTIAL extension <xref target="RFC9394" format="default" sectionFormat="of" derivedContent="RFC9394"/> provides paged SEARCH and FETCH operations, some clients need to predetermine UID ranges for batches upfront. <tt>UIDBATCHES</tt> enables such clients to use the same overall batching strategy, regardless of whether the server supports UIDONLY, PARTIAL, or neither, making client implementations simpler and more consistent.</t>
        <t indent="0" pn="section-3.3-3">When operating in UIDONLY mode, clients <bcp14>SHOULD</bcp14> use <tt>UIDBATCHES</tt> to determine appropriate UID ranges for batch operations rather than attempting to construct batches using sequence-number-based approaches that would violate UIDONLY restrictions.</t>
        <t indent="0" pn="section-3.3-4">The batch size constraints defined in <xref target="batch-sizes" format="default" sectionFormat="of" derivedContent="Section 3.1.3"/> serve dual purposes: ensuring server efficiency and preventing <tt>UIDBATCHES</tt> from becoming a mechanism to effectively reconstruct sequence numbers. Without these constraints, clients could request very small batch sizes to obtain fine-grained positional information about messages, which would circumvent the sequence number restrictions of UIDONLY mode. The extension is designed specifically to support the legitimate need of predetermining message batches upfront while maintaining the architectural intent of UIDONLY mode.</t>
      </section>
      <section anchor="interaction-searchres" numbered="true" removeInRFC="false" toc="include" pn="section-3.4">
        <name slugifiedName="name-interaction-with-searchres-">Interaction with SEARCHRES Extension</name>
        <t indent="0" pn="section-3.4-1"><tt>UIDBATCHES</tt> is not a SEARCH nor UID SEARCH command. Servers that support SEARCHRES <xref target="RFC5182" format="default" sectionFormat="of" derivedContent="RFC5182"/> <bcp14>MUST NOT</bcp14> store the result of <tt>UIDBATCHES</tt> in the <tt>$</tt> variable.</t>
      </section>
    </section>
    <section anchor="formal-syntax" numbered="true" removeInRFC="false" toc="include" pn="section-4">
      <name slugifiedName="name-formal-syntax">Formal Syntax</name>
      <t indent="0" pn="section-4-1">The following syntax specification uses the Augmented Backus-Naur Form (ABNF) notation as specified in <xref target="RFC5234" format="default" sectionFormat="of" derivedContent="RFC5234"/>.</t>
      <t indent="0" pn="section-4-2">Non-terminals referenced but not defined below are as defined by
        IMAP4 <xref target="RFC9051" format="default" sectionFormat="of" derivedContent="RFC9051"/>.</t>
      <t indent="0" pn="section-4-3">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 <bcp14>MUST</bcp14> accept these strings in a case-insensitive fashion.</t>
      <sourcecode type="abnf" markers="false" pn="section-4-4">
capability          =/ "UIDBATCHES"
                       ;; &lt;capability&gt; from [RFC9051]

command-select      =/ message-batches

message-batches     = "UIDBATCHES" SP nz-number
                      [SP nz-number ":" nz-number]

uidbatches-response = "UIDBATCHES" search-correlator
                      [SP uid-range *("," uid-range) ]

mailbox-data        =/ uidbatches-response

resp-text-code      =/ "TOOFEW" / "TOOMANY"</sourcecode>
    </section>
    <section anchor="operational-considerations" numbered="true" removeInRFC="false" toc="include" pn="section-5">
      <name slugifiedName="name-operational-considerations">Operational Considerations</name>
      <t indent="0" pn="section-5-1">This document defines an optimization that can reduce both the amount of work performed by the server and the amount of data returned to the client.  Use of this extension is likely to cause the server and the client to use less memory than when the extension is not used.  However, as this is going to be new code in both the client and the server, rigorous testing of such code is required in order to avoid the introduction of new implementation bugs.</t>
    </section>
    <section anchor="security-considerations" numbered="true" removeInRFC="false" toc="include" pn="section-6">
      <name slugifiedName="name-security-considerations">Security Considerations</name>
      <t indent="0" pn="section-6-1">This document defines an additional IMAP4 capability.  As such, it does not change the underlying security considerations of IMAP4rev1 <xref target="RFC3501" format="default" sectionFormat="of" derivedContent="RFC3501"/> and IMAP4rev2 <xref target="RFC9051" format="default" sectionFormat="of" derivedContent="RFC9051"/>. The author and reviewers believe that no new security issues are introduced with this additional IMAP4 capability.</t>
      <t indent="0" pn="section-6-2">One consideration during the design of this extension was the potential for clients to cause servers to perform excessive computational work by repeatedly requesting batch calculations. The restrictions on when clients may re-run <tt>UIDBATCHES</tt> (<xref target="command" format="default" sectionFormat="of" derivedContent="Section 3.1"/>) and the batch size constraints (<xref target="batch-sizes" format="default" sectionFormat="of" derivedContent="Section 3.1.3"/>) are designed to mitigate this concern. Server implementations are strongly advised to implement enforcement of these rate-limiting restrictions rather than relying solely on client compliance. Servers <bcp14>SHOULD</bcp14> track <tt>UIDBATCHES</tt> requests per mailbox and reject requests that violate the conditions in <xref target="command" format="default" sectionFormat="of" derivedContent="Section 3.1"/>, as failure to do so may allow malicious or buggy clients to cause resource exhaustion through repeated batch calculations. Servers may reject requests that exceed these limits with the <tt>LIMIT</tt>, <tt>TOOFEW</tt>, or <tt>TOOMANY</tt> response codes.</t>
      <t indent="0" pn="section-6-3">As this extension involves new code in both clients and servers, rigorous testing of such code is required in order to avoid introducing new implementation bugs.</t>
    </section>
    <section anchor="iana-considerations" numbered="true" removeInRFC="false" toc="include" pn="section-7">
      <name slugifiedName="name-iana-considerations">IANA Considerations</name>
      <t indent="0" pn="section-7-1">IANA has added the <tt>UIDBATCHES</tt> capability to the <eref target="https://www.iana.org/assignments/imap4-capabilities" brackets="none">"Internet Message Access Protocol (IMAP) Capabilities Registry"</eref>, with a reference to this document.</t>
      <t indent="0" pn="section-7-2">IANA has added <tt>TOOMANY</tt> and <tt>TOOFEW</tt> to the <eref target="https://www.iana.org/assignments/imap-response-codes" brackets="none">"IMAP Response Codes" registry</eref>, with a reference to this document.</t>
    </section>
  </middle>
  <back>
    <references pn="section-8">
      <name slugifiedName="name-references">References</name>
      <references pn="section-8.1">
        <name slugifiedName="name-normative-references">Normative References</name>
        <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119" quoteTitle="true" derivedAnchor="RFC2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author fullname="S. Bradner" initials="S." surname="Bradner"/>
            <date month="March" year="1997"/>
            <abstract>
              <t indent="0">In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>
        <reference anchor="RFC3501" target="https://www.rfc-editor.org/info/rfc3501" quoteTitle="true" derivedAnchor="RFC3501">
          <front>
            <title>INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1</title>
            <author fullname="M. Crispin" initials="M." surname="Crispin"/>
            <date month="March" year="2003"/>
            <abstract>
              <t indent="0">The Internet Message Access Protocol, Version 4rev1 (IMAP4rev1) allows a client to access and manipulate electronic mail messages on a server. IMAP4rev1 permits manipulation of mailboxes (remote message folders) in a way that is functionally equivalent to local folders. IMAP4rev1 also provides the capability for an offline client to resynchronize with the server. IMAP4rev1 includes operations for creating, deleting, and renaming mailboxes, checking for new messages, permanently removing messages, setting and clearing flags, RFC 2822 and RFC 2045 parsing, searching, and selective fetching of message attributes, texts, and portions thereof. Messages in IMAP4rev1 are accessed by the use of numbers. These numbers are either message sequence numbers or unique identifiers. IMAP4rev1 supports a single server. A mechanism for accessing configuration information to support multiple IMAP4rev1 servers is discussed in RFC 2244. IMAP4rev1 does not specify a means of posting mail; this function is handled by a mail transfer protocol such as RFC 2821. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="3501"/>
          <seriesInfo name="DOI" value="10.17487/RFC3501"/>
        </reference>
        <reference anchor="RFC5234" target="https://www.rfc-editor.org/info/rfc5234" quoteTitle="true" derivedAnchor="RFC5234">
          <front>
            <title>Augmented BNF for Syntax Specifications: ABNF</title>
            <author fullname="D. Crocker" initials="D." role="editor" surname="Crocker"/>
            <author fullname="P. Overell" initials="P." surname="Overell"/>
            <date month="January" year="2008"/>
            <abstract>
              <t indent="0">Internet technical specifications often need to define a formal syntax. Over the years, a modified version of Backus-Naur Form (BNF), called Augmented BNF (ABNF), has been popular among many Internet specifications. The current specification documents ABNF. It balances compactness and simplicity with reasonable representational power. The differences between standard BNF and ABNF involve naming rules, repetition, alternatives, order-independence, and value ranges. This specification also supplies additional rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="STD" value="68"/>
          <seriesInfo name="RFC" value="5234"/>
          <seriesInfo name="DOI" value="10.17487/RFC5234"/>
        </reference>
        <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174" quoteTitle="true" derivedAnchor="RFC8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author fullname="B. Leiba" initials="B." surname="Leiba"/>
            <date month="May" year="2017"/>
            <abstract>
              <t indent="0">RFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
        <reference anchor="RFC9051" target="https://www.rfc-editor.org/info/rfc9051" quoteTitle="true" derivedAnchor="RFC9051">
          <front>
            <title>Internet Message Access Protocol (IMAP) - Version 4rev2</title>
            <author fullname="A. Melnikov" initials="A." role="editor" surname="Melnikov"/>
            <author fullname="B. Leiba" initials="B." role="editor" surname="Leiba"/>
            <date month="August" year="2021"/>
            <abstract>
              <t indent="0">The Internet Message Access Protocol Version 4rev2 (IMAP4rev2) allows a client to access and manipulate electronic mail messages on a server. IMAP4rev2 permits manipulation of mailboxes (remote message folders) in a way that is functionally equivalent to local folders. IMAP4rev2 also provides the capability for an offline client to resynchronize with the server.</t>
              <t indent="0">IMAP4rev2 includes operations for creating, deleting, and renaming mailboxes; checking for new messages; removing messages permanently; setting and clearing flags; parsing per RFCs 5322, 2045, and 2231; searching; and selective fetching of message attributes, texts, and portions thereof. Messages in IMAP4rev2 are accessed by the use of numbers. These numbers are either message sequence numbers or unique identifiers.</t>
              <t indent="0">IMAP4rev2 does not specify a means of posting mail; this function is handled by a mail submission protocol such as the one specified in RFC 6409.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="9051"/>
          <seriesInfo name="DOI" value="10.17487/RFC9051"/>
        </reference>
        <reference anchor="RFC9738" target="https://www.rfc-editor.org/info/rfc9738" quoteTitle="true" derivedAnchor="RFC9738">
          <front>
            <title>IMAP MESSAGELIMIT Extension</title>
            <author fullname="A. Melnikov" initials="A." surname="Melnikov"/>
            <author fullname="A. P. Achuthan" initials="A. P." surname="Achuthan"/>
            <author fullname="V. Nagulakonda" initials="V." surname="Nagulakonda"/>
            <author fullname="L. Alves" initials="L." surname="Alves"/>
            <date month="March" year="2025"/>
            <abstract>
              <t indent="0">The MESSAGELIMIT extension of the Internet Message Access Protocol (RFCs 3501 and 9051) allows servers to announce a limit on the number of messages that can be processed in a single FETCH, SEARCH, STORE, COPY, or MOVE command (or their UID variants), or in a single APPEND or UID EXPUNGE command. This helps servers to control resource usage when performing various IMAP operations. This helps clients to know the message limit enforced by the corresponding IMAP server and avoid issuing commands that would exceed such limit.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="9738"/>
          <seriesInfo name="DOI" value="10.17487/RFC9738"/>
        </reference>
      </references>
      <references pn="section-8.2">
        <name slugifiedName="name-informative-references">Informative References</name>
        <reference anchor="RFC4731" target="https://www.rfc-editor.org/info/rfc4731" quoteTitle="true" derivedAnchor="RFC4731">
          <front>
            <title>IMAP4 Extension to SEARCH Command for Controlling What Kind of Information Is Returned</title>
            <author fullname="A. Melnikov" initials="A." surname="Melnikov"/>
            <author fullname="D. Cridland" initials="D." surname="Cridland"/>
            <date month="November" year="2006"/>
            <abstract>
              <t indent="0">This document extends IMAP (RFC 3501) SEARCH and UID SEARCH commands with several result options, which can control what kind of information is returned. The following result options are defined: minimal value, maximal value, all found messages, and number of found messages. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="4731"/>
          <seriesInfo name="DOI" value="10.17487/RFC4731"/>
        </reference>
        <reference anchor="RFC5182" target="https://www.rfc-editor.org/info/rfc5182" quoteTitle="true" derivedAnchor="RFC5182">
          <front>
            <title>IMAP Extension for Referencing the Last SEARCH Result</title>
            <author fullname="A. Melnikov" initials="A." surname="Melnikov"/>
            <date month="March" year="2008"/>
            <abstract>
              <t indent="0">Many IMAP clients use the result of a SEARCH command as the input to perform another operation, for example, fetching the found messages, deleting them, or copying them to another mailbox.</t>
              <t indent="0">This can be achieved using standard IMAP operations described in RFC 3501; however, this would be suboptimal. The server will send the list of found messages to the client; after that, the client will have to parse the list, reformat it, and send it back to the server. The client can't pipeline the SEARCH command with the subsequent command, and, as a result, the server might not be able to perform some optimizations.</t>
              <t indent="0">This document proposes an IMAP extension that allows a client to tell a server to use the result of a SEARCH (or Unique Identifier (UID) SEARCH) command as an input to any subsequent command. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="5182"/>
          <seriesInfo name="DOI" value="10.17487/RFC5182"/>
        </reference>
        <reference anchor="RFC8792" target="https://www.rfc-editor.org/info/rfc8792" quoteTitle="true" derivedAnchor="RFC8792">
          <front>
            <title>Handling Long Lines in Content of Internet-Drafts and RFCs</title>
            <author fullname="K. Watsen" initials="K." surname="Watsen"/>
            <author fullname="E. Auerswald" initials="E." surname="Auerswald"/>
            <author fullname="A. Farrel" initials="A." surname="Farrel"/>
            <author fullname="Q. Wu" initials="Q." surname="Wu"/>
            <date month="June" year="2020"/>
            <abstract>
              <t indent="0">This document defines two strategies for handling long lines in width-bounded text content. One strategy, called the "single backslash" strategy, is based on the historical use of a single backslash ('\') character to indicate where line-folding has occurred, with the continuation occurring with the first character that is not a space character (' ') on the next line. The second strategy, called the "double backslash" strategy, extends the first strategy by adding a second backslash character to identify where the continuation begins and is thereby able to handle cases not supported by the first strategy. Both strategies use a self-describing header enabling automated reconstitution of the original content.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8792"/>
          <seriesInfo name="DOI" value="10.17487/RFC8792"/>
        </reference>
        <reference anchor="RFC9394" target="https://www.rfc-editor.org/info/rfc9394" quoteTitle="true" derivedAnchor="RFC9394">
          <front>
            <title>IMAP PARTIAL Extension for Paged SEARCH and FETCH</title>
            <author fullname="A. Melnikov" initials="A." surname="Melnikov"/>
            <author fullname="A. P. Achuthan" initials="A. P." surname="Achuthan"/>
            <author fullname="V. Nagulakonda" initials="V." surname="Nagulakonda"/>
            <author fullname="L. Alves" initials="L." surname="Alves"/>
            <date month="June" year="2023"/>
            <abstract>
              <t indent="0">The PARTIAL extension of the Internet Message Access Protocol (see RFCs 3501 and 9051) allows clients to limit the number of SEARCH results returned, as well as to perform incremental (paged) searches. This also helps servers to optimize resource usage when performing searches.</t>
              <t indent="0">This document extends the PARTIAL SEARCH return option originally specified in RFC 5267. It also clarifies some interactions between RFC 5267 and RFCs 4731 and 9051.</t>
              <t indent="0">This document updates RFCs 4731 and 5267.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="9394"/>
          <seriesInfo name="DOI" value="10.17487/RFC9394"/>
        </reference>
        <reference anchor="RFC9586" target="https://www.rfc-editor.org/info/rfc9586" quoteTitle="true" derivedAnchor="RFC9586">
          <front>
            <title>IMAP Extension for Using and Returning Unique Identifiers (UIDs) Only</title>
            <author fullname="A. Melnikov" initials="A." surname="Melnikov"/>
            <author fullname="A. P. Achuthan" initials="A. P." surname="Achuthan"/>
            <author fullname="V. Nagulakonda" initials="V." surname="Nagulakonda"/>
            <author fullname="A. Singh" initials="A." surname="Singh"/>
            <author fullname="L. Alves" initials="L." surname="Alves"/>
            <date month="May" year="2024"/>
            <abstract>
              <t indent="0">The UIDONLY extension to the Internet Message Access Protocol (RFCs 3501 and 9051) allows clients to enable a mode in which information about mailbox changes is returned using only Unique Identifiers (UIDs). Message numbers are not returned in responses and cannot be used in requests once this extension is enabled. This helps both clients and servers to reduce resource usage required to maintain a map between message numbers and UIDs.</t>
              <t indent="0">This document defines an experimental IMAP extension.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="9586"/>
          <seriesInfo name="DOI" value="10.17487/RFC9586"/>
        </reference>
      </references>
    </references>
    <section anchor="design-comparison" numbered="true" toc="include" removeInRFC="false" pn="section-appendix.a">
      <name slugifiedName="name-comparison-with-existing-co">Comparison with Existing Commands and Extensions</name>
      <section anchor="similarity-to-uid-search" numbered="true" removeInRFC="false" toc="include" pn="section-appendix.a.1">
        <name slugifiedName="name-similarity-to-uid-search-co">Similarity to UID SEARCH Command</name>
        <t indent="0" pn="section-appendix.a.1-1"><tt>UIDBATCHES</tt> is in effect nothing more than shorthand for a UID SEARCH command of the form</t>
        <sourcecode markers="false" pn="section-appendix.a.1-2">
C: A145 UID SEARCH RETURN () &lt;M&gt;,&lt;M-N&gt;,&lt;M-2*N&gt;,&lt;M-3*N&gt;,...</sourcecode>
        <t indent="0" pn="section-appendix.a.1-3">where M is the number of messages in the mailbox and N is the
        requested batch count.</t>
        <t indent="0" pn="section-appendix.a.1-4">However, the special purpose <tt>UIDBATCHES</tt> command tries to
        address two problems:</t>
        <ol type="1" indent="adaptive" spacing="normal" start="1" pn="section-appendix.a.1-5">
          <li pn="section-appendix.a.1-5.1" derivedCounter="1.">For many servers, UID SEARCH commands specifying sequence numbers are costly, especially for mailboxes with many messages.</li>
          <li pn="section-appendix.a.1-5.2" derivedCounter="2.">The UIDONLY extension disallows the use of sequence numbers and thus makes it difficult for the client to split its commands into batches of a size that works well for the client and server.</li>
        </ol>
        <t indent="0" pn="section-appendix.a.1-6">By providing a special purpose command, servers can implement a different, optimized code path for determining message batches. And servers using the UIDONLY extension can provide a facility to let the client determine message batches without using sequence numbers in a UID SEARCH command.</t>
        <t indent="0" pn="section-appendix.a.1-7"><xref target="batch-sizes" format="default" sectionFormat="of" derivedContent="Section 3.1.3"/> describes some implementation restrictions to ensure this.</t>
      </section>
      <section anchor="partial-comparison" numbered="true" removeInRFC="false" toc="include" pn="section-appendix.a.2">
        <name slugifiedName="name-similarity-to-partial-exten">Similarity to PARTIAL Extension</name>
        <t indent="0" pn="section-appendix.a.2-1">The PARTIAL extension in <xref target="RFC9394" format="default" sectionFormat="of" derivedContent="RFC9394"/> provides a different way for the client to split its commands into batches by using paged SEARCH and FETCH.</t>
        <t indent="0" pn="section-appendix.a.2-2">The intention of the <tt>UIDBATCHES</tt> command is to let the client predetermine message batches of a desired size.</t>
        <t indent="0" pn="section-appendix.a.2-3">This makes it easier for the client to share implementation between servers, regardless of their support of PARTIAL. And additionally, because the client can issue a corresponding UID SEARCH command to servers that do not implement <tt>UIDBATCHES</tt>, the client can use similar batching implementations for servers that support <tt>UIDBATCHES</tt> and those that do not.</t>
      </section>
    </section>
    <section anchor="authors-addresses" numbered="false" removeInRFC="false" toc="include" pn="section-appendix.b">
      <name slugifiedName="name-authors-address">Author's Address</name>
      <author fullname="Daniel Eggert" initials="D." role="editor" surname="Eggert">
        <organization showOnFrontPage="true">Apple Inc</organization>
        <address>
          <postal>
            <street>One Apple Park Way</street>
            <city>Cupertino</city>
            <region>CA</region>
            <code>95014</code>
            <country>United States of America</country>
          </postal>
          <email>deggert@apple.com</email>
        </address>
      </author>
    </section>
  </back>
</rfc>
