📄 rfc1730.txt
字号:
Crispin [Page 9]
RFC 1730 IMAP4 December 1994
6. Client Commands
IMAP4 commands are described in this section. Commands are organized
by the state in which the command is permitted. Commands which are
permitted in multiple states are listed in the minimum permitted
state (for example, commands valid in authenticated and selected
state are listed in the authenticated state commands).
Command arguments, identified by "Arguments:" in the command
descriptions below, are described by function, not by syntax. The
precise syntax of command arguments is described in the Formal Syntax
section.
Some commands cause specific server data to be returned; these are
identified by "Data:" in the command descriptions below. See the
response descriptions in the Responses section for information on
these responses, and the Formal Syntax section for the precise syntax
of these responses. It is possible for server data to be transmitted
as a result of any command; thus, commands that do not specifically
require server data specify "no specific data for this command"
instead of "none".
The "Result:" in the command description refers to the possible
tagged status responses to a command, and any special interpretation
of these status responses.
6.1. Client Commands - Any State
The following commands are valid in any state: CAPABILITY, NOOP, and
LOGOUT.
6.1.1. CAPABILITY Command
Arguments: none
Data: mandatory untagged response: CAPABILITY
Result: OK - capability completed
BAD - command unknown or arguments invalid
The CAPABILITY command requests a listing of capabilities that the
server supports. The server MUST send a single untagged
CAPABILITY response with "IMAP4" as the first listed capability
before the (tagged) OK response. This listing of capabilities is
not dependent upon connection state or user. It is therefore not
necessary to issue a CAPABILITY command more than once in a
session.
Crispin [Page 10]
RFC 1730 IMAP4 December 1994
Capability names other than "IMAP4" refer to extensions,
revisions, or amendments to this specification. See the
documentation of the CAPABILITY response for additional
information. No capabilities are enabled without explicit client
action to invoke the capability. See the section entitled "Client
Commands - Experimental/Expansion" for information about the form
of site or implementation-specific capabilities.
Example: C: abcd CAPABILITY
S: * CAPABILITY IMAP4
S: abcd OK CAPABILITY completed
6.1.2. NOOP Command
Arguments: none
Data: no specific data for this command (but see below)
Result: OK - noop completed
BAD - command unknown or arguments invalid
The NOOP command always succeeds. It does nothing.
Since any command can return a status update as untagged data, the
NOOP command can be used as a periodic poll for new messages or
message status updates during a period of inactivity. The NOOP
command can also be used to reset any inactivity autologout timer
on the server.
Example: C: a002 NOOP
S: a002 OK NOOP completed
. . .
C: a047 NOOP
S: * 22 EXPUNGE
S: * 23 EXISTS
S: * 3 RECENT
S: * 14 FETCH (FLAGS (\Seen \Deleted))
S: a047 OK NOOP completed
Crispin [Page 11]
RFC 1730 IMAP4 December 1994
6.1.3. LOGOUT Command
Arguments: none
Data: mandatory untagged response: BYE
Result: OK - logout completed
BAD - command unknown or arguments invalid
The LOGOUT command informs the server that the client is done with
the session. The server must send a BYE untagged response before
the (tagged) OK response, and then close the network connection.
Example: C: A023 LOGOUT
S: * BYE IMAP4 Server logging out
S: A023 OK LOGOUT completed
(Server and client then close the connection)
6.2. Client Commands - Non-Authenticated State
In non-authenticated state, the AUTHENTICATE or LOGIN command
establishes authentication and enter authenticated state. The
AUTHENTICATE command provides a general mechanism for a variety of
authentication techniques, whereas the LOGIN command uses the
traditional user name and plaintext password pair.
Server implementations may allow non-authenticated access to certain
mailboxes. The convention is to use a LOGIN command with the userid
"anonymous". A password is required. It is implementation-dependent
what requirements, if any, are placed on the password and what access
restrictions are placed on anonymous users.
Once authenticated (including as anonymous), it is not possible to
re-enter non-authenticated state.
In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT),
the following commands are valid in non-authenticated state:
AUTHENTICATE and LOGIN.
Crispin [Page 12]
RFC 1730 IMAP4 December 1994
6.2.1. AUTHENTICATE Command
Arguments: authentication mechanism name
Data: continuation data may be requested
Result: OK - authenticate completed, now in authenticated state
NO - authenticate failure: unsupported authentication
mechanism, credentials rejected
BAD - command unknown or arguments invalid,
authentication exchange cancelled
The AUTHENTICATE command indicates an authentication mechanism,
such as described in [IMAP-AUTH], to the server. If the server
supports the requested authentication mechanism, it performs an
authentication protocol exchange to authenticate and identify the
user. Optionally, it also negotiates a protection mechanism for
subsequent protocol interactions. If the requested authentication
mechanism is not supported, the server should reject the
AUTHENTICATE command by sending a tagged NO response.
The authentication protocol exchange consists of a series of
server challenges and client answers that are specific to the
authentication mechanism. A server challenge consists of a
command continuation request response with the "+" token followed
by a BASE64 encoded string. The client answer consists of a line
consisting of a BASE64 encoded string. If the client wishes to
cancel an authentication exchange, it should issue a line with a
single "*". If the server receives such an answer, it must reject
the AUTHENTICATE command by sending a tagged BAD response.
A protection mechanism provides integrity and privacy protection
to the protocol session. If a protection mechanism is negotiated,
it is applied to all subsequent data sent over the connection.
The protection mechanism takes effect immediately following the
CRLF that concludes the authentication exchange for the client,
and the CRLF of the tagged OK response for the server. Once the
protection mechanism is in effect, the stream of command and
response octets is processed into buffers of ciphertext. Each
buffer is transferred over the connection as a stream of octets
prepended with a four octet field in network byte order that
represents the length of the following data. The maximum
ciphertext buffer length is defined by the protection mechanism.
The server is not required to support any particular
authentication mechanism, nor are authentication mechanisms
required to support any protection mechanisms. If an AUTHENTICATE
command fails with a NO response, the client may try another
Crispin [Page 13]
RFC 1730 IMAP4 December 1994
authentication mechanism by issuing another AUTHENTICATE command,
or may attempt to authenticate by using the LOGIN command. In
other words, the client may request authentication types in
decreasing order of preference, with the LOGIN command as a last
resort.
Example: S: * OK KerberosV4 IMAP4 Server
C: A001 AUTHENTICATE KERBEROS_V4
S: + AmFYig==
C: BAcAQU5EUkVXLkNNVS5FRFUAOCAsho84kLN3/IJmrMG+25a4DT
+nZImJjnTNHJUtxAA+o0KPKfHEcAFs9a3CL5Oebe/ydHJUwYFd
WwuQ1MWiy6IesKvjL5rL9WjXUb9MwT9bpObYLGOKi1Qh
S: + or//EoAADZI=
C: DiAF5A4gA+oOIALuBkAAmw==
S: A001 OK Kerberos V4 authentication successful
Note: the line breaks in the first client answer are for
editorial clarity and are not in real authenticators.
6.2.2. LOGIN Command
Arguments: user name
password
Data: no specific data for this command
Result: OK - login completed, now in authenticated state
NO - login failure: user name or password rejected
BAD - command unknown or arguments invalid
The LOGIN command identifies the user to the server and carries
the plaintext password authenticating this user.
Example: C: a001 LOGIN SMITH SESAME
S: a001 OK LOGIN completed
6.3. Client Commands - Authenticated State
In authenticated state, commands that manipulate mailboxes as atomic
entities are permitted. Of these commands, the SELECT and EXAMINE
commands will select a mailbox for access and enter selected state.
Crispin [Page 14]
RFC 1730 IMAP4 December 1994
In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT),
the following commands are valid in authenticated state: SELECT,
EXAMINE, CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB,
and APPEND.
6.3.1. SELECT Command
Arguments: mailbox name
Data: mandatory untagged responses: FLAGS, EXISTS, RECENT
optional OK untagged responses: UNSEEN, PERMANENTFLAGS
Result: OK - select completed, now in selected state
NO - select failure, now in authenticated state: no
such mailbox, can't access mailbox
BAD - command unknown or arguments invalid
The SELECT command selects a mailbox so that messages in the
mailbox can be accessed. Before returning an OK to the client,
the server MUST send the following untagged data to the client:
FLAGS Defined flags in the mailbox
<n> EXISTS The number of messages in the mailbox
<n> RECENT The number of messages added to the mailbox since
the previous time this mailbox was read
OK [UIDVALIDITY <n>]
The unique identifier validity value. See the
description of the UID command for more detail.
to define the initial state of the mailbox at the client. If it
is not possible to determine the messages that were added since
the previous time a mailbox was read, then all messages SHOULD be
considered recent.
The server SHOULD also send an UNSEEN response code in an OK
untagged response, indicating the message sequence number of the
first unseen message in the mailbox.
If the client can not change the permanent state of one or more of
the flags listed in the FLAGS untagged response, the server SHOULD
send a PERMANENTFLAGS response code in an OK untagged response,
listing the flags that the client may change permanently.
Only one mailbox may be selected at a time in a session;
simultaneous access to multiple mailboxes requires multiple
Crispin [Page 15]
RFC 1730 IMAP4 December 1994
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -