Connected: An Internet Encyclopedia
4.4. STATE DIAGRAMS

Up: Connected: An Internet Encyclopedia
Up: RFC 821
Up: 4. THE SMTP SPECIFICATIONS
Prev: 4.3. SEQUENCING OF COMMANDS AND REPLIES
Next: 4.5. DETAILS

### 4.4. STATE DIAGRAMS

4.4. STATE DIAGRAMS

Following are state diagrams for a simple-minded SMTP implementation. Only the first digit of the reply codes is used. There is one state diagram for each group of SMTP commands. The command groupings were determined by constructing a model for each command and then collecting together the commands with structurally identical models.

For each command there are three possible outcomes: "success" (S), "failure" (F), and "error" (E). In the state diagrams below we use the symbol B for "begin", and the symbol W for "wait for reply".

First, the diagram that represents most of the SMTP commands:

```
1,3    +---+
----------->| E |
|            +---+
|
+---+    cmd    +---+    2      +---+
| B |---------->| W |---------->| S |
+---+           +---+           +---+
|
|     4,5    +---+
----------->| F |
+---+

```

This diagram models the commands:

```            HELO, MAIL, RCPT, RSET, SEND, SOML, SAML, VRFY, EXPN, HELP,
NOOP, QUIT, TURN.
```

A more complex diagram models the DATA command:

```
+---+   DATA    +---+ 1,2                 +---+
| B |---------->| W |-------------------->| E |
+---+           +---+        ------------>+---+
3| |4,5     |
| |        |
--------------   -----   |
|                      |  |             +---+
|               ----------     -------->| S |
|              |       |      |         +---+
|              |  ------------
|              | |     |
V           1,3| |2    |
+---+   data    +---+     --------------->+---+
|   |---------->| W |                     | F |
+---+           +---+-------------------->+---+
4,5
```

Note that the "data" here is a series of lines sent from the sender to the receiver with no response expected until the last line is sent.

Next: 4.5. DETAILS

Connected: An Internet Encyclopedia
4.4. STATE DIAGRAMS