跳到主要内容

5.2. MTP 应答

设计 MTP 命令的应答,是为了确保邮件传输过程中请求与动作的同步,并保证发送方 MTP 始终知道接收方 MTP 的状态。每条命令必须恰好产生一个应答。此外,有些命令必须按顺序出现,例如 MRSQ T->MAIL->MRCP 或 MRSQ R->MRCP->MAIL。

命令-应答序列的细节在关于时序和状态图的第 5.3 和 5.4 节中明确给出。

MTP 应答由一个三位数字(以三个字母数字字符传输)后跟一些文本组成。数字供自动机用来确定下一步进入什么状态;文本则是给人类用户看的。其意图是让这三位数字包含足够的编码信息,使发送方 MTP 无需检查文本,可以根据情况丢弃文本或将其转交给用户。特别地,文本可能依赖于接收方,因此每个应答码可能有各种不同的文本。关于应答码分配的进一步说明见关于应答码理论的附录 E。形式上,应答定义为如下序列:三位数字代码、<SP>、一行文本和 <CRLF>。

5.2.1. 按功能分组的应答码​

200 Command okay
201 Command okay, action aborted
500 Syntax error, command unrecognized
[This may include errors such as command line too long]
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented

211 System status, or system help reply
214 Help message
[Information on how to use the receiver or the meaning of a
particular non-standard command; this reply is useful only
to the human user]
215 <scheme> is the preferred scheme

120 <host> Service ready in nnn minutes
220 <host> Service ready for new user
221 <host> Service closing transmission channel
421 <host> Service not available, closing transmission channel
[This may be a reply to any command if the service knows it
must shut down]

151 User not local; will forward to <user>@<host>
152 User unknown; mail will be forwarded by the operator
250 Requested mail action okay, completed
450 Requested mail action not taken: mailbox unavailable
[E.g., mailbox busy]
550 Requested action not taken: mailbox unavailable
[E.g., mailbox not found, no access]
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
552 Requested mail action aborted: exceeded storage allocation
[For current mailbox location]
553 Requested action not taken: mailbox name not allowed
[E.g., mailbox syntax incorrect]
354 Start mail input; end with <CRLF>.<CRLF>

5.2.2. 应答码的数字顺序列表​

120 <host> Service ready in nnn minutes
151 User not local; will forward to <user>@<host>
152 User unknown; mail will be forwarded by the operator

200 Command okay
201 Command okay, action aborted
211 System status, or system help reply
214 Help message
[Information on how to use the receiver or the meaning of a
particular non-standard command; this reply is useful only
to the human user]
215 <scheme> is the preferred scheme
220 <host> Service ready for new user
221 <host> Service closing transmission channel
250 Requested mail action okay, completed

354 Start mail input; end with <CRLF>.<CRLF>

421 <host> Service not available, closing transmission channel
[This may be a reply to any command if the service knows it
must shut down]
450 Requested mail action not taken: mailbox unavailable
[E.g., mailbox busy]
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage

500 Syntax error, command unrecognized
[This may include errors such as command line too long]
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented
550 Requested action not taken: mailbox unavailable
[E.g., mailbox not found, no access]
552 Requested mail action aborted: exceeded storage allocation
[For current mailbox location]
553 Requested action not taken: mailbox name not allowed
[E.g., mailbox syntax incorrect]