home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 700s / rfc772.txt < prev    next >
Text File  |  1992-10-14  |  61KB  |  1,798 lines

  1.  
  2.  
  3. Network Working Group                                         S. Sluizer
  4. Request for Comments: 772                                      J. Postel
  5.                                                                      ISI
  6.                                                           September 1980
  7.  
  8.                          MAIL TRANSFER PROTOCOL
  9.  
  10.  
  11. PREFACE
  12.  
  13.    This is a first draft of this protocol and comments are very
  14.    definitely requested.
  15.  
  16. INTRODUCTION
  17.  
  18.    The objective of Mail Transfer Protocol (MTP) is to transfer mail
  19.    reliably and efficiently.
  20.  
  21.    This paper assumes knowledge of the following protocols described in
  22.    the ARPA Internet Protocol Handbook.  The reader will note strong
  23.    similarities to portions of the File Transfer Protocol; in part, this
  24.    is due to the original ARPA Network implementation of computer mail
  25.    as a feature of FTP.
  26.  
  27.       The ARPANET Host-to-Host Protocol [Network Control Protocol] (NCP)
  28.  
  29.       The Transmission Control Protocol (TCP)
  30.  
  31.       The TELNET Protocol (TELNET)
  32.  
  33.       The File Transfer Protocol (FTP)
  34.  
  35. DISCUSSION
  36.  
  37.    In this section, the terminology and the MTP model are discussed.
  38.    The terms defined in this section are only those that have special
  39.    significance in MTP.  Some of the terminology is very specific to the
  40.    MTP model; some readers may wish to turn to the section on the MTP
  41.    model while reviewing the terminology.
  42.  
  43.    TERMINOLOGY
  44.  
  45.       ASCII
  46.  
  47.          The ASCII character set as defined in the ARPA Internet
  48.          Protocol Handbook.  In MTP, ASCII characters are defined to be
  49.          the lower half of an eight-bit code set (i.e., the most
  50.          significant bit is zero) and is called NVT-ASCII.
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.                                    1
  58.  
  59.  
  60.                                                                         
  61. September 1980                                                   RFC 772
  62. Mail Transfer Protocol                                                  
  63.  
  64.  
  65.  
  66.       control connection
  67.  
  68.          The TCP full-duplex communication path or two NCP simplex
  69.          communication paths between a sender-MTP and a receiver-MTP for
  70.          the exchange of commands, replies, and mail text.  The control
  71.          connection operates according to the TELNET Protocol.
  72.  
  73.       data mode
  74.  
  75.          The mail is transmitted over the control connection as a stream
  76.          of octets.  (In FTP terminology this is called stream mode.)
  77.  
  78.       data structure
  79.  
  80.          The internal structure of mail is considered to be a continuous
  81.          sequence of data octets.  (In FTP terminology this is called
  82.          file-structure.)
  83.  
  84.       data representation
  85.  
  86.          The internal representation of all data (i.e., mail) is in
  87.          NVT-ASCII.
  88.  
  89.       host
  90.  
  91.          A computer in the internetwork environment on which mailboxes
  92.          reside.
  93.  
  94.       MTP commands
  95.  
  96.          A set of commands which comprise the control information
  97.          flowing from the sender-MTP to the receiver-MTP.
  98.  
  99.       mail
  100.  
  101.          An ordered set of computer data of arbitrary length, which
  102.          conforms to the standard set in RFC 733 (Standard for the
  103.          Format of ARPA Network Text Messages).
  104.  
  105.       mailbox
  106.  
  107.          A character string (address) which identifies a user to whom
  108.          mail is to be sent.  Mailbox normally consists of the host and
  109.          user specifications.  The standard mailbox naming convention is
  110.          defined to be "user@host".  Additionally, the "container" in
  111.          which mail is stored.
  112.  
  113.  
  114.  
  115.                                    2
  116.  
  117.  
  118.                                                                         
  119. RFC 772                                                   September 1980
  120.                                                   Mail Transfer Protocol
  121.  
  122.  
  123.  
  124.       NVT
  125.  
  126.          The Network Virtual Terminal as defined in the TELNET Protocol.
  127.  
  128.       octet
  129.  
  130.          Bytes in MTP are octets (8 bits).  This is not necessarily the
  131.          same byte size in which data is stored in a host.
  132.  
  133.       reply
  134.  
  135.          A reply is an acknowledgment (positive or negative) sent from
  136.          receiver to sender via the control connection in response to a
  137.          MTP command.  The general form of a reply is a completion code
  138.          (including error codes) followed by a text string.  The codes
  139.          are for use by programs and the text is usually intended for
  140.          human users.
  141.  
  142.       receiver-MTP process
  143.  
  144.          A process which transfers mail in cooperation with a sender-MTP
  145.          process.  It "listens" on its port/socket L for a connection
  146.          from a sender-MTP and establishes a control connection using
  147.          the TELNET Protocol.  It receives MTP commands from the
  148.          sender-MTP, sends replies, and governs the transfer of mail.
  149.  
  150.       sender-MTP process
  151.  
  152.          A process which transfers mail in cooperation with a
  153.          receiver-MTP process.  A local language may be used in the user
  154.          interface command/reply dialogue.  The sender-MTP initiates the
  155.          control connection from its port/socket U to the receiver-MTP
  156.          process.  It initiates MTP commands, receives replies, and
  157.          governs the transfer of mail.
  158.  
  159.       user
  160.  
  161.          A human being (or a process on behalf of a human being) wishing
  162.          to obtain mail transfer service.  In addition, a recipient of
  163.          computer mail.
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.                                    3
  174.  
  175.  
  176.                                                                         
  177. September 1980                                                   RFC 772
  178. Mail Transfer Protocol                                                  
  179.  
  180.  
  181.  
  182.    THE MTP MODEL
  183.  
  184.       With the above definitions in mind, the following model (shown in
  185.       Figure 1) may be diagrammed for an MTP service.
  186.  
  187.                   ------------                ------------
  188.                   |          |                |          |    --------
  189.                   |          |      MTP       |          |<-->| User |
  190.                   | Receiver-|Commands/Replies|  Sender- |    --------
  191.       --------    |   MTP    |<-------------->|    MTP   |    --------
  192.       | Mail |<-->|          |      Mail      |          |<-->| Mail |
  193.       |System|    |          |                |          |    |System|
  194.       --------    ------------                ------------    --------
  195.       
  196.  
  197.                   Receiver-MTP                 Sender-MTP
  198.  
  199.                            Model for MTP Use
  200.  
  201.                                 Figure 1
  202.  
  203.       In the model described in Figure 1, the sender-MTP initiates the
  204.       TCP/NCP control connection which follows the TELNET Protocol.  At
  205.       the initiation of the user, standard MTP commands are generated by
  206.       the sender-MTP and transmitted to the receiver-MTP via the control
  207.       connection.  Standard replies are sent from the receiver-MTP to
  208.       the sender-MTP over the control connection in response to the
  209.       commands.  In addition, mail is sent over the control connection.
  210.  
  211. MAIL TRANSFER FUNCTIONS
  212.  
  213.    The control connection is used for the transfer of commands which
  214.    describe the functions to be performed, the replies to commands, as
  215.    well as the actual transfer of mail.  Mail is transferred only via
  216.    the control connection.
  217.  
  218.    The communication channel from the sender-MTP to the receiver-MTP is
  219.    established by a TCP/NCP control connection from the sender to a
  220.    standard receiver port/socket.  The sender-MTP is responsible for
  221.    sending MTP commands, interpreting the replies received, and sending
  222.    the mail; the receiver-MTP interprets commands, sends replies, and
  223.    receives the mail.
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.                                    4
  232.  
  233.  
  234.                                                                         
  235. RFC 772                                                   September 1980
  236.                                                   Mail Transfer Protocol
  237.  
  238.  
  239.  
  240.    MAIL REPRESENTATION AND STORAGE
  241.  
  242.       Mail is transferred from a storage device in the sending host to a
  243.       storage device in the receiving host.  It may be necessary to
  244.       perform certain transformations on the mail because data storage
  245.       representations in the two systems are different.  For example,
  246.       NVT-ASCII has different data storage representations in different
  247.       systems.  PDP-10's generally store NVT-ASCII as five 7-bit ASCII
  248.       characters, left-justified in a 36-bit word.  360's store
  249.       NVT-ASCII as four 8-bit EBCDIC codes in a 32-bit word.  Multics
  250.       stores NVT-ASCII as four 9-bit characters in a 36-bit word.
  251.  
  252.       For the sake of simplicity, all data must be represented in MTP as
  253.       NVT-ASCII.  This means that characters must be converted into the
  254.       standard NVT-ASCII representation when transmitting text,
  255.       regardless of whether the sending and receiving hosts are
  256.       dissimilar.  The sender converts the data from its internal
  257.       character representation to the standard 8-bit NVT-ASCII
  258.       representation (see the TELNET specification).  The receiver
  259.       converts the data from the standard form to its own internal form.
  260.       In accordance with this standard, the <CRLF> sequence should be
  261.       used to denote the end of a line of text.
  262.  
  263.       The mail in MTP has no internal structure and is considered to be
  264.       a continuous sequence of data octets.
  265.  
  266.    ERROR RECOVERY AND RESTART
  267.  
  268.       There is no provision for detecting bits lost or scrambled in data
  269.       transfer; this level of error control is handled by the TCP/NCP.
  270.       In addition, there is no restart procedure provided to protect
  271.       senders from gross system failures (including failures of a host,
  272.       an MTP-process, or the underlying network).
  273.  
  274. MTP COMMANDS
  275.  
  276.    COMMAND SEMANTICS
  277.  
  278.       The MTP commands define the mail transfer or the mail system
  279.       function requested by the user.  The syntax of mailboxes must
  280.       conform to receiver site conventions (with standard defaults
  281.       applicable).  In response to an MTP transfer command, the mail
  282.       shall always be transferred over the control connection.
  283.  
  284.       The Mail Transfer Protocol follows the specifications of the
  285.       TELNET Protocol for all communications over the control
  286.  
  287.  
  288.  
  289.                                    5
  290.  
  291.  
  292.                                                                         
  293. September 1980                                                   RFC 772
  294. Mail Transfer Protocol                                                  
  295.  
  296.  
  297.  
  298.       connection.  Although the language used for TELNET communication
  299.       can be a negotiated option, the "TELNET language" and the
  300.       corresponding "TELNET end of line code" are required to be
  301.       NVT-ASCII and <CRLF> respectively.  No other specifications of the
  302.       TELNET Protocol will be cited.
  303.  
  304.       MTP commands are NVT-ASCII strings terminated by <CRLF>.  The
  305.       command codes themselves are alphabetic characters terminated by
  306.       the character <SP> (space) if parameters follow and <CRLF>
  307.       otherwise.
  308.  
  309.       The MTP commands are discussed below.  In the description of a few
  310.       of the commands in this section the possible replies are given
  311.       explicitly.  MTP replies are discussed in the next section.
  312.  
  313.          MAIL (MAIL)
  314.  
  315.             This command allows a sender-MTP to send mail over the
  316.             control connection.  The argument field contains a sender
  317.             and optional path sequence.  If the path sequence is
  318.             present, it consists of an optional list of hosts and a
  319.             destination mailbox.  When the list of hosts is present, it
  320.             is source routing information and indicates that the mail
  321.             must be forwarded to the first host on the list.  Following
  322.             this command line the receiver treats all subsequent
  323.             characters as mail text from the sender.  The mail text is
  324.             terminated by the character sequence "CRLF.CRLF".
  325.  
  326.             As mail is forwarded along the path sequence, each
  327.             forwarding host must remove itself from the list.  When mail
  328.             reaches its ultimate destination (the path sequence has only
  329.             a (possibly empty) destination mailbox), the receiver
  330.             inserts it into the destination mailbox in accordance with
  331.             its host mail conventions.  If the second argument field is
  332.             blank (one or more spaces) or empty (<CRLF>), the mail is
  333.             destined for a printer or other designated place for site
  334.             general delivery mail.  The mail may be marked as sent from
  335.             the sender as specified by the first argument field.
  336.  
  337.          MAIL RECIPIENT SCHEME QUESTION (MRSQ)
  338.  
  339.             This MTP command is used to select a scheme for the
  340.             transmission of mail to several users at the same host.  The
  341.             schemes are to list the recipients first, or to send the
  342.             mail first.
  343.  
  344.  
  345.  
  346.  
  347.                                    6
  348.  
  349.  
  350.                                                                         
  351. RFC 772                                                   September 1980
  352.                                                   Mail Transfer Protocol
  353.  
  354.  
  355.  
  356.          MAIL RECIPIENT (MRCP)
  357.  
  358.             This command is used to identify the individual recipients
  359.             of the mail in the transmission of mail for multiple users
  360.             at one host.
  361.  
  362.          HELP (HELP)
  363.  
  364.             This command causes the receiver to send helpful information
  365.             regarding its implementation status over the control
  366.             connection to the receiver.  The command may take an
  367.             argument (e.g., any command name) and return more specific
  368.             information as a response.  The reply is type 211 or 214.
  369.  
  370.          QUIT (QUIT)
  371.  
  372.             This command specifies that the receiver must close the
  373.             control connection.
  374.  
  375.          NOOP (NOOP)
  376.  
  377.             This command does not affect any parameters or previously
  378.             entered commands.  It specifies no action other than that
  379.             the receiver send an OK reply.
  380.  
  381.    COMMAND SYNTAX
  382.  
  383.       The commands (and their functions and semantics) are TELNET
  384.       NVT-ASCII strings transmitted over the control connection.  The
  385.       functions and semantics of commands are described in the section
  386.       on MTP Commands.  The reply sequences are discussed in the section
  387.       on Sequencing of Commands and Replies.  Scenarios illustrating the
  388.       use of commands are provided in the section on Typical MTP
  389.       Scenarios.  The command syntax is specified in this section.
  390.  
  391.       The commands begin with a command code followed by an argument
  392.       field.  The command codes are four alphabetic characters.  Upper
  393.       and lower case alphabetic characters are to be treated
  394.       identically.  Thus any of the following may represent the mail
  395.       command:
  396.  
  397.          MAIL    Mail    mail    MaIl    mAIl
  398.  
  399.       This also applies to any symbols representing parameter values,
  400.       such as R or r for RECIPIENT first.  The command codes and the
  401.       argument fields are separated by one or more spaces.
  402.  
  403.  
  404.  
  405.                                    7
  406.  
  407.  
  408.                                                                         
  409. September 1980                                                   RFC 772
  410. Mail Transfer Protocol                                                  
  411.  
  412.  
  413.  
  414.       The argument field consists of a variable length character string
  415.       ending with the character sequence <CRLF>.  It should be noted
  416.       that the receiver is to take no action until the end of line code
  417.       is received.
  418.  
  419.       The syntax is specified below in NVT-ASCII.  All characters in the
  420.       argument field are ASCII characters.  Square brackets denote an
  421.       optional argument field.  If the option is not taken, the
  422.       appropriate default is implied.
  423.  
  424.       The following are the MTP commands:
  425.  
  426.          MAIL <SP> FROM:<sender> [<SP> TO:<path>] <CRLF>
  427.  
  428.          MRSQ [<SP> <scheme>] <CRLF>
  429.  
  430.          MRCP <SP> TO:<path> <CRLF>
  431.  
  432.          HELP [<SP> <string>] <CRLF>
  433.  
  434.          QUIT <CRLF>
  435.  
  436.          NOOP <CRLF>
  437.  
  438.       The syntax of the above argument fields (using BNF notation where
  439.       applicable) is given below.  The "..." notation indicates that a
  440.       field may be repeated one or more times.
  441.  
  442.          <sender> ::= "<" <mailbox> ">"
  443.  
  444.          <path> ::= "<" ["@" <host> "," ...] <mailbox> ">"
  445.  
  446.          <scheme> ::= "R" | "T" | "?"
  447.  
  448.          <string> ::= <char> | <char><string>
  449.  
  450.          <mailbox> ::= <user> "@" <host>
  451.  
  452.          <host> ::= <string>
  453.  
  454.          <user> ::= <string>
  455.  
  456.          <char> ::= any of the 128 ASCII characters except <CR> and <LF>
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.                                    8
  464.  
  465.  
  466.                                                                         
  467. RFC 772                                                   September 1980
  468.                                                   Mail Transfer Protocol
  469.  
  470.  
  471.  
  472.    CONTROL FUNCTIONS
  473.  
  474.       Most time-sharing systems provide mechanisms to allow a terminal
  475.       user to regain control of a "runaway" process.  When used locally,
  476.       such systems have access to all user-supplied signals, whether
  477.       these are normal characters or special "out of band" signals.
  478.       When terminals are connected to the system through the network,
  479.       the system does not necessarily have access to all user signals;
  480.       the network's flow control mechanisms may cause such signals to be
  481.       buffered elsewhere, for example in the user's host.
  482.  
  483.       To counter this problem, the TELNET "Synch" mechanism is used.  A
  484.       Synch signal consists of a TCP Urgent or an NCP Interrupt
  485.       notification, coupled with the TELNET command DATA MARK (DM).
  486.       This notification, which is not subject to the flow control
  487.       pertaining to the TELNET connection, is used to invoke special
  488.       handling of the data stream by the process which receives it.  In
  489.       this mode the data stream is immediately scanned for a TELNET
  490.       Interrupt Process (IP) command.  (The rationale for the use of the
  491.       TELNET IP command is to allow an existing server TELNET module to
  492.       sit "under" the MTP.  If this code were directly implemented in
  493.       the MTP the IP command would be unnecessary.)  The TELNET command
  494.       DM is the synchronizing mark in the data stream which indicates
  495.       that any special signal has already occurred and the recipient can
  496.       return to normal processing of the data stream.  For a more
  497.       complete understanding of this mechanism, see the TELNET Protocol
  498.       Specification in the Internet Protocol Handbook.
  499.  
  500.       The effect of this mechanism is to to discard all characters (up
  501.       to the DM) between the sender of the Synch and its recipeint.
  502.       Thus, all characters in the control connection are ignored until
  503.       the TELNET command DM is received.  The full sequence is
  504.       illustrated below.  Each vertical bar (|) represents the boundary
  505.       between data octets; IAC refers to the TELNET command code
  506.       Interpret As Command.
  507.  
  508.                        Old                       New
  509.                     -+-+-+-+-+-----+---+--+---+--+-  
  510.                   ...|M|A|I|L| ... |IAC|IP|IAC|DM|...
  511.                     -+-+-+-+-+-----+---+--+---+--+-  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.                                    9
  522.  
  523.  
  524.                                                                         
  525. September 1980                                                   RFC 772
  526. Mail Transfer Protocol                                                  
  527.  
  528.  
  529.  
  530. MTP REPLIES
  531.  
  532.    Replies to Mail Transfer Protocol commands are devised to ensure the
  533.    synchronization of requests and actions in the process of mail
  534.    transfer, and to guarantee that the sender-MTP always knows the state
  535.    of the receiver.  Every command must generate at least one reply,
  536.    although there may be more than one.  In the latter case, the
  537.    multiple replies must be easily distinguished.  Additionally, some
  538.    commands must occur sequentially, such as MRSQ T->MAIL->MRCP or
  539.    MRSQ R->MRCP->MAIL.  Replies to these sequences show the existence of
  540.    an intermediate state if all preceding commands have been successful.
  541.    A failure at any point in the sequence necessitates the repetition of
  542.    the entire sequence from the beginning.
  543.  
  544.       The details of the command-reply sequence are made explicit in the
  545.       section on State Diagrams.
  546.  
  547.    An MTP reply consists of a three digit number (transmitted as three
  548.    alphanumeric characters) followed by some text.  The number is
  549.    intended for use by automata to determine what state to enter next;
  550.    the text is meant for the human user.  It is intended that the three
  551.    digits contain enough encoded information that the sender-MTP will
  552.    not need to examine the text and may either discard it or pass it on
  553.    to the user, as appropriate.  In particular, the text may be
  554.    receiver-dependent, so there are likely to be varying texts for each
  555.    reply code.
  556.  
  557.    Formally, a reply is defined to be the sequence:  a three-digit code,
  558.    space <SP>, one line of text (where the maximum line length is 65),
  559.    and a terminal <CRLF>.  Occasionally the text is longer than a single
  560.    line; in these cases the complete text must be bracketed so the
  561.    sender-MTP knows when it can stop reading the reply.  This requires a
  562.    special first line format to indicate a multiple line reply, and
  563.    another on the last line to so designate it.  Both lines will contain
  564.    the appropriate reply code which indicates the transaction state.
  565.  
  566.       Thus the format for multi-line replies is that the first line will
  567.       begin with the exact required reply code, followed immediately by
  568.       a Hyphen, "-" (also known as minus), followed by text.  The last
  569.       line will begin with the same code, followed immediately by space
  570.       <SP>, optionally some text, and <CRLF>.
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.                                    10
  580.  
  581.  
  582.                                                                         
  583. RFC 772                                                   September 1980
  584.                                                   Mail Transfer Protocol
  585.  
  586.  
  587.  
  588.          For example:
  589.                                 123-First line
  590.                                 Second line
  591.                                   234 A line beginning with numbers
  592.                                 123 The last line
  593.  
  594.       The sender-MTP then simply needs to search for the second
  595.       occurrence of the same reply code followed by <SP> (space> at the
  596.       beginning of a line, and ignore all intermediary lines.  If an
  597.       intermediary line begins with a three-digit number, the receiver
  598.       must pad the front to avoid confusion.
  599.  
  600.          This scheme allows standard system routines to be used for
  601.          reply information, with "artificial" first and last lines
  602.          tacked on.  In the rare cases where these routines are able to
  603.          generate three digits and a space at the beginning of any line,
  604.          the beginning of each text line should be offset by some
  605.          neutral text, like space.
  606.  
  607.       This scheme assumes that multi-line replies may not be nested.  In
  608.       general, reply nesting will not occur except for random system
  609.       messages (also called spontaneous replies) which may interrupt
  610.       another reply.  System messages (i.e., those not processed by the
  611.       receiver-MTP) will NOT carry reply codes and may occur anywhere in
  612.       the command-reply sequence.  They may be ignored by the sender-MTP
  613.       as they are only information for the human user.
  614.  
  615.    The three digits of the reply each have a special significance.  This
  616.    is intended to allow a range of very simple to very sophisticated
  617.    response by the sender-MTP.  The first digit denotes whether the
  618.    response is good, bad or incomplete.  (Referring to the state
  619.    diagram) an unsophisticated sender-MTP will be able to determine its
  620.    next action (proceed as planned, redo, retrench, etc.) by simply
  621.    examining this first digit.  A sender-MTP that wants to know
  622.    approximately what kind of error occurred (e.g., mail system error,
  623.    command syntax error) may examine the second digit, reserving the
  624.    third digit for the finest gradation of information.
  625.  
  626.       There are five values for the first digit of the reply code:
  627.  
  628.          1yz   Positive Preliminary reply
  629.  
  630.             The requested action is being initiated; expect another
  631.             reply before proceeding with a new command.  (The sender-MTP
  632.             sending another command before the completion reply would be
  633.  
  634.  
  635.  
  636.  
  637.                                    11
  638.  
  639.  
  640.                                                                         
  641. September 1980                                                   RFC 772
  642. Mail Transfer Protocol                                                  
  643.  
  644.  
  645.  
  646.             in violation of protocol.  However, receiver-MTP processes
  647.             should queue any commands that arrive while a preceding
  648.             command is in progress.)
  649.  
  650.          2yz   Positive Completion reply
  651.  
  652.             The requested action has been successfully completed.  A new
  653.             request may be initiated.
  654.  
  655.          3yz   Positive Intermediate reply
  656.  
  657.             The command has been accepted, but the requested action is
  658.             being held in abeyance, pending receipt of further
  659.             information.  The sender-MTP should send another command
  660.             specifying this information.  This reply is used in command
  661.             sequence groups.
  662.  
  663.          4yz   Transient Negative Completion reply
  664.  
  665.             The command was not accepted and the requested action did
  666.             not occur.  However, the error condition is temporary and
  667.             the action may be requested again.  The sender should return
  668.             to the beginning of the command sequence (if any).  It is
  669.             difficult to assign a meaning to "transient" when two
  670.             different sites (receiver- and sender- MTPs) must agree on
  671.             the interpretation.  Each reply in this category might have
  672.             a different time value, but the sender-MTP is encouraged to
  673.             try again.  A rule of thumb to determine if a reply fits
  674.             into the 4yz or the 5yz category (see below) is that replies
  675.             are 4yz if they can be repeated without any change in
  676.             command form or in properties of the sender or receiver.
  677.             (E.g., the command is repeated identically; the receiver
  678.             does not put up a new implementation).
  679.  
  680.          5yz   Permanent Negative Completion reply
  681.  
  682.             The command was not accepted and the requested action did
  683.             not occur.  The sender-MTP is discouraged from repeating the
  684.             exact request (in the same sequence).  Even some "permanent"
  685.             error conditions can be corrected, so the human user may
  686.             want to direct the sender-MTP to reinitiate the command
  687.             sequence by direct action at some point in the future (e.g.,
  688.             after the spelling has been changed, or the user has altered
  689.             his/her directory status.)
  690.  
  691.  
  692.  
  693.  
  694.  
  695.                                    12
  696.  
  697.  
  698.                                                                         
  699. RFC 772                                                   September 1980
  700.                                                   Mail Transfer Protocol
  701.  
  702.  
  703.  
  704.       The second digit encodes responses in specific categories:
  705.  
  706.          x0z   Syntax -- These replies refer to syntax errors,
  707.                syntactically correct commands that don't fit any
  708.                functional category, and unimplemented or superfluous
  709.                commands.
  710.  
  711.          x1z   Information --  These are replies to requests for
  712.                information, such as status or help.
  713.  
  714.          x2z   Connections -- These are replies referring to the control
  715.                connection.
  716.  
  717.          x3z   Unspecified as yet.
  718.  
  719.          x4z   Unspecified as yet.
  720.  
  721.          x5z   Mail system -- These replies indicate the status of the
  722.                receiver mail system vis-a-vis the requested transfer or
  723.                other mail system action.
  724.  
  725.       The third digit gives a finer gradation of meaning in each
  726.       category specified by the second digit.  The list of replies below
  727.       will illustrate this.  Each reply text is recommended rather than
  728.       mandatory, and may even change according to the command with which
  729.       it is associated.  On the other hand, the reply codes must
  730.       strictly follow the specifications in this section.  Receiver
  731.       implementations should not invent new codes for slightly different
  732.       situations from the ones described here, but rather adapt codes
  733.       already defined.
  734.  
  735.          A command such as NOOP whose successful execution does not
  736.          offer the sender-MTP any new information will return a 200
  737.          reply.  The response is 502 when the command requests an
  738.          unimplemented non-site-specific action.  A refinement of that
  739.          is the 504 reply for a command that IS implemented, but that
  740.          requests an unimplemented parameter.
  741.  
  742.    REPLY CODES BY FUNCTION GROUPS
  743.  
  744.       200 Command okay
  745.       500 Syntax error, command unrecognized
  746.          [This may include errors such as command line too long]
  747.       501 Syntax error in parameters or arguments
  748.       502 Command not implemented
  749.       503 Bad sequence of commands
  750.  
  751.  
  752.  
  753.                                    13
  754.  
  755.  
  756.                                                                         
  757. September 1980                                                   RFC 772
  758. Mail Transfer Protocol                                                  
  759.  
  760.  
  761.  
  762.        
  763.       211 System status, or system help reply
  764.       214 Help message
  765.          [Information on how to use the receiver or the meaning of a
  766.          particular non-standard command; this reply is useful only to
  767.          the human user]
  768.       215 <scheme> is the preferred scheme
  769.        
  770.       120 <host> Service ready in nnn minutes
  771.       220 <host> Service ready for new user
  772.       221 <host> Service closing control connection
  773.       421 <host> Service not available, closing control connection
  774.          [This may be a reply to any command if the service knows it
  775.          must shut down]
  776.        
  777.       151 User not local; will forward to <user>@<host>
  778.       152 User unknown; mail will be forwarded by the operator
  779.       250 Requested mail action okay, completed
  780.       450 Requested mail action not taken: mailbox unavailable
  781.          [E.g., mailbox busy]
  782.       550 Requested action not taken: mailbox unavailable
  783.          [E.g., mailbox not found, no access]
  784.       451 Requested action aborted: local error in processing
  785.       452 Requested action not taken: insufficient system storage space
  786.       552 Requested mail action aborted: exceeded storage allocation
  787.          [For current mailbox location]
  788.       553 Requested action not taken: mailbox name not allowed
  789.       354 Start mail input; end with <CR><LF>.<CR><LF>
  790.       
  791.  
  792.    NUMERIC ORDER LIST OF REPLY CODES
  793.  
  794.       120 <host> Service ready in nnn minutes
  795.       151 User not local; will forward to <user>@<host>
  796.       152 User unknown; mail will be forwarded by the operator
  797.       200 Command okay
  798.       211 System status, or system help reply
  799.       214 Help message
  800.          [Information on how to use the receiver or the meaning of a
  801.          particular non-standard command; this reply is useful only to
  802.          the human user]
  803.       215 <scheme> is the preferred scheme
  804.       220 <host> Service ready for new user
  805.       221 <host> Service closing control connection
  806.       250 Requested mail action okay, completed
  807.       354 Start mail input; end with <CR><LF>.<CR><LF>
  808.  
  809.  
  810.  
  811.                                    14
  812.  
  813.  
  814.                                                                         
  815. RFC 772                                                   September 1980
  816.                                                   Mail Transfer Protocol
  817.  
  818.  
  819.  
  820.       421 <host> Service not available, closing control connection
  821.          [This may be a reply to any command if the service knows it
  822.          must shut down]
  823.       450 Requested mail action not taken: mailbox unavailable
  824.          [E.g., mailbox busy]
  825.       451 Requested action aborted: local error in processing
  826.       452 Requested action not taken: insufficient system storage space
  827.       500 Syntax error, command unrecognized
  828.          [This may include errors such as command line too long]
  829.       501 Syntax error in parameters or arguments
  830.       502 Command not implemented
  831.       503 Bad sequence of commands
  832.       550 Requested action not taken: mailbox unavailable
  833.          [E.g., mailbox not found, no access]
  834.       552 Requested mail action aborted: exceeded storage allocation
  835.          [For current mailbox location]
  836.       553 Requested action not taken: mailbox name not allowed
  837.       
  838.  
  839. DISCUSSION OF MAIL TRANSFER
  840.  
  841.    The basic command for transmitting mail is MAIL.  This command causes
  842.    the transmitted data to be entered into the recipient's mailbox.
  843.  
  844.       MAIL <SP> "FROM:" <sender> [<SP> "TO:" <path>] <CRLF>
  845.  
  846.          <sender> is a mailbox and <path> is a source routing list of
  847.          hosts and destination mailbox.  If accepted, it returns a 354
  848.          reply and considers all succeeding lines to be the message
  849.          text.  It is terminated by a line containing only a period,
  850.          upon which a 250 completion reply is returned.  Various errors
  851.          are possible.
  852.  
  853.    There are two possible preliminary replies that a receiver may use to
  854.    indicate that it is accepting mail for a user whose mailbox is not at
  855.    that receiver.
  856.  
  857.       151 User not local; will forward to <user>@<host>
  858.  
  859.          This reply indicates that the receiver knows the user's mailbox
  860.          is on another host and will take responsibility for forwarding
  861.          the mail to that host.  For example, at BBN (or ISI) there are
  862.          several hosts.  Each has a list of many of the users on the
  863.          hosts.  Each host can accept mail for any user on their list
  864.          and forward it to the correct host.
  865.  
  866.  
  867.  
  868.  
  869.                                    15
  870.  
  871.  
  872.                                                                         
  873. September 1980                                                   RFC 772
  874. Mail Transfer Protocol                                                  
  875.  
  876.  
  877.  
  878.       152 User Unknown; mail will be forwarded by the operator
  879.  
  880.          This reply indicates that the host does not recognize the user
  881.          name, but that it will accept the mail and have the operator
  882.          attempt to deliver it.  This is useful if the user name is
  883.          misspelled, but may be a disservice if the mail is really
  884.          undeliverable.
  885.  
  886.    If forwarding by the operator is unacceptable or if the user would
  887.    prefer to send the mail directly to the recipient's actual host, the
  888.    dialogue may be terminated upon receipt of one of these preliminary
  889.    responses.
  890.  
  891.    There are two MTP commands which allow the text of a message to be
  892.    mailed to several recipients simultaneously; such message
  893.    transmission is far more efficient than the practice of sending the
  894.    text again and again for each additional recipient at a site.  In
  895.    one, all recipients are specified first, and then the text is sent.
  896.    In the other, the order is reversed and the text is sent first,
  897.    followed by the recipients.  Both schemes are necessary because
  898.    neither by itself is optimal for all systems, as will be explained
  899.    later.  To select a particular scheme, the MRSQ command is used; to
  900.    specify recipients after a scheme is chosen, MRCP commands are given;
  901.    and to furnish text, the MAIL command is used.
  902.  
  903.    SCHEME SELECTION:  MRSQ
  904.  
  905.       MRSQ is the means by which a sender-MTP can test for MRSQ/MRCP
  906.       implementation, select a particular scheme, reset its state, and
  907.       even do some rudimentary negotiation.  Its format is as follows:
  908.  
  909.          MRSQ [<SP> <scheme>] <CRLF>
  910.  
  911.          <scheme> is a single character.  The following are defined:
  912.             R  Recipients first.  If this is not implemented, T must be.
  913.             T  Text first.  If this is not implemented, R must be.
  914.             ?  Request for preference.  This must always be implemented.
  915.  
  916.             No argument means a "selection" of none of the schemes (the
  917.             default).
  918.  
  919.          Possible replies are:
  920.             200 OK, we'll use specified scheme
  921.             215 <scheme> This is the scheme I prefer
  922.             501 I understand MRSQ but can't use that scheme
  923.             5xx Command unrecognized or unimplemented
  924.  
  925.  
  926.  
  927.                                    16
  928.  
  929.  
  930.                                                                         
  931. RFC 772                                                   September 1980
  932.                                                   Mail Transfer Protocol
  933.  
  934.  
  935.  
  936.       There are three aspects of MRSQ.  The first is that an MRSQ with
  937.       no argument must always return a 200 reply and restore the default
  938.       state of having no scheme selected.  Any other reply implies that
  939.       MRSQ and hence MRCP are not understood or cannot be performed
  940.       correctly.
  941.  
  942.       The second is that the use of "?" as a <scheme> asks the MTP
  943.       receiver to return a 215 reply in which the receiver specifies a
  944.       "preferred" scheme.  The format of this reply is simple:
  945.  
  946.          215 <SP> <scheme> [<SP> <arbitrary text>] <CRLF>
  947.  
  948.          Any other reply (e.g., 4xx or 5xx) implies that MRSQ and MRCP
  949.          are not implemented, because "?" must always be implemented if
  950.          MRSQ is.
  951.  
  952.       The third important point about MRSQ is that it always has the
  953.       side effect of resetting all schemes to their initial state.  This
  954.       reset must be done no matter what the reply will be -- 200, 215,
  955.       or 501.  The actions necessary for a reset will be explained when
  956.       discussing how each scheme actually works.
  957.  
  958.    MESSAGE TEXT SPECIFICATION:  MAIL
  959.  
  960.       Regardless of which scheme (if any) has been selected, a MAIL
  961.       command with a non-null "TO" argument will behave exactly as
  962.       before; the MRSQ/MRCP commands have no effect on it.  However, a
  963.       normal MAIL command does have the same side effect as MRSQ; it
  964.       "resets" the current scheme to its initial state.
  965.  
  966.       It is only when the "TO" argument is null (e.g., MAIL FROM:<X@Y>
  967.       <CRLF>) that the particular scheme chosen is important.  Rather
  968.       than producing an error (as most receivers currently do), the
  969.       receiver will accept message text for this "null" specification.
  970.       What it does with it depends on which scheme is in effect, and
  971.       will be described in the section on Scheme Mechanics.
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.                                    17
  986.  
  987.  
  988.                                                                         
  989. September 1980                                                   RFC 772
  990. Mail Transfer Protocol                                                  
  991.  
  992.  
  993.  
  994.    RECIPIENT SPECIFICATION:  MRCP
  995.  
  996.       In order to specify recipient names (i.e., mailboxes) and receive
  997.       some acknowledgment (or refusal) for each name, the following
  998.       command is used:
  999.  
  1000.          MRCP <SP> TO:<path> <CRLF>
  1001.  
  1002.          Reply for no scheme:
  1003.             503 No scheme specified yet; use MRSQ
  1004.          Replies for scheme T are identical to those for MAIL.
  1005.          Replies for scheme R (recipients first):
  1006.             200 OK, name stored
  1007.             452 Recipient table full, this name not stored
  1008.             553 Recipient name rejected
  1009.             4xx Temporary error, try this name again later
  1010.             5xx Permanent error, report to sender
  1011.  
  1012.       Note that use of this command is an error if no scheme has been
  1013.       selected yet; an MRSQ <scheme> must have been given if MRCP is to
  1014.       be used.
  1015.  
  1016.    SCHEME MECHANICS:  MRSQ R (RECIPIENTS-FIRST)
  1017.  
  1018.       In the recipients-first scheme, MRCP is used to specify names
  1019.       which the MTP receiver stores in a list or table.  Normally the
  1020.       reply for each MRCP will be either a 200 for acceptance or a
  1021.       4xx/5xx rejection code.  All 5xx codes are permanent rejections
  1022.       (e.g., user not known) which should be reported to the human user,
  1023.       whereas 4xx codes in general connote some temporary error that may
  1024.       be rectified later.  None of the 4xx/5xx replies impinge on
  1025.       previous or succeeding MRCP commands, except for 452 which
  1026.       indicates that no further MRCPs will succeed unless a message is
  1027.       sent to the already stored recipients or a reset is done.
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.                                    18
  1044.  
  1045.  
  1046.                                                                         
  1047. RFC 772                                                   September 1980
  1048.                                                   Mail Transfer Protocol
  1049.  
  1050.  
  1051.  
  1052.       Sending message text to stored recipients is done by giving a MAIL
  1053.       command with no "TO" argument; that is, just MAIL <SP> <sender>
  1054.       <CRLF>.  Transmission of the message text is exactly the same as
  1055.       for normal MAIL.  However, a positive acknowledgment at the end of
  1056.       transmission means the message has been sent to ALL recipients
  1057.       that were remembered with MRCP, and a failure code means that it
  1058.       should be considered to have failed for ALL of these specified
  1059.       recipients.  This applies regardless of the actual error code.
  1060.       Regardless of what the reply signifies, all stored recipient names
  1061.       are flushed and forgotten -- in other words, things are reset to
  1062.       their initial state.  This purging of the recipient name list must
  1063.       also be done as the reset side effect of any use of MRSQ.
  1064.  
  1065.       A 452 reply to an MRCP can be handled by using MAIL to specify the
  1066.       message for currently stored recipients, and then sending more
  1067.       MRCPs and another MAIL, as many times as necessary.  For example,
  1068.       if a receiver only had room for 10 names this would result in a
  1069.       50-recipient message being sent 5 times, to 10 different
  1070.       recipients each time.
  1071.  
  1072.       If a sender attempts to specify message text (MAIL with no "TO"
  1073.       argument) before any successful MRCPs have been given, this should
  1074.       be treated exactly as a "normal" MAIL with a null recipient would
  1075.       be; some receivers return an error, such as "550 Null recipient".
  1076.  
  1077.       See the example in Appendix A for a mail transfer using MRSQ R.
  1078.  
  1079.    SCHEME MECHANICS:  MRSQ T (TEXT-FIRST)
  1080.  
  1081.       In the text-first scheme, MAIL with no "TO" argument is used to
  1082.       specify message text, which the receiver stores away.  Succeeding
  1083.       MRCPs are then treated as if they were MAIL commands, except that
  1084.       none of the text transfer manipulations are done; the stored
  1085.       message text is sent to the specified recipient, and a reply code
  1086.       is returned identical to that which an actual MAIL would invoke.
  1087.       (Note that ANY 2xx code indicates success.)
  1088.  
  1089.       The stored message text is not forgotten until the next MAIL or
  1090.       MRSQ, which will either replace it with new text or flush it
  1091.       entirely.  Any use of MRSQ will reset this scheme by flushing
  1092.       stored text, as will any use of MAIL with a non-null argument.
  1093.  
  1094.       If an MRCP is seen before any message text has been stored, the
  1095.       sender in effect is trying to send a null message; some receivers
  1096.       might allow this, others would return an error code.
  1097.  
  1098.  
  1099.  
  1100.  
  1101.                                    19
  1102.  
  1103.  
  1104.                                                                         
  1105. September 1980                                                   RFC 772
  1106. Mail Transfer Protocol                                                  
  1107.  
  1108.  
  1109.  
  1110.       See the example in Appendix B for a mail transfer using MRSQ T.
  1111.  
  1112.    WHY TWO SCHEMES ANYWAY?
  1113.  
  1114.       Because neither by itself is optimal for all systems.  MRSQ R
  1115.       allows more of a "bulk" mailing because everything is saved up and
  1116.       then mailed simultaneously.  This is very useful for systems such
  1117.       as ITS where the MTP-receiver does not itself write mail directly,
  1118.       but hands it on to a central mailer demon of great power.  The
  1119.       more information (e.g., recipients) associated with a single
  1120.       "hand-off", the more efficiently mail can be delivered.
  1121.  
  1122.       By contrast, MRSQ T is geared to receiver-MTPs which want to
  1123.       deliver mail directly, in one-by-one incremental fashion.  For
  1124.       each given recipient this scheme returns an individual
  1125.       success/failure reply code which may depend on variable mail
  1126.       system factors such as exceeding disk allocation, mailbox access
  1127.       conflicts, and so forth.  If these receiver-MTPs tried to emulate
  1128.       MRSQ Rs bulk mailing, they would have to ensure that a success
  1129.       reply to the MAIL indeed meant that it had been delivered to ALL
  1130.       recipients specified -- not just some.
  1131.  
  1132.    NOTES:
  1133.  
  1134.       * Because these commands are not required in the minimum
  1135.         implementation of MTP, one must be prepared to deal with sites
  1136.         which don't recognize either MRSQ or MRCP.  "MRSQ" and "MRSQ ?"
  1137.         are explicitly designed as tests to see whether either scheme is
  1138.         implemented.  MRCP is not designed as a test, and a failure
  1139.         return of the "unimplemented" variety could be confused with "No
  1140.         scheme selected yet", or even with "Recipient unknown".
  1141.  
  1142.       * There is no way to indicate in a positive response to "MRSQ ?"
  1143.         that the preferred "scheme" for a receiver is that of the
  1144.         default state; i.e., none of the multi-recipient schemes.  The
  1145.         rationale is that in this case, it would be pointless to
  1146.         implement MRSQ/MRCP at all, and the response would therefore be
  1147.         negative.
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.                                    20
  1160.  
  1161.  
  1162.                                                                         
  1163. RFC 772                                                   September 1980
  1164.                                                   Mail Transfer Protocol
  1165.  
  1166.  
  1167.  
  1168.       * One reason that the use of MAIL is restricted to null "TO"
  1169.         arguments with this multi-recipient extension is the ambiguity
  1170.         that would result if a non-null "TO" argument were allowed.  For
  1171.         example, if MRSQ R was in effect and some MRCPs had been given,
  1172.         and a MAIL FROM:<X@Y> TO:<FOO><CRLF> was done, there would be no
  1173.         way to distinguish a failure reply for mailbox "FOO" from a
  1174.         global failure for all recipients specified.  A similar
  1175.         situation exists for MRSQ T; it would not be clear whether the
  1176.         text was stored and the mailbox failed, or vice versa, or both.
  1177.  
  1178.       * "Resets" are done by all MRSQs and "normal" MAILs to avoid
  1179.         confusion and overly complicated implementation.  The MRSQ
  1180.         command implies a change or uncertainty of status, and the MAIL
  1181.         command would otherwise have to use some independent mechanisms
  1182.         to avoid clobbering the data bases (e.g., message text storage
  1183.         area) used by the T/R schemes.  However, once a scheme is
  1184.         selected, it remains "in effect" just as an FTP "TYPE A" remains
  1185.         selected.  The recommended way for doing a reset, without
  1186.         changing the current selection, is with "MRSQ ?".  Remember that
  1187.         "MRSQ" alone reverts to the no-scheme state.
  1188.  
  1189.       * It is permissible to intersperse other MTP commands among the
  1190.         MRSQ/MRCP/MAIL sequences.
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.                                    21
  1218.  
  1219.  
  1220.                                                                         
  1221. September 1980                                                   RFC 772
  1222. Mail Transfer Protocol                                                  
  1223.  
  1224.  
  1225.  
  1226. DECLARATIVE SPECIFICATIONS
  1227.  
  1228.    MINIMUM IMPLEMENTATION
  1229.  
  1230.       In order to make MTP workable without needless error messages, the
  1231.       following minimum implementation is required for all receivers:
  1232.  
  1233.          COMMANDS -- QUIT
  1234.                      MAIL
  1235.                      NOOP
  1236.  
  1237.       In terms of FTP, the values of the transfer parameters must be:
  1238.  
  1239.          TYPE -- ASCII
  1240.          MODE -- STREAM
  1241.          STRU -- FILE-STRUCTURE
  1242.  
  1243.       All hosts must use the above values for mail transfer.
  1244.  
  1245.    CONNECTIONS
  1246.  
  1247.       The receiver-MTP shall "listen" on Port L.  The sender-MTP shall
  1248.       initiate the TCP/NCP control connection.  The control connection
  1249.       consists of a full-duplex connection under TCP; it is two simplex
  1250.       connections under NCP.  Receiver- and sender- MTPs should follow
  1251.       the conventions of the TELNET Protocol as specified in the ARPA
  1252.       Internet Protocol Handbook.  Receivers are under no obligation to
  1253.       provide for editing of command lines and may specify that it be
  1254.       done in the sender host.  The control connection shall be closed
  1255.       by the receiver at the sender's request after all transfers and
  1256.       replies are completed.
  1257.  
  1258.    SEQUENCING OF COMMANDS AND REPLIES
  1259.  
  1260.       The communication between the sender and receiver is intended to
  1261.       be an alternating dialogue.  As such, the sender issues an MTP
  1262.       command and the receiver responds with a prompt primary reply.
  1263.       The sender should wait for this initial primary success or failure
  1264.       response before sending further commands.
  1265.  
  1266.       Certain commands require a second reply for which the sender
  1267.       should also wait.  These replies may, for example, report on the
  1268.       progress or completion of mail transfer.  They are secondary
  1269.       replies to mail transfer commands.
  1270.  
  1271.       One important group of informational replies is the connection
  1272.  
  1273.  
  1274.  
  1275.                                    22
  1276.  
  1277.  
  1278.                                                                         
  1279. RFC 772                                                   September 1980
  1280.                                                   Mail Transfer Protocol
  1281.  
  1282.  
  1283.  
  1284.       greetings.  Under normal circumstances, a receiver will send a 220
  1285.       reply, "awaiting input", when the connection is completed.  The
  1286.       sender should wait for this greeting message before sending any
  1287.       commands.  If the receiver is unable to accept input right away,
  1288.       it should send a 120 "expected delay" reply immediately and a 220
  1289.       reply when ready.  The sender will then know not to hang up if
  1290.       there is a delay.
  1291.  
  1292.          Note: all the greeting type replies have the official name of
  1293.          the server host as the first word following the reply code.
  1294.  
  1295.       The table below lists alternative success and failure replies for
  1296.       each command.  These must be strictly adhered to; a receiver may
  1297.       substitute text in the replies, but the meaning and action implied
  1298.       by the code numbers and by the specific command reply sequence
  1299.       cannot be altered.
  1300.  
  1301.       COMMAND-REPLY SEQUENCES
  1302.  
  1303.          In this section, the command-reply sequence is presented.  Each
  1304.          command is listed with its possible replies; command groups are
  1305.          listed together.  Preliminary replies are listed first (with
  1306.          their succeeding replies indented under them), then positive
  1307.          and negative completion, and finally intermediary replies with
  1308.          the remaining commands from the sequence following.  The 421
  1309.          reply (service not available, closing control connection) may
  1310.          be given at any point if the MTP-receiver knows it must shut
  1311.          down.  This listing forms the basis for the state diagrams,
  1312.          which will be presented separately.
  1313.  
  1314.             CONNECTION ESTABLISHMENT
  1315.                120
  1316.                   220
  1317.                220
  1318.                421
  1319.             MAIL ACTION COMMANDS
  1320.                MAIL
  1321.                   151, 152
  1322.                      354
  1323.                         250
  1324.                         451, 552
  1325.                   354
  1326.                      250
  1327.                      451, 552
  1328.                   450, 550, 452, 553
  1329.                   500, 501, 502, 421
  1330.  
  1331.  
  1332.  
  1333.                                    23
  1334.  
  1335.  
  1336.                                                                         
  1337. September 1980                                                   RFC 772
  1338. Mail Transfer Protocol                                                  
  1339.  
  1340.  
  1341.  
  1342.                MRSQ
  1343.                   200, 215
  1344.                   500, 501, 502, 421
  1345.                MRCP
  1346.                   151, 152
  1347.                      200
  1348.                   200
  1349.                   450, 550, 452, 553
  1350.                   500, 501, 502, 503, 421
  1351.                QUIT
  1352.                   221
  1353.             INFORMATIONAL COMMANDS
  1354.                HELP
  1355.                   211, 214
  1356.                   500, 501, 502, 421
  1357.             MISCELLANEOUS COMMANDS
  1358.                NOOP
  1359.                   200
  1360.                   500 421
  1361.  
  1362. STATE DIAGRAMS
  1363.  
  1364.    Here we present state diagrams for a very simple minded MTP
  1365.    implementation.  Only the first digit of the reply codes is used.
  1366.    There is one state diagram for each group of MTP commands.
  1367.  
  1368.    The command groupings were determined by constructing a model for
  1369.    each command and then collecting together the commands with
  1370.    structurally identical models.
  1371.  
  1372.    For each command there are three possible outcomes:  "success" (S),
  1373.    "failure" (F), and "error" (E). In the state diagrams below we use
  1374.    the symbol B for "begin", and the symbol W for "wait for reply".
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.                                    24
  1392.  
  1393.  
  1394.                                                                         
  1395. RFC 772                                                   September 1980
  1396.                                                   Mail Transfer Protocol
  1397.  
  1398.  
  1399.  
  1400.    We first present the diagram that represents the most MTP commands:
  1401.  
  1402.       
  1403.                                1,3    +---+
  1404.                           ----------->| E |
  1405.                          |            +---+
  1406.                          |
  1407.       +---+    cmd    +---+    2      +---+
  1408.       | B |---------->| W |---------->| S |
  1409.       +---+           +---+           +---+
  1410.                          |
  1411.                          |     4,5    +---+
  1412.                           ----------->| F |
  1413.                                       +---+
  1414.       
  1415.  
  1416.       This diagram models the commands:
  1417.  
  1418.          HELP, MRCP, MRSQ, NOOP, QUIT.
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.                                    25
  1450.  
  1451.  
  1452.                                                                         
  1453. September 1980                                                   RFC 772
  1454. Mail Transfer Protocol                                                  
  1455.  
  1456.  
  1457.  
  1458.    A more complex diagram models the MAIL command:
  1459.  
  1460.       
  1461.                    ----  1
  1462.                   |    |
  1463.       +---+  cmd   -->+---+     2     +---+
  1464.       | B |---------->| W |---------->| E |
  1465.       +---+           +---+        -->+---+
  1466.                        | |        |
  1467.                 3      | | 4,5    |
  1468.          --------------  ------   |
  1469.         |                      |  |   +---+
  1470.         |               ------------->| S |
  1471.         |              |   1,3 |  |   +---+
  1472.         |             2|  --------
  1473.         |              | |     |
  1474.         V              | |     |
  1475.       +---+   text    +---+ 4,5 ----->+---+
  1476.       |   |---------->| W |---------->| F |
  1477.       +---+           +---+           +---+
  1478.       
  1479.  
  1480.       Note that the "text" here is a series of lines sent from the
  1481.       sender to the receiver with no response expected until the last
  1482.       line is sent.  (The last line must consist of only a single
  1483.       period.)
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.                                    26
  1508.  
  1509.  
  1510.                                                                         
  1511. RFC 772                                                   September 1980
  1512.                                                   Mail Transfer Protocol
  1513.  
  1514.  
  1515.  
  1516.    Finally we present a generalized diagram that could be used to model
  1517.    the command and reply interchange:
  1518.  
  1519.       
  1520.                ------------------------------------
  1521.               |                                    |
  1522.       Begin   |                                    |
  1523.         |     V                                    |
  1524.         |   +---+  cmd   +---+ 2         +---+     |
  1525.          -->|   |------->|   |---------->|   |     |
  1526.             |   |        | W |           | S |-----|
  1527.          -->|   |     -->|   |-----      |   |     |
  1528.         |   +---+    |   +---+ 4,5 |     +---+     |
  1529.         |     |      |    | |      |               |
  1530.         |     |      |   1| |3     |     +---+     |
  1531.         |     |      |    | |      |     |   |     |
  1532.         |     |       ----  |       ---->| F |-----
  1533.         |     |             |            |   |
  1534.         |     |             |            +---+
  1535.          -------------------
  1536.               |
  1537.               |
  1538.               V
  1539.              End
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.                                    27
  1566.  
  1567.  
  1568.                                                                         
  1569. September 1980                                                   RFC 772
  1570. Mail Transfer Protocol                                                  
  1571.  
  1572.  
  1573.  
  1574. CONNECTION ESTABLISHMENT
  1575.  
  1576.    The MTP control connection is established via TCP/NCP between the
  1577.    receiver process port/socket L and the sender process port/socket U.
  1578.    This protocol is assigned the service port/socket 57 (71 octal), that
  1579.    is L=57.
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.                                    28
  1624.  
  1625.  
  1626.                                                                         
  1627. RFC 772                                                   September 1980
  1628.                                                   Mail Transfer Protocol
  1629.  
  1630.  
  1631.  
  1632. APPENDIX A
  1633.  
  1634.                   Example of MRSQ R (Recipients-first)
  1635.  
  1636.    This is an example of how MRSQ R is used.  First the sender must
  1637.    establish that the receiver in fact implements MRSQ.
  1638.  
  1639.       S: MRSQ <CRLF>
  1640.       R: 200 OK, no scheme selected
  1641.  
  1642.    An MRSQ with a null argument always returns a 200 if implemented,
  1643.    selecting the default "scheme", i.e., none of them.  If MRSQ were not
  1644.    implemented, a code of 4xx or 5xx would be returned.
  1645.  
  1646.       S: MRSQ R <CRLF>
  1647.       R: 200 OK, using that scheme
  1648.  
  1649.    All is well; now the recipients can be specified.
  1650.  
  1651.       S: MRCP TO:<Foo@Y> <CRLF>
  1652.       R: 200 OK
  1653.  
  1654.       S: MRCP TO:<Raboof@Y> <CRLF>
  1655.       R: 553  No such user here
  1656.  
  1657.       S: MRCP TO:<bar@Y> <CRLF>
  1658.       R: 200 OK
  1659.  
  1660.       S: MRCP TO:<@Y,@X,fubar@Z> <CRLF>
  1661.       R: 200 OK
  1662.  
  1663.    Note that the failure of "Raboof" has no effect on the storage of
  1664.    mail for "Foo", "bar" or the mail to be forwarded to "fubar@Z"
  1665.    through host "X".  Now the message text is furnished, by giving a
  1666.    MAIL command with no "TO" argument.
  1667.  
  1668.       S: MAIL FROM:<waldo@A><CRLF>
  1669.       R: 354 Type mail, ended by <CRLF>.<CRLF>
  1670.       S: Blah blah blah blah....etc. etc. etc.
  1671.       S: <CRLF>.<CRLF>
  1672.       R: 250 Mail sent
  1673.  
  1674.    The mail text has now been sent to "Foo" and "bar" as well as
  1675.    forwarded to "fubar@Z".
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.                                    29
  1682.  
  1683.  
  1684.                                                                         
  1685. September 1980                                                   RFC 772
  1686. Mail Transfer Protocol                                                  
  1687.  
  1688.  
  1689.  
  1690. APPENDIX B
  1691.  
  1692.                      Example of MRSQ T (Text-first)
  1693.  
  1694.    Using the same message as the previous example to establish that the
  1695.    receiver implements MRSQ.
  1696.  
  1697.       S: MRSQ ? <CRLF>
  1698.       R: 215 T Text first, please
  1699.  
  1700.    MRSQ is indeed implemented, and the receiver says that it prefers
  1701.    "T", but that needn't stop the sender from trying something else.
  1702.  
  1703.       S: MRSQ R <CRLF>
  1704.       R: 501 Sorry, I really can't do that
  1705.  
  1706.    It's possible that it could have understood "R" also, but in general
  1707.    it's best to use the "preferred" scheme, since the receiver knows
  1708.    which is most efficient for its particular site.
  1709.  
  1710.       S: MRSQ T <CRLF>
  1711.       R: 200 OK, using that scheme
  1712.  
  1713.    Scheme "T" is now selected, and the message text is sent by giving a
  1714.    mail command with no "TO" argument.
  1715.  
  1716.       S: MAIL FROM:<WALDO@A><CRLF>
  1717.       R: 354 Type mail, ended by <CRLF>.<CRLF>
  1718.       S: Blah blah blah blah....etc. etc. etc.
  1719.       S: <CRLF>.<CRLF>
  1720.       R: 250 Mail stored
  1721.  
  1722.    Now recipients can be specified.
  1723.  
  1724.       S: MRCP TO:<Foo@Y> <CRLF>
  1725.       R: 250 Stored mail sent
  1726.  
  1727.       S: MRCP TO:<Raboof@Y> <CRLF>
  1728.       R: 553  No such user here
  1729.  
  1730.       S: MRCP TO:<bar@Y> <CRLF>
  1731.       R: 250 Stored mail sent
  1732.  
  1733.       S: MRCP TO:<@Y,@X,fubar@Z> <CRLF>
  1734.       R: 200 OK
  1735.  
  1736.  
  1737.  
  1738.  
  1739.                                    30
  1740.  
  1741.  
  1742.                                                                         
  1743. RFC 772                                                   September 1980
  1744.                                                   Mail Transfer Protocol
  1745.  
  1746.  
  1747.  
  1748.    The text has now been sent to "Foo" and "bar" at host "Y" and will be
  1749.    forwarded to "fubar@Z" through host "X", and still remains stored.  A
  1750.    new message can be sent with another MAIL/MRCP ... sequence, but a
  1751.    careful sender would reset the state using the exchange below.
  1752.  
  1753.       S: MRSQ ? <CRLF>
  1754.       R: 215 T Text first, please
  1755.  
  1756.    Which resets the state without altering the scheme in effect.
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.                                    31
  1798.