summaryrefslogtreecommitdiff
path: root/doc/rfc/rfc772.txt
blob: bd6fdefbc2efdc1bfed8cc4ad6c67d20e934aa2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
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
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
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
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
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
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
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
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
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
1798
Network Working Group                                         S. Sluizer
Request for Comments: 772                                      J. Postel
                                                                     ISI
                                                          September 1980

                         MAIL TRANSFER PROTOCOL


PREFACE

   This is a first draft of this protocol and comments are very
   definitely requested.

INTRODUCTION

   The objective of Mail Transfer Protocol (MTP) is to transfer mail
   reliably and efficiently.

   This paper assumes knowledge of the following protocols described in
   the ARPA Internet Protocol Handbook.  The reader will note strong
   similarities to portions of the File Transfer Protocol; in part, this
   is due to the original ARPA Network implementation of computer mail
   as a feature of FTP.

      The ARPANET Host-to-Host Protocol [Network Control Protocol] (NCP)

      The Transmission Control Protocol (TCP)

      The TELNET Protocol (TELNET)

      The File Transfer Protocol (FTP)

DISCUSSION

   In this section, the terminology and the MTP model are discussed.
   The terms defined in this section are only those that have special
   significance in MTP.  Some of the terminology is very specific to the
   MTP model; some readers may wish to turn to the section on the MTP
   model while reviewing the terminology.

   TERMINOLOGY

      ASCII

         The ASCII character set as defined in the ARPA Internet
         Protocol Handbook.  In MTP, ASCII characters are defined to be
         the lower half of an eight-bit code set (i.e., the most
         significant bit is zero) and is called NVT-ASCII.






                                   1
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



      control connection

         The TCP full-duplex communication path or two NCP simplex
         communication paths between a sender-MTP and a receiver-MTP for
         the exchange of commands, replies, and mail text.  The control
         connection operates according to the TELNET Protocol.

      data mode

         The mail is transmitted over the control connection as a stream
         of octets.  (In FTP terminology this is called stream mode.)

      data structure

         The internal structure of mail is considered to be a continuous
         sequence of data octets.  (In FTP terminology this is called
         file-structure.)

      data representation

         The internal representation of all data (i.e., mail) is in
         NVT-ASCII.

      host

         A computer in the internetwork environment on which mailboxes
         reside.

      MTP commands

         A set of commands which comprise the control information
         flowing from the sender-MTP to the receiver-MTP.

      mail

         An ordered set of computer data of arbitrary length, which
         conforms to the standard set in RFC 733 (Standard for the
         Format of ARPA Network Text Messages).

      mailbox

         A character string (address) which identifies a user to whom
         mail is to be sent.  Mailbox normally consists of the host and
         user specifications.  The standard mailbox naming convention is
         defined to be "user@host".  Additionally, the "container" in
         which mail is stored.



                                   2
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



      NVT

         The Network Virtual Terminal as defined in the TELNET Protocol.

      octet

         Bytes in MTP are octets (8 bits).  This is not necessarily the
         same byte size in which data is stored in a host.

      reply

         A reply is an acknowledgment (positive or negative) sent from
         receiver to sender via the control connection in response to a
         MTP command.  The general form of a reply is a completion code
         (including error codes) followed by a text string.  The codes
         are for use by programs and the text is usually intended for
         human users.

      receiver-MTP process

         A process which transfers mail in cooperation with a sender-MTP
         process.  It "listens" on its port/socket L for a connection
         from a sender-MTP and establishes a control connection using
         the TELNET Protocol.  It receives MTP commands from the
         sender-MTP, sends replies, and governs the transfer of mail.

      sender-MTP process

         A process which transfers mail in cooperation with a
         receiver-MTP process.  A local language may be used in the user
         interface command/reply dialogue.  The sender-MTP initiates the
         control connection from its port/socket U to the receiver-MTP
         process.  It initiates MTP commands, receives replies, and
         governs the transfer of mail.

      user

         A human being (or a process on behalf of a human being) wishing
         to obtain mail transfer service.  In addition, a recipient of
         computer mail.









                                   3
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



   THE MTP MODEL

      With the above definitions in mind, the following model (shown in
      Figure 1) may be diagrammed for an MTP service.

                  ------------                ------------
                  |          |                |          |    --------
                  |          |      MTP       |          |<-->| User |
                  | Receiver-|Commands/Replies|  Sender- |    --------
      --------    |   MTP    |<-------------->|    MTP   |    --------
      | Mail |<-->|          |      Mail      |          |<-->| Mail |
      |System|    |          |                |          |    |System|
      --------    ------------                ------------    --------
      

                  Receiver-MTP                 Sender-MTP

                           Model for MTP Use

                                Figure 1

      In the model described in Figure 1, the sender-MTP initiates the
      TCP/NCP control connection which follows the TELNET Protocol.  At
      the initiation of the user, standard MTP commands are generated by
      the sender-MTP and transmitted to the receiver-MTP via the control
      connection.  Standard replies are sent from the receiver-MTP to
      the sender-MTP over the control connection in response to the
      commands.  In addition, mail is sent over the control connection.

MAIL TRANSFER FUNCTIONS

   The control connection is used for the transfer of commands which
   describe the functions to be performed, the replies to commands, as
   well as the actual transfer of mail.  Mail is transferred only via
   the control connection.

   The communication channel from the sender-MTP to the receiver-MTP is
   established by a TCP/NCP control connection from the sender to a
   standard receiver port/socket.  The sender-MTP is responsible for
   sending MTP commands, interpreting the replies received, and sending
   the mail; the receiver-MTP interprets commands, sends replies, and
   receives the mail.







                                   4
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



   MAIL REPRESENTATION AND STORAGE

      Mail is transferred from a storage device in the sending host to a
      storage device in the receiving host.  It may be necessary to
      perform certain transformations on the mail because data storage
      representations in the two systems are different.  For example,
      NVT-ASCII has different data storage representations in different
      systems.  PDP-10's generally store NVT-ASCII as five 7-bit ASCII
      characters, left-justified in a 36-bit word.  360's store
      NVT-ASCII as four 8-bit EBCDIC codes in a 32-bit word.  Multics
      stores NVT-ASCII as four 9-bit characters in a 36-bit word.

      For the sake of simplicity, all data must be represented in MTP as
      NVT-ASCII.  This means that characters must be converted into the
      standard NVT-ASCII representation when transmitting text,
      regardless of whether the sending and receiving hosts are
      dissimilar.  The sender converts the data from its internal
      character representation to the standard 8-bit NVT-ASCII
      representation (see the TELNET specification).  The receiver
      converts the data from the standard form to its own internal form.
      In accordance with this standard, the <CRLF> sequence should be
      used to denote the end of a line of text.

      The mail in MTP has no internal structure and is considered to be
      a continuous sequence of data octets.

   ERROR RECOVERY AND RESTART

      There is no provision for detecting bits lost or scrambled in data
      transfer; this level of error control is handled by the TCP/NCP.
      In addition, there is no restart procedure provided to protect
      senders from gross system failures (including failures of a host,
      an MTP-process, or the underlying network).

MTP COMMANDS

   COMMAND SEMANTICS

      The MTP commands define the mail transfer or the mail system
      function requested by the user.  The syntax of mailboxes must
      conform to receiver site conventions (with standard defaults
      applicable).  In response to an MTP transfer command, the mail
      shall always be transferred over the control connection.

      The Mail Transfer Protocol follows the specifications of the
      TELNET Protocol for all communications over the control



                                   5
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



      connection.  Although the language used for TELNET communication
      can be a negotiated option, the "TELNET language" and the
      corresponding "TELNET end of line code" are required to be
      NVT-ASCII and <CRLF> respectively.  No other specifications of the
      TELNET Protocol will be cited.

      MTP commands are NVT-ASCII strings terminated by <CRLF>.  The
      command codes themselves are alphabetic characters terminated by
      the character <SP> (space) if parameters follow and <CRLF>
      otherwise.

      The MTP commands are discussed below.  In the description of a few
      of the commands in this section the possible replies are given
      explicitly.  MTP replies are discussed in the next section.

         MAIL (MAIL)

            This command allows a sender-MTP to send mail over the
            control connection.  The argument field contains a sender
            and optional path sequence.  If the path sequence is
            present, it consists of an optional list of hosts and a
            destination mailbox.  When the list of hosts is present, it
            is source routing information and indicates that the mail
            must be forwarded to the first host on the list.  Following
            this command line the receiver treats all subsequent
            characters as mail text from the sender.  The mail text is
            terminated by the character sequence "CRLF.CRLF".

            As mail is forwarded along the path sequence, each
            forwarding host must remove itself from the list.  When mail
            reaches its ultimate destination (the path sequence has only
            a (possibly empty) destination mailbox), the receiver
            inserts it into the destination mailbox in accordance with
            its host mail conventions.  If the second argument field is
            blank (one or more spaces) or empty (<CRLF>), the mail is
            destined for a printer or other designated place for site
            general delivery mail.  The mail may be marked as sent from
            the sender as specified by the first argument field.

         MAIL RECIPIENT SCHEME QUESTION (MRSQ)

            This MTP command is used to select a scheme for the
            transmission of mail to several users at the same host.  The
            schemes are to list the recipients first, or to send the
            mail first.




                                   6
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



         MAIL RECIPIENT (MRCP)

            This command is used to identify the individual recipients
            of the mail in the transmission of mail for multiple users
            at one host.

         HELP (HELP)

            This command causes the receiver to send helpful information
            regarding its implementation status over the control
            connection to the receiver.  The command may take an
            argument (e.g., any command name) and return more specific
            information as a response.  The reply is type 211 or 214.

         QUIT (QUIT)

            This command specifies that the receiver must close the
            control connection.

         NOOP (NOOP)

            This command does not affect any parameters or previously
            entered commands.  It specifies no action other than that
            the receiver send an OK reply.

   COMMAND SYNTAX

      The commands (and their functions and semantics) are TELNET
      NVT-ASCII strings transmitted over the control connection.  The
      functions and semantics of commands are described in the section
      on MTP Commands.  The reply sequences are discussed in the section
      on Sequencing of Commands and Replies.  Scenarios illustrating the
      use of commands are provided in the section on Typical MTP
      Scenarios.  The command syntax is specified in this section.

      The commands begin with a command code followed by an argument
      field.  The command codes are four alphabetic characters.  Upper
      and lower case alphabetic characters are to be treated
      identically.  Thus any of the following may represent the mail
      command:

         MAIL    Mail    mail    MaIl    mAIl

      This also applies to any symbols representing parameter values,
      such as R or r for RECIPIENT first.  The command codes and the
      argument fields are separated by one or more spaces.



                                   7
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



      The argument field consists of a variable length character string
      ending with the character sequence <CRLF>.  It should be noted
      that the receiver is to take no action until the end of line code
      is received.

      The syntax is specified below in NVT-ASCII.  All characters in the
      argument field are ASCII characters.  Square brackets denote an
      optional argument field.  If the option is not taken, the
      appropriate default is implied.

      The following are the MTP commands:

         MAIL <SP> FROM:<sender> [<SP> TO:<path>] <CRLF>

         MRSQ [<SP> <scheme>] <CRLF>

         MRCP <SP> TO:<path> <CRLF>

         HELP [<SP> <string>] <CRLF>

         QUIT <CRLF>

         NOOP <CRLF>

      The syntax of the above argument fields (using BNF notation where
      applicable) is given below.  The "..." notation indicates that a
      field may be repeated one or more times.

         <sender> ::= "<" <mailbox> ">"

         <path> ::= "<" ["@" <host> "," ...] <mailbox> ">"

         <scheme> ::= "R" | "T" | "?"

         <string> ::= <char> | <char><string>

         <mailbox> ::= <user> "@" <host>

         <host> ::= <string>

         <user> ::= <string>

         <char> ::= any of the 128 ASCII characters except <CR> and <LF>






                                   8
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



   CONTROL FUNCTIONS

      Most time-sharing systems provide mechanisms to allow a terminal
      user to regain control of a "runaway" process.  When used locally,
      such systems have access to all user-supplied signals, whether
      these are normal characters or special "out of band" signals.
      When terminals are connected to the system through the network,
      the system does not necessarily have access to all user signals;
      the network's flow control mechanisms may cause such signals to be
      buffered elsewhere, for example in the user's host.

      To counter this problem, the TELNET "Synch" mechanism is used.  A
      Synch signal consists of a TCP Urgent or an NCP Interrupt
      notification, coupled with the TELNET command DATA MARK (DM).
      This notification, which is not subject to the flow control
      pertaining to the TELNET connection, is used to invoke special
      handling of the data stream by the process which receives it.  In
      this mode the data stream is immediately scanned for a TELNET
      Interrupt Process (IP) command.  (The rationale for the use of the
      TELNET IP command is to allow an existing server TELNET module to
      sit "under" the MTP.  If this code were directly implemented in
      the MTP the IP command would be unnecessary.)  The TELNET command
      DM is the synchronizing mark in the data stream which indicates
      that any special signal has already occurred and the recipient can
      return to normal processing of the data stream.  For a more
      complete understanding of this mechanism, see the TELNET Protocol
      Specification in the Internet Protocol Handbook.

      The effect of this mechanism is to to discard all characters (up
      to the DM) between the sender of the Synch and its recipeint.
      Thus, all characters in the control connection are ignored until
      the TELNET command DM is received.  The full sequence is
      illustrated below.  Each vertical bar (|) represents the boundary
      between data octets; IAC refers to the TELNET command code
      Interpret As Command.

                       Old                       New
                    -+-+-+-+-+-----+---+--+---+--+-  
                  ...|M|A|I|L| ... |IAC|IP|IAC|DM|...
                    -+-+-+-+-+-----+---+--+---+--+-  









                                   9
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



MTP REPLIES

   Replies to Mail Transfer Protocol commands are devised to ensure the
   synchronization of requests and actions in the process of mail
   transfer, and to guarantee that the sender-MTP always knows the state
   of the receiver.  Every command must generate at least one reply,
   although there may be more than one.  In the latter case, the
   multiple replies must be easily distinguished.  Additionally, some
   commands must occur sequentially, such as MRSQ T->MAIL->MRCP or
   MRSQ R->MRCP->MAIL.  Replies to these sequences show the existence of
   an intermediate state if all preceding commands have been successful.
   A failure at any point in the sequence necessitates the repetition of
   the entire sequence from the beginning.

      The details of the command-reply sequence are made explicit in the
      section on State Diagrams.

   An MTP reply consists of a three digit number (transmitted as three
   alphanumeric characters) followed by some text.  The number is
   intended for use by automata to determine what state to enter next;
   the text is meant for the human user.  It is intended that the three
   digits contain enough encoded information that the sender-MTP will
   not need to examine the text and may either discard it or pass it on
   to the user, as appropriate.  In particular, the text may be
   receiver-dependent, so there are likely to be varying texts for each
   reply code.

   Formally, a reply is defined to be the sequence:  a three-digit code,
   space <SP>, one line of text (where the maximum line length is 65),
   and a terminal <CRLF>.  Occasionally the text is longer than a single
   line; in these cases the complete text must be bracketed so the
   sender-MTP knows when it can stop reading the reply.  This requires a
   special first line format to indicate a multiple line reply, and
   another on the last line to so designate it.  Both lines will contain
   the appropriate reply code which indicates the transaction state.

      Thus the format for multi-line replies is that the first line will
      begin with the exact required reply code, followed immediately by
      a Hyphen, "-" (also known as minus), followed by text.  The last
      line will begin with the same code, followed immediately by space
      <SP>, optionally some text, and <CRLF>.








                                   10
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



         For example:
                                123-First line
                                Second line
                                  234 A line beginning with numbers
                                123 The last line

      The sender-MTP then simply needs to search for the second
      occurrence of the same reply code followed by <SP> (space> at the
      beginning of a line, and ignore all intermediary lines.  If an
      intermediary line begins with a three-digit number, the receiver
      must pad the front to avoid confusion.

         This scheme allows standard system routines to be used for
         reply information, with "artificial" first and last lines
         tacked on.  In the rare cases where these routines are able to
         generate three digits and a space at the beginning of any line,
         the beginning of each text line should be offset by some
         neutral text, like space.

      This scheme assumes that multi-line replies may not be nested.  In
      general, reply nesting will not occur except for random system
      messages (also called spontaneous replies) which may interrupt
      another reply.  System messages (i.e., those not processed by the
      receiver-MTP) will NOT carry reply codes and may occur anywhere in
      the command-reply sequence.  They may be ignored by the sender-MTP
      as they are only information for the human user.

   The three digits of the reply each have a special significance.  This
   is intended to allow a range of very simple to very sophisticated
   response by the sender-MTP.  The first digit denotes whether the
   response is good, bad or incomplete.  (Referring to the state
   diagram) an unsophisticated sender-MTP will be able to determine its
   next action (proceed as planned, redo, retrench, etc.) by simply
   examining this first digit.  A sender-MTP that wants to know
   approximately what kind of error occurred (e.g., mail system error,
   command syntax error) may examine the second digit, reserving the
   third digit for the finest gradation of information.

      There are five values for the first digit of the reply code:

         1yz   Positive Preliminary reply

            The requested action is being initiated; expect another
            reply before proceeding with a new command.  (The sender-MTP
            sending another command before the completion reply would be




                                   11
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



            in violation of protocol.  However, receiver-MTP processes
            should queue any commands that arrive while a preceding
            command is in progress.)

         2yz   Positive Completion reply

            The requested action has been successfully completed.  A new
            request may be initiated.

         3yz   Positive Intermediate reply

            The command has been accepted, but the requested action is
            being held in abeyance, pending receipt of further
            information.  The sender-MTP should send another command
            specifying this information.  This reply is used in command
            sequence groups.

         4yz   Transient Negative Completion reply

            The command was not accepted and the requested action did
            not occur.  However, the error condition is temporary and
            the action may be requested again.  The sender should return
            to the beginning of the command sequence (if any).  It is
            difficult to assign a meaning to "transient" when two
            different sites (receiver- and sender- MTPs) must agree on
            the interpretation.  Each reply in this category might have
            a different time value, but the sender-MTP is encouraged to
            try again.  A rule of thumb to determine if a reply fits
            into the 4yz or the 5yz category (see below) is that replies
            are 4yz if they can be repeated without any change in
            command form or in properties of the sender or receiver.
            (E.g., the command is repeated identically; the receiver
            does not put up a new implementation).

         5yz   Permanent Negative Completion reply

            The command was not accepted and the requested action did
            not occur.  The sender-MTP is discouraged from repeating the
            exact request (in the same sequence).  Even some "permanent"
            error conditions can be corrected, so the human user may
            want to direct the sender-MTP to reinitiate the command
            sequence by direct action at some point in the future (e.g.,
            after the spelling has been changed, or the user has altered
            his/her directory status.)





                                   12
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



      The second digit encodes responses in specific categories:

         x0z   Syntax -- These replies refer to syntax errors,
               syntactically correct commands that don't fit any
               functional category, and unimplemented or superfluous
               commands.

         x1z   Information --  These are replies to requests for
               information, such as status or help.

         x2z   Connections -- These are replies referring to the control
               connection.

         x3z   Unspecified as yet.

         x4z   Unspecified as yet.

         x5z   Mail system -- These replies indicate the status of the
               receiver mail system vis-a-vis the requested transfer or
               other mail system action.

      The third digit gives a finer gradation of meaning in each
      category specified by the second digit.  The list of replies below
      will illustrate this.  Each reply text is recommended rather than
      mandatory, and may even change according to the command with which
      it is associated.  On the other hand, the reply codes must
      strictly follow the specifications in this section.  Receiver
      implementations should not invent new codes for slightly different
      situations from the ones described here, but rather adapt codes
      already defined.

         A command such as NOOP whose successful execution does not
         offer the sender-MTP any new information will return a 200
         reply.  The response is 502 when the command requests an
         unimplemented non-site-specific action.  A refinement of that
         is the 504 reply for a command that IS implemented, but that
         requests an unimplemented parameter.

   REPLY CODES BY FUNCTION GROUPS

      200 Command okay
      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



                                   13
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



       
      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 control connection
      421 <host> Service not available, closing control connection
         [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 space
      552 Requested mail action aborted: exceeded storage allocation
         [For current mailbox location]
      553 Requested action not taken: mailbox name not allowed
      354 Start mail input; end with <CR><LF>.<CR><LF>
      

   NUMERIC ORDER LIST OF REPLY CODES

      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
      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 control connection
      250 Requested mail action okay, completed
      354 Start mail input; end with <CR><LF>.<CR><LF>



                                   14
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



      421 <host> Service not available, closing control connection
         [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 space
      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
      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
      

DISCUSSION OF MAIL TRANSFER

   The basic command for transmitting mail is MAIL.  This command causes
   the transmitted data to be entered into the recipient's mailbox.

      MAIL <SP> "FROM:" <sender> [<SP> "TO:" <path>] <CRLF>

         <sender> is a mailbox and <path> is a source routing list of
         hosts and destination mailbox.  If accepted, it returns a 354
         reply and considers all succeeding lines to be the message
         text.  It is terminated by a line containing only a period,
         upon which a 250 completion reply is returned.  Various errors
         are possible.

   There are two possible preliminary replies that a receiver may use to
   indicate that it is accepting mail for a user whose mailbox is not at
   that receiver.

      151 User not local; will forward to <user>@<host>

         This reply indicates that the receiver knows the user's mailbox
         is on another host and will take responsibility for forwarding
         the mail to that host.  For example, at BBN (or ISI) there are
         several hosts.  Each has a list of many of the users on the
         hosts.  Each host can accept mail for any user on their list
         and forward it to the correct host.




                                   15
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



      152 User Unknown; mail will be forwarded by the operator

         This reply indicates that the host does not recognize the user
         name, but that it will accept the mail and have the operator
         attempt to deliver it.  This is useful if the user name is
         misspelled, but may be a disservice if the mail is really
         undeliverable.

   If forwarding by the operator is unacceptable or if the user would
   prefer to send the mail directly to the recipient's actual host, the
   dialogue may be terminated upon receipt of one of these preliminary
   responses.

   There are two MTP commands which allow the text of a message to be
   mailed to several recipients simultaneously; such message
   transmission is far more efficient than the practice of sending the
   text again and again for each additional recipient at a site.  In
   one, all recipients are specified first, and then the text is sent.
   In the other, the order is reversed and the text is sent first,
   followed by the recipients.  Both schemes are necessary because
   neither by itself is optimal for all systems, as will be explained
   later.  To select a particular scheme, the MRSQ command is used; to
   specify recipients after a scheme is chosen, MRCP commands are given;
   and to furnish text, the MAIL command is used.

   SCHEME SELECTION:  MRSQ

      MRSQ is the means by which a sender-MTP can test for MRSQ/MRCP
      implementation, select a particular scheme, reset its state, and
      even do some rudimentary negotiation.  Its format is as follows:

         MRSQ [<SP> <scheme>] <CRLF>

         <scheme> is a single character.  The following are defined:
            R  Recipients first.  If this is not implemented, T must be.
            T  Text first.  If this is not implemented, R must be.
            ?  Request for preference.  This must always be implemented.

            No argument means a "selection" of none of the schemes (the
            default).

         Possible replies are:
            200 OK, we'll use specified scheme
            215 <scheme> This is the scheme I prefer
            501 I understand MRSQ but can't use that scheme
            5xx Command unrecognized or unimplemented



                                   16
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



      There are three aspects of MRSQ.  The first is that an MRSQ with
      no argument must always return a 200 reply and restore the default
      state of having no scheme selected.  Any other reply implies that
      MRSQ and hence MRCP are not understood or cannot be performed
      correctly.

      The second is that the use of "?" as a <scheme> asks the MTP
      receiver to return a 215 reply in which the receiver specifies a
      "preferred" scheme.  The format of this reply is simple:

         215 <SP> <scheme> [<SP> <arbitrary text>] <CRLF>

         Any other reply (e.g., 4xx or 5xx) implies that MRSQ and MRCP
         are not implemented, because "?" must always be implemented if
         MRSQ is.

      The third important point about MRSQ is that it always has the
      side effect of resetting all schemes to their initial state.  This
      reset must be done no matter what the reply will be -- 200, 215,
      or 501.  The actions necessary for a reset will be explained when
      discussing how each scheme actually works.

   MESSAGE TEXT SPECIFICATION:  MAIL

      Regardless of which scheme (if any) has been selected, a MAIL
      command with a non-null "TO" argument will behave exactly as
      before; the MRSQ/MRCP commands have no effect on it.  However, a
      normal MAIL command does have the same side effect as MRSQ; it
      "resets" the current scheme to its initial state.

      It is only when the "TO" argument is null (e.g., MAIL FROM:<X@Y>
      <CRLF>) that the particular scheme chosen is important.  Rather
      than producing an error (as most receivers currently do), the
      receiver will accept message text for this "null" specification.
      What it does with it depends on which scheme is in effect, and
      will be described in the section on Scheme Mechanics.













                                   17
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



   RECIPIENT SPECIFICATION:  MRCP

      In order to specify recipient names (i.e., mailboxes) and receive
      some acknowledgment (or refusal) for each name, the following
      command is used:

         MRCP <SP> TO:<path> <CRLF>

         Reply for no scheme:
            503 No scheme specified yet; use MRSQ
         Replies for scheme T are identical to those for MAIL.
         Replies for scheme R (recipients first):
            200 OK, name stored
            452 Recipient table full, this name not stored
            553 Recipient name rejected
            4xx Temporary error, try this name again later
            5xx Permanent error, report to sender

      Note that use of this command is an error if no scheme has been
      selected yet; an MRSQ <scheme> must have been given if MRCP is to
      be used.

   SCHEME MECHANICS:  MRSQ R (RECIPIENTS-FIRST)

      In the recipients-first scheme, MRCP is used to specify names
      which the MTP receiver stores in a list or table.  Normally the
      reply for each MRCP will be either a 200 for acceptance or a
      4xx/5xx rejection code.  All 5xx codes are permanent rejections
      (e.g., user not known) which should be reported to the human user,
      whereas 4xx codes in general connote some temporary error that may
      be rectified later.  None of the 4xx/5xx replies impinge on
      previous or succeeding MRCP commands, except for 452 which
      indicates that no further MRCPs will succeed unless a message is
      sent to the already stored recipients or a reset is done.















                                   18
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



      Sending message text to stored recipients is done by giving a MAIL
      command with no "TO" argument; that is, just MAIL <SP> <sender>
      <CRLF>.  Transmission of the message text is exactly the same as
      for normal MAIL.  However, a positive acknowledgment at the end of
      transmission means the message has been sent to ALL recipients
      that were remembered with MRCP, and a failure code means that it
      should be considered to have failed for ALL of these specified
      recipients.  This applies regardless of the actual error code.
      Regardless of what the reply signifies, all stored recipient names
      are flushed and forgotten -- in other words, things are reset to
      their initial state.  This purging of the recipient name list must
      also be done as the reset side effect of any use of MRSQ.

      A 452 reply to an MRCP can be handled by using MAIL to specify the
      message for currently stored recipients, and then sending more
      MRCPs and another MAIL, as many times as necessary.  For example,
      if a receiver only had room for 10 names this would result in a
      50-recipient message being sent 5 times, to 10 different
      recipients each time.

      If a sender attempts to specify message text (MAIL with no "TO"
      argument) before any successful MRCPs have been given, this should
      be treated exactly as a "normal" MAIL with a null recipient would
      be; some receivers return an error, such as "550 Null recipient".

      See the example in Appendix A for a mail transfer using MRSQ R.

   SCHEME MECHANICS:  MRSQ T (TEXT-FIRST)

      In the text-first scheme, MAIL with no "TO" argument is used to
      specify message text, which the receiver stores away.  Succeeding
      MRCPs are then treated as if they were MAIL commands, except that
      none of the text transfer manipulations are done; the stored
      message text is sent to the specified recipient, and a reply code
      is returned identical to that which an actual MAIL would invoke.
      (Note that ANY 2xx code indicates success.)

      The stored message text is not forgotten until the next MAIL or
      MRSQ, which will either replace it with new text or flush it
      entirely.  Any use of MRSQ will reset this scheme by flushing
      stored text, as will any use of MAIL with a non-null argument.

      If an MRCP is seen before any message text has been stored, the
      sender in effect is trying to send a null message; some receivers
      might allow this, others would return an error code.




                                   19
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



      See the example in Appendix B for a mail transfer using MRSQ T.

   WHY TWO SCHEMES ANYWAY?

      Because neither by itself is optimal for all systems.  MRSQ R
      allows more of a "bulk" mailing because everything is saved up and
      then mailed simultaneously.  This is very useful for systems such
      as ITS where the MTP-receiver does not itself write mail directly,
      but hands it on to a central mailer demon of great power.  The
      more information (e.g., recipients) associated with a single
      "hand-off", the more efficiently mail can be delivered.

      By contrast, MRSQ T is geared to receiver-MTPs which want to
      deliver mail directly, in one-by-one incremental fashion.  For
      each given recipient this scheme returns an individual
      success/failure reply code which may depend on variable mail
      system factors such as exceeding disk allocation, mailbox access
      conflicts, and so forth.  If these receiver-MTPs tried to emulate
      MRSQ Rs bulk mailing, they would have to ensure that a success
      reply to the MAIL indeed meant that it had been delivered to ALL
      recipients specified -- not just some.

   NOTES:

      * Because these commands are not required in the minimum
        implementation of MTP, one must be prepared to deal with sites
        which don't recognize either MRSQ or MRCP.  "MRSQ" and "MRSQ ?"
        are explicitly designed as tests to see whether either scheme is
        implemented.  MRCP is not designed as a test, and a failure
        return of the "unimplemented" variety could be confused with "No
        scheme selected yet", or even with "Recipient unknown".

      * There is no way to indicate in a positive response to "MRSQ ?"
        that the preferred "scheme" for a receiver is that of the
        default state; i.e., none of the multi-recipient schemes.  The
        rationale is that in this case, it would be pointless to
        implement MRSQ/MRCP at all, and the response would therefore be
        negative.











                                   20
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



      * One reason that the use of MAIL is restricted to null "TO"
        arguments with this multi-recipient extension is the ambiguity
        that would result if a non-null "TO" argument were allowed.  For
        example, if MRSQ R was in effect and some MRCPs had been given,
        and a MAIL FROM:<X@Y> TO:<FOO><CRLF> was done, there would be no
        way to distinguish a failure reply for mailbox "FOO" from a
        global failure for all recipients specified.  A similar
        situation exists for MRSQ T; it would not be clear whether the
        text was stored and the mailbox failed, or vice versa, or both.

      * "Resets" are done by all MRSQs and "normal" MAILs to avoid
        confusion and overly complicated implementation.  The MRSQ
        command implies a change or uncertainty of status, and the MAIL
        command would otherwise have to use some independent mechanisms
        to avoid clobbering the data bases (e.g., message text storage
        area) used by the T/R schemes.  However, once a scheme is
        selected, it remains "in effect" just as an FTP "TYPE A" remains
        selected.  The recommended way for doing a reset, without
        changing the current selection, is with "MRSQ ?".  Remember that
        "MRSQ" alone reverts to the no-scheme state.

      * It is permissible to intersperse other MTP commands among the
        MRSQ/MRCP/MAIL sequences.


























                                   21
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



DECLARATIVE SPECIFICATIONS

   MINIMUM IMPLEMENTATION

      In order to make MTP workable without needless error messages, the
      following minimum implementation is required for all receivers:

         COMMANDS -- QUIT
                     MAIL
                     NOOP

      In terms of FTP, the values of the transfer parameters must be:

         TYPE -- ASCII
         MODE -- STREAM
         STRU -- FILE-STRUCTURE

      All hosts must use the above values for mail transfer.

   CONNECTIONS

      The receiver-MTP shall "listen" on Port L.  The sender-MTP shall
      initiate the TCP/NCP control connection.  The control connection
      consists of a full-duplex connection under TCP; it is two simplex
      connections under NCP.  Receiver- and sender- MTPs should follow
      the conventions of the TELNET Protocol as specified in the ARPA
      Internet Protocol Handbook.  Receivers are under no obligation to
      provide for editing of command lines and may specify that it be
      done in the sender host.  The control connection shall be closed
      by the receiver at the sender's request after all transfers and
      replies are completed.

   SEQUENCING OF COMMANDS AND REPLIES

      The communication between the sender and receiver is intended to
      be an alternating dialogue.  As such, the sender issues an MTP
      command and the receiver responds with a prompt primary reply.
      The sender should wait for this initial primary success or failure
      response before sending further commands.

      Certain commands require a second reply for which the sender
      should also wait.  These replies may, for example, report on the
      progress or completion of mail transfer.  They are secondary
      replies to mail transfer commands.

      One important group of informational replies is the connection



                                   22
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



      greetings.  Under normal circumstances, a receiver will send a 220
      reply, "awaiting input", when the connection is completed.  The
      sender should wait for this greeting message before sending any
      commands.  If the receiver is unable to accept input right away,
      it should send a 120 "expected delay" reply immediately and a 220
      reply when ready.  The sender will then know not to hang up if
      there is a delay.

         Note: all the greeting type replies have the official name of
         the server host as the first word following the reply code.

      The table below lists alternative success and failure replies for
      each command.  These must be strictly adhered to; a receiver may
      substitute text in the replies, but the meaning and action implied
      by the code numbers and by the specific command reply sequence
      cannot be altered.

      COMMAND-REPLY SEQUENCES

         In this section, the command-reply sequence is presented.  Each
         command is listed with its possible replies; command groups are
         listed together.  Preliminary replies are listed first (with
         their succeeding replies indented under them), then positive
         and negative completion, and finally intermediary replies with
         the remaining commands from the sequence following.  The 421
         reply (service not available, closing control connection) may
         be given at any point if the MTP-receiver knows it must shut
         down.  This listing forms the basis for the state diagrams,
         which will be presented separately.

            CONNECTION ESTABLISHMENT
               120
                  220
               220
               421
            MAIL ACTION COMMANDS
               MAIL
                  151, 152
                     354
                        250
                        451, 552
                  354
                     250
                     451, 552
                  450, 550, 452, 553
                  500, 501, 502, 421



                                   23
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



               MRSQ
                  200, 215
                  500, 501, 502, 421
               MRCP
                  151, 152
                     200
                  200
                  450, 550, 452, 553
                  500, 501, 502, 503, 421
               QUIT
                  221
            INFORMATIONAL COMMANDS
               HELP
                  211, 214
                  500, 501, 502, 421
            MISCELLANEOUS COMMANDS
               NOOP
                  200
                  500 421

STATE DIAGRAMS

   Here we present state diagrams for a very simple minded MTP
   implementation.  Only the first digit of the reply codes is used.
   There is one state diagram for each group of MTP 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".
















                                   24
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



   We first present the diagram that represents the most MTP commands:

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

      This diagram models the commands:

         HELP, MRCP, MRSQ, NOOP, QUIT.






























                                   25
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



   A more complex diagram models the MAIL command:

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

      Note that the "text" here is a series of lines sent from the
      sender to the receiver with no response expected until the last
      line is sent.  (The last line must consist of only a single
      period.)























                                   26
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



   Finally we present a generalized diagram that could be used to model
   the command and reply interchange:

      
               ------------------------------------
              |                                    |
      Begin   |                                    |
        |     V                                    |
        |   +---+  cmd   +---+ 2         +---+     |
         -->|   |------->|   |---------->|   |     |
            |   |        | W |           | S |-----|
         -->|   |     -->|   |-----      |   |     |
        |   +---+    |   +---+ 4,5 |     +---+     |
        |     |      |    | |      |               |
        |     |      |   1| |3     |     +---+     |
        |     |      |    | |      |     |   |     |
        |     |       ----  |       ---->| F |-----
        |     |             |            |   |
        |     |             |            +---+
         -------------------
              |
              |
              V
             End

























                                   27
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



CONNECTION ESTABLISHMENT

   The MTP control connection is established via TCP/NCP between the
   receiver process port/socket L and the sender process port/socket U.
   This protocol is assigned the service port/socket 57 (71 octal), that
   is L=57.











































                                   28
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



APPENDIX A

                  Example of MRSQ R (Recipients-first)

   This is an example of how MRSQ R is used.  First the sender must
   establish that the receiver in fact implements MRSQ.

      S: MRSQ <CRLF>
      R: 200 OK, no scheme selected

   An MRSQ with a null argument always returns a 200 if implemented,
   selecting the default "scheme", i.e., none of them.  If MRSQ were not
   implemented, a code of 4xx or 5xx would be returned.

      S: MRSQ R <CRLF>
      R: 200 OK, using that scheme

   All is well; now the recipients can be specified.

      S: MRCP TO:<Foo@Y> <CRLF>
      R: 200 OK

      S: MRCP TO:<Raboof@Y> <CRLF>
      R: 553  No such user here

      S: MRCP TO:<bar@Y> <CRLF>
      R: 200 OK

      S: MRCP TO:<@Y,@X,fubar@Z> <CRLF>
      R: 200 OK

   Note that the failure of "Raboof" has no effect on the storage of
   mail for "Foo", "bar" or the mail to be forwarded to "fubar@Z"
   through host "X".  Now the message text is furnished, by giving a
   MAIL command with no "TO" argument.

      S: MAIL FROM:<waldo@A><CRLF>
      R: 354 Type mail, ended by <CRLF>.<CRLF>
      S: Blah blah blah blah....etc. etc. etc.
      S: <CRLF>.<CRLF>
      R: 250 Mail sent

   The mail text has now been sent to "Foo" and "bar" as well as
   forwarded to "fubar@Z".





                                   29
^L

                                                                        
September 1980                                                   RFC 772
Mail Transfer Protocol                                                  



APPENDIX B

                     Example of MRSQ T (Text-first)

   Using the same message as the previous example to establish that the
   receiver implements MRSQ.

      S: MRSQ ? <CRLF>
      R: 215 T Text first, please

   MRSQ is indeed implemented, and the receiver says that it prefers
   "T", but that needn't stop the sender from trying something else.

      S: MRSQ R <CRLF>
      R: 501 Sorry, I really can't do that

   It's possible that it could have understood "R" also, but in general
   it's best to use the "preferred" scheme, since the receiver knows
   which is most efficient for its particular site.

      S: MRSQ T <CRLF>
      R: 200 OK, using that scheme

   Scheme "T" is now selected, and the message text is sent by giving a
   mail command with no "TO" argument.

      S: MAIL FROM:<WALDO@A><CRLF>
      R: 354 Type mail, ended by <CRLF>.<CRLF>
      S: Blah blah blah blah....etc. etc. etc.
      S: <CRLF>.<CRLF>
      R: 250 Mail stored

   Now recipients can be specified.

      S: MRCP TO:<Foo@Y> <CRLF>
      R: 250 Stored mail sent

      S: MRCP TO:<Raboof@Y> <CRLF>
      R: 553  No such user here

      S: MRCP TO:<bar@Y> <CRLF>
      R: 250 Stored mail sent

      S: MRCP TO:<@Y,@X,fubar@Z> <CRLF>
      R: 200 OK




                                   30
^L

                                                                        
RFC 772                                                   September 1980
                                                  Mail Transfer Protocol



   The text has now been sent to "Foo" and "bar" at host "Y" and will be
   forwarded to "fubar@Z" through host "X", and still remains stored.  A
   new message can be sent with another MAIL/MRCP ... sequence, but a
   careful sender would reset the state using the exchange below.

      S: MRSQ ? <CRLF>
      R: 215 T Text first, please

   Which resets the state without altering the scheme in effect.








































                                   31
^L