@@ -45,10 +45,16 @@ module Net
4545 # To work on the messages within a mailbox, the client must
4646 # first select that mailbox, using either #select or #examine
4747 # (for read-only access). Once the client has successfully
48- # selected a mailbox, they enter the "_selected_" state, and that
48+ # selected a mailbox, they enter the +selected+ state, and that
4949 # mailbox becomes the _current_ mailbox, on which mail-item
5050 # related commands implicitly operate.
5151 #
52+ # === Connection state
53+ #
54+ # Once an IMAP connection is established, the connection is in one of four
55+ # states: <tt>not authenticated</tt>, +authenticated+, +selected+, and
56+ # +logout+. Most commands are valid only in certain states.
57+ #
5258 # === Sequence numbers and UIDs
5359 #
5460 # Messages have two sorts of identifiers: message sequence
@@ -126,6 +132,35 @@ module Net
126132 #
127133 # This script invokes the FETCH command and the SEARCH command concurrently.
128134 #
135+ # When running multiple commands, care must be taken to avoid ambiguity. For
136+ # example, SEARCH responses are ambiguous about which command they are
137+ # responding to, so search commands should not run simultaneously, unless the
138+ # server supports +ESEARCH+ {[RFC4731]}[https://rfc-editor.org/rfc/rfc4731] or
139+ # IMAP4rev2[https://www.rfc-editor.org/rfc/rfc9051]. See {RFC9051
140+ # §5.5}[https://www.rfc-editor.org/rfc/rfc9051.html#section-5.5] for
141+ # other examples of command sequences which should not be pipelined.
142+ #
143+ # == Unbounded memory use
144+ #
145+ # Net::IMAP reads server responses in a separate receiver thread per client.
146+ # Unhandled response data is saved to #responses, and response_handlers run
147+ # inside the receiver thread. See the list of methods for {handling server
148+ # responses}[rdoc-ref:Net::IMAP@Handling+server+responses], below.
149+ #
150+ # Because the receiver thread continuously reads and saves new responses, some
151+ # scenarios must be careful to avoid unbounded memory use:
152+ #
153+ # * Commands such as #list or #fetch can have an enormous number of responses.
154+ # * Commands such as #fetch can result in an enormous size per response.
155+ # * Long-lived connections will gradually accumulate unsolicited server
156+ # responses, especially +EXISTS+, +FETCH+, and +EXPUNGE+ responses.
157+ # * A buggy or untrusted server could send inappropriate responses, which
158+ # could be very numerous, very large, and very rapid.
159+ #
160+ # Use paginated or limited versions of commands whenever possible.
161+ #
162+ # Use #add_response_handler to handle responses after each one is received.
163+ #
129164 # == Errors
130165 #
131166 # An \IMAP server can send three different types of responses to indicate
@@ -187,7 +222,7 @@ module Net
187222 # - Net::IMAP.new: A new client connects immediately and waits for a
188223 # successful server greeting before returning the new client object.
189224 # - #starttls: Asks the server to upgrade a clear-text connection to use TLS.
190- # - #logout: Tells the server to end the session. Enters the "_logout_" state.
225+ # - #logout: Tells the server to end the session. Enters the +logout+ state.
191226 # - #disconnect: Disconnects the connection (without sending #logout first).
192227 # - #disconnected?: True if the connection has been closed.
193228 #
@@ -230,40 +265,39 @@ module Net
230265 # <em>Capabilities may change after</em> #starttls, #authenticate, or #login
231266 # <em>and cached capabilities must be reloaded.</em>
232267 # - #noop: Allows the server to send unsolicited untagged #responses.
233- # - #logout: Tells the server to end the session. Enters the "_logout_" state.
268+ # - #logout: Tells the server to end the session. Enters the +logout+ state.
234269 #
235270 # ==== \IMAP commands for the "Not Authenticated" state
236271 #
237- # In addition to the universal commands, the following commands are valid in
238- # the "<em>not authenticated</em>" state:
272+ # In addition to the commands for any state , the following commands are valid
273+ # in the +not_authenticated+ state:
239274 #
240275 # - #starttls: Upgrades a clear-text connection to use TLS.
241276 #
242277 # <em>Requires the +STARTTLS+ capability.</em>
243- # - #authenticate: Identifies the client to the server using a {SASL
244- # mechanism}[https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml].
245- # Enters the "_authenticated_" state.
278+ # - #authenticate: Identifies the client to the server using the given {SASL
279+ # mechanism}[https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml]
280+ # and credentials. Enters the +authenticated+ state.
246281 #
247282 # <em>Requires the <tt>AUTH=#{mechanism}</tt> capability for the chosen
248283 # mechanism.</em>
249284 # - #login: Identifies the client to the server using a plain text password.
250- # Using #authenticate is generally preferred. Enters the "_authenticated_"
251- # state.
285+ # Using #authenticate is preferred. Enters the +authenticated+ state.
252286 #
253287 # <em>The +LOGINDISABLED+ capability</em> <b>must NOT</b> <em>be listed.</em>
254288 #
255289 # ==== \IMAP commands for the "Authenticated" state
256290 #
257- # In addition to the universal commands, the following commands are valid in
258- # the "_authenticated_" state:
291+ # In addition to the commands for any state , the following commands are valid
292+ # in the +authenticated+ state:
259293 #
260294 #--
261295 # - #enable: <em>Not implemented by Net::IMAP, yet.</em>
262296 #
263297 # <em>Requires the +ENABLE+ capability.</em>
264298 #++
265- # - #select: Open a mailbox and enter the "_selected_" state.
266- # - #examine: Open a mailbox read-only, and enter the "_selected_" state.
299+ # - #select: Open a mailbox and enter the +selected+ state.
300+ # - #examine: Open a mailbox read-only, and enter the +selected+ state.
267301 # - #create: Creates a new mailbox.
268302 # - #delete: Permanently remove a mailbox.
269303 # - #rename: Change the name of a mailbox.
@@ -289,12 +323,12 @@ module Net
289323 #
290324 # ==== \IMAP commands for the "Selected" state
291325 #
292- # In addition to the universal commands and the "authenticated" commands, the
293- # following commands are valid in the "_selected_" state:
326+ # In addition to the commands for any state and the +authenticated+
327+ # commands, the following commands are valid in the +selected+ state:
294328 #
295- # - #close: Closes the mailbox and returns to the "_authenticated_" state,
329+ # - #close: Closes the mailbox and returns to the +authenticated+ state,
296330 # expunging deleted messages, unless the mailbox was opened as read-only.
297- # - #unselect: Closes the mailbox and returns to the "_authenticated_" state,
331+ # - #unselect: Closes the mailbox and returns to the +authenticated+ state,
298332 # without expunging any messages.
299333 #
300334 # <em>Requires the +UNSELECT+ capability.</em>
@@ -384,7 +418,7 @@ module Net
384418 # ==== RFC3691: +UNSELECT+
385419 # Folded into IMAP4rev2[https://tools.ietf.org/html/rfc9051], so it is also
386420 # listed with {Core IMAP commands}[rdoc-ref:Net::IMAP@Core+IMAP+commands].
387- # - #unselect: Closes the mailbox and returns to the "_authenticated_" state,
421+ # - #unselect: Closes the mailbox and returns to the +authenticated+ state,
388422 # without expunging any messages.
389423 #
390424 # ==== RFC4314: +ACL+
0 commit comments