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 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908
|
<pre> <a href="./rfc821">RFC 821</a>
SIMPLE MAIL TRANSFER PROTOCOL
Jonathan B. Postel
August 1982
Information Sciences Institute
University of Southern California
4676 Admiralty Way
Marina del Rey, California 90291
(213) 822-1511</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
TABLE OF CONTENTS
<a href="#section-1">1</a>. INTRODUCTION .................................................. <a href="#page-1">1</a>
<a href="#section-2">2</a>. THE SMTP MODEL ................................................ <a href="#page-2">2</a>
<a href="#section-3">3</a>. THE SMTP PROCEDURE ............................................ <a href="#page-4">4</a>
<a href="#section-3.1">3.1</a>. Mail ..................................................... <a href="#page-4">4</a>
<a href="#section-3.2">3.2</a>. Forwarding ............................................... <a href="#page-7">7</a>
<a href="#section-3.3">3.3</a>. Verifying and Expanding .................................. <a href="#page-8">8</a>
<a href="#section-3.4">3.4</a>. Sending and Mailing ..................................... <a href="#page-11">11</a>
<a href="#section-3.5">3.5</a>. Opening and Closing ..................................... <a href="#page-13">13</a>
<a href="#section-3.6">3.6</a>. Relaying ................................................ <a href="#page-14">14</a>
<a href="#section-3.7">3.7</a>. Domains ................................................. <a href="#page-17">17</a>
<a href="#section-3.8">3.8</a>. Changing Roles .......................................... <a href="#page-18">18</a>
<a href="#section-4">4</a>. THE SMTP SPECIFICATIONS ...................................... <a href="#page-19">19</a>
<a href="#section-4.1">4.1</a>. SMTP Commands ........................................... <a href="#page-19">19</a>
<a href="#section-4.1.1">4.1.1</a>. Command Semantics ..................................... <a href="#page-19">19</a>
<a href="#section-4.1.2">4.1.2</a>. Command Syntax ........................................ <a href="#page-27">27</a>
<a href="#section-4.2">4.2</a>. SMTP Replies ............................................ <a href="#page-34">34</a>
<a href="#section-4.2.1">4.2.1</a>. Reply Codes by Function Group ......................... <a href="#page-35">35</a>
<a href="#section-4.2.2">4.2.2</a>. Reply Codes in Numeric Order .......................... <a href="#page-36">36</a>
<a href="#section-4.3">4.3</a>. Sequencing of Commands and Replies ...................... <a href="#page-37">37</a>
<a href="#section-4.4">4.4</a>. State Diagrams .......................................... <a href="#page-39">39</a>
<a href="#section-4.5">4.5</a>. Details ................................................. <a href="#page-41">41</a>
<a href="#section-4.5.1">4.5.1</a>. Minimum Implementation ................................ <a href="#page-41">41</a>
<a href="#section-4.5.2">4.5.2</a>. Transparency .......................................... <a href="#page-41">41</a>
<a href="#section-4.5.3">4.5.3</a>. Sizes ................................................. <a href="#page-42">42</a>
APPENDIX A: TCP ................................................. <a href="#page-44">44</a>
APPENDIX B: NCP ................................................. <a href="#page-45">45</a>
APPENDIX C: NITS ................................................ <a href="#page-46">46</a>
APPENDIX D: X.25 ................................................ <a href="#page-47">47</a>
APPENDIX E: Theory of Reply Codes ............................... <a href="#page-48">48</a>
APPENDIX F: Scenarios ........................................... <a href="#page-51">51</a>
GLOSSARY ......................................................... <a href="#page-64">64</a>
REFERENCES ....................................................... <a href="#page-67">67</a></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-1" ></span>
Network Working Group J. Postel
Request for Comments: DRAFT ISI
Replaces: <a href="./rfc788">RFC 788</a>, 780, 772 August 1982
SIMPLE MAIL TRANSFER PROTOCOL
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. INTRODUCTION</span>
The objective of Simple Mail Transfer Protocol (SMTP) is to transfer
mail reliably and efficiently.
SMTP is independent of the particular transmission subsystem and
requires only a reliable ordered data stream channel. Appendices A,
B, C, and D describe the use of SMTP with various transport services.
A Glossary provides the definitions of terms as used in this
document.
An important feature of SMTP is its capability to relay mail across
transport service environments. A transport service provides an
interprocess communication environment (IPCE). An IPCE may cover one
network, several networks, or a subset of a network. It is important
to realize that transport systems (or IPCEs) are not one-to-one with
networks. A process can communicate directly with another process
through any mutually known IPCE. Mail is an application or use of
interprocess communication. Mail can be communicated between
processes in different IPCEs by relaying through a process connected
to two (or more) IPCEs. More specifically, mail can be relayed
between hosts on different transport systems by a host on both
transport systems.
<span class="grey">Postel [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. THE SMTP MODEL</span>
The SMTP design is based on the following model of communication: as
the result of a user mail request, the sender-SMTP establishes a
two-way transmission channel to a receiver-SMTP. The receiver-SMTP
may be either the ultimate destination or an intermediate. SMTP
commands are generated by the sender-SMTP and sent to the
receiver-SMTP. SMTP replies are sent from the receiver-SMTP to the
sender-SMTP in response to the commands.
Once the transmission channel is established, the SMTP-sender sends a
MAIL command indicating the sender of the mail. If the SMTP-receiver
can accept mail it responds with an OK reply. The SMTP-sender then
sends a RCPT command identifying a recipient of the mail. If the
SMTP-receiver can accept mail for that recipient it responds with an
OK reply; if not, it responds with a reply rejecting that recipient
(but not the whole mail transaction). The SMTP-sender and
SMTP-receiver may negotiate several recipients. When the recipients
have been negotiated the SMTP-sender sends the mail data, terminating
with a special sequence. If the SMTP-receiver successfully processes
the mail data it responds with an OK reply. The dialog is purposely
lock-step, one-at-a-time.
-------------------------------------------------------------
+----------+ +----------+
+------+ | | | |
| User |<-->| | SMTP | |
+------+ | Sender- |Commands/Replies| Receiver-|
+------+ | SMTP |<-------------->| SMTP | +------+
| File |<-->| | and Mail | |<-->| File |
|System| | | | | |System|
+------+ +----------+ +----------+ +------+
Sender-SMTP Receiver-SMTP
Model for SMTP Use
Figure 1
-------------------------------------------------------------
The SMTP provides mechanisms for the transmission of mail; directly
from the sending user's host to the receiving user's host when the
[Page 2] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
two host are connected to the same transport service, or via one or
more relay SMTP-servers when the source and destination hosts are not
connected to the same transport service.
To be able to provide the relay capability the SMTP-server must be
supplied with the name of the ultimate destination host as well as
the destination mailbox name.
The argument to the MAIL command is a reverse-path, which specifies
who the mail is from. The argument to the RCPT command is a
forward-path, which specifies who the mail is to. The forward-path
is a source route, while the reverse-path is a return route (which
may be used to return a message to the sender when an error occurs
with a relayed message).
When the same message is sent to multiple recipients the SMTP
encourages the transmission of only one copy of the data for all the
recipients at the same destination host.
The mail commands and replies have a rigid syntax. Replies also have
a numeric code. In the following, examples appear which use actual
commands and replies. The complete lists of commands and replies
appears in <a href="#section-4">Section 4</a> on specifications.
Commands and replies are not case sensitive. That is, a command or
reply word may be upper case, lower case, or any mixture of upper and
lower case. Note that this is not true of mailbox user names. For
some hosts the user name is case sensitive, and SMTP implementations
must take case to preserve the case of user names as they appear in
mailbox arguments. Host names are not case sensitive.
Commands and replies are composed of characters from the ASCII
character set [<a href="#ref-1">1</a>]. When the transport service provides an 8-bit byte
(octet) transmission channel, each 7-bit character is transmitted
right justified in an octet with the high order bit cleared to zero.
When specifying the general form of a command or reply, an argument
(or special symbol) will be denoted by a meta-linguistic variable (or
constant), for example, "<string>" or "<reverse-path>". Here the
angle brackets indicate these are meta-linguistic variables.
However, some arguments use the angle brackets literally. For
example, an actual reverse-path is enclosed in angle brackets, i.e.,
"<John.Smith@USC-ISI.ARPA>" is an instance of <reverse-path> (the
angle brackets are actually transmitted in the command or reply).
<span class="grey">Postel [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. THE SMTP PROCEDURES</span>
This section presents the procedures used in SMTP in several parts.
First comes the basic mail procedure defined as a mail transaction.
Following this are descriptions of forwarding mail, verifying mailbox
names and expanding mailing lists, sending to terminals instead of or
in combination with mailboxes, and the opening and closing exchanges.
At the end of this section are comments on relaying, a note on mail
domains, and a discussion of changing roles. Throughout this section
are examples of partial command and reply sequences, several complete
scenarios are presented in <a href="#appendix-F">Appendix F</a>.
3.1. MAIL
There are three steps to SMTP mail transactions. The transaction
is started with a MAIL command which gives the sender
identification. A series of one or more RCPT commands follows
giving the receiver information. Then a DATA command gives the
mail data. And finally, the end of mail data indicator confirms
the transaction.
The first step in the procedure is the MAIL command. The
<reverse-path> contains the source mailbox.
MAIL <SP> FROM:<reverse-path> <CRLF>
This command tells the SMTP-receiver that a new mail
transaction is starting and to reset all its state tables and
buffers, including any recipients or mail data. It gives the
reverse-path which can be used to report errors. If accepted,
the receiver-SMTP returns a 250 OK reply.
The <reverse-path> can contain more than just a mailbox. The
<reverse-path> is a reverse source routing list of hosts and
source mailbox. The first host in the <reverse-path> should be
the host sending this command.
The second step in the procedure is the RCPT command.
RCPT <SP> TO:<forward-path> <CRLF>
This command gives a forward-path identifying one recipient.
If accepted, the receiver-SMTP returns a 250 OK reply, and
stores the forward-path. If the recipient is unknown the
receiver-SMTP returns a 550 Failure reply. This second step of
the procedure can be repeated any number of times.
[Page 4] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
The <forward-path> can contain more than just a mailbox. The
<forward-path> is a source routing list of hosts and the
destination mailbox. The first host in the <forward-path>
should be the host receiving this command.
The third step in the procedure is the DATA command.
DATA <CRLF>
If accepted, the receiver-SMTP returns a 354 Intermediate reply
and considers all succeeding lines to be the message text.
When the end of text is received and stored the SMTP-receiver
sends a 250 OK reply.
Since the mail data is sent on the transmission channel the end
of the mail data must be indicated so that the command and
reply dialog can be resumed. SMTP indicates the end of the
mail data by sending a line containing only a period. A
transparency procedure is used to prevent this from interfering
with the user's text (see <a href="#section-4.5.2">Section 4.5.2</a>).
Please note that the mail data includes the memo header
items such as Date, Subject, To, Cc, From [<a href="#ref-2">2</a>].
The end of mail data indicator also confirms the mail
transaction and tells the receiver-SMTP to now process the
stored recipients and mail data. If accepted, the
receiver-SMTP returns a 250 OK reply. The DATA command should
fail only if the mail transaction was incomplete (for example,
no recipients), or if resources are not available.
The above procedure is an example of a mail transaction. These
commands must be used only in the order discussed above.
Example 1 (below) illustrates the use of these commands in a mail
transaction.
<span class="grey">Postel [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
-------------------------------------------------------------
Example of the SMTP Procedure
This SMTP example shows mail sent by Smith at host Alpha.ARPA,
to Jones, Green, and Brown at host Beta.ARPA. Here we assume
that host Alpha contacts host Beta directly.
S: MAIL FROM:<Smith@Alpha.ARPA>
R: 250 OK
S: RCPT TO:<Jones@Beta.ARPA>
R: 250 OK
S: RCPT TO:<Green@Beta.ARPA>
R: 550 No such user here
S: RCPT TO:<Brown@Beta.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: <CRLF>.<CRLF>
R: 250 OK
The mail has now been accepted for Jones and Brown. Green did
not have a mailbox at host Beta.
Example 1
-------------------------------------------------------------
[Page 6] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
3.2. FORWARDING
There are some cases where the destination information in the
<forward-path> is incorrect, but the receiver-SMTP knows the
correct destination. In such cases, one of the following replies
should be used to allow the sender to contact the correct
destination.
251 User not local; will forward to <forward-path>
This reply indicates that the receiver-SMTP knows the user's
mailbox is on another host and indicates the correct
forward-path to use in the future. Note that either the
host or user or both may be different. The receiver takes
responsibility for delivering the message.
551 User not local; please try <forward-path>
This reply indicates that the receiver-SMTP knows the user's
mailbox is on another host and indicates the correct
forward-path to use. Note that either the host or user or
both may be different. The receiver refuses to accept mail
for this user, and the sender must either redirect the mail
according to the information provided or return an error
response to the originating user.
Example 2 illustrates the use of these responses.
-------------------------------------------------------------
Example of Forwarding
Either
S: RCPT TO:<Postel@USC-ISI.ARPA>
R: 251 User not local; will forward to <Postel@USC-ISIF.ARPA>
Or
S: RCPT TO:<Paul@USC-ISIB.ARPA>
R: 551 User not local; please try <Mockapetris@USC-ISIF.ARPA>
Example 2
-------------------------------------------------------------
<span class="grey">Postel [Page 7]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
3.3. VERIFYING AND EXPANDING
SMTP provides as additional features, commands to verify a user
name or expand a mailing list. This is done with the VRFY and
EXPN commands, which have character string arguments. For the
VRFY command, the string is a user name, and the response may
include the full name of the user and must include the mailbox of
the user. For the EXPN command, the string identifies a mailing
list, and the multiline response may include the full name of the
users and must give the mailboxes on the mailing list.
"User name" is a fuzzy term and used purposely. If a host
implements the VRFY or EXPN commands then at least local mailboxes
must be recognized as "user names". If a host chooses to
recognize other strings as "user names" that is allowed.
In some hosts the distinction between a mailing list and an alias
for a single mailbox is a bit fuzzy, since a common data structure
may hold both types of entries, and it is possible to have mailing
lists of one mailbox. If a request is made to verify a mailing
list a positive response can be given if on receipt of a message
so addressed it will be delivered to everyone on the list,
otherwise an error should be reported (e.g., "550 That is a
mailing list, not a user"). If a request is made to expand a user
name a positive response can be formed by returning a list
containing one name, or an error can be reported (e.g., "550 That
is a user name, not a mailing list").
In the case of a multiline reply (normal for EXPN) exactly one
mailbox is to be specified on each line of the reply. In the case
of an ambiguous request, for example, "VRFY Smith", where there
are two Smith's the response must be "553 User ambiguous".
The case of verifying a user name is straightforward as shown in
example 3.
[Page 8] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
-------------------------------------------------------------
Example of Verifying a User Name
Either
S: VRFY Smith
R: 250 Fred Smith <Smith@USC-ISIF.ARPA>
Or
S: VRFY Smith
R: 251 User not local; will forward to <Smith@USC-ISIQ.ARPA>
Or
S: VRFY Jones
R: 550 String does not match anything.
Or
S: VRFY Jones
R: 551 User not local; please try <Jones@USC-ISIQ.ARPA>
Or
S: VRFY Gourzenkyinplatz
R: 553 User ambiguous.
Example 3
-------------------------------------------------------------
<span class="grey">Postel [Page 9]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
The case of expanding a mailbox list requires a multiline reply as
shown in example 4.
-------------------------------------------------------------
Example of Expanding a Mailing List
Either
S: EXPN Example-People
R: 250-Jon Postel <Postel@USC-ISIF.ARPA>
R: 250-Fred Fonebone <Fonebone@USC-ISIQ.ARPA>
R: 250-Sam Q. Smith <SQSmith@USC-ISIQ.ARPA>
R: 250-Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA>
R: 250-<joe@foo-unix.ARPA>
R: 250 <xyz@bar-unix.ARPA>
Or
S: EXPN Executive-Washroom-List
R: 550 Access Denied to You.
Example 4
-------------------------------------------------------------
The character string arguments of the VRFY and EXPN commands
cannot be further restricted due to the variety of implementations
of the user name and mailbox list concepts. On some systems it
may be appropriate for the argument of the EXPN command to be a
file name for a file containing a mailing list, but again there is
a variety of file naming conventions in the Internet.
The VRFY and EXPN commands are not included in the minimum
implementation (<a href="#section-4.5.1">Section 4.5.1</a>), and are not required to work
across relays when they are implemented.
[Page 10] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
3.4. SENDING AND MAILING
The main purpose of SMTP is to deliver messages to user's
mailboxes. A very similar service provided by some hosts is to
deliver messages to user's terminals (provided the user is active
on the host). The delivery to the user's mailbox is called
"mailing", the delivery to the user's terminal is called
"sending". Because in many hosts the implementation of sending is
nearly identical to the implementation of mailing these two
functions are combined in SMTP. However the sending commands are
not included in the required minimum implementation
(<a href="#section-4.5.1">Section 4.5.1</a>). Users should have the ability to control the
writing of messages on their terminals. Most hosts permit the
users to accept or refuse such messages.
The following three command are defined to support the sending
options. These are used in the mail transaction instead of the
MAIL command and inform the receiver-SMTP of the special semantics
of this transaction:
SEND <SP> FROM:<reverse-path> <CRLF>
The SEND command requires that the mail data be delivered to
the user's terminal. If the user is not active (or not
accepting terminal messages) on the host a 450 reply may
returned to a RCPT command. The mail transaction is
successful if the message is delivered the terminal.
SOML <SP> FROM:<reverse-path> <CRLF>
The Send Or MaiL command requires that the mail data be
delivered to the user's terminal if the user is active (and
accepting terminal messages) on the host. If the user is
not active (or not accepting terminal messages) then the
mail data is entered into the user's mailbox. The mail
transaction is successful if the message is delivered either
to the terminal or the mailbox.
SAML <SP> FROM:<reverse-path> <CRLF>
The Send And MaiL command requires that the mail data be
delivered to the user's terminal if the user is active (and
accepting terminal messages) on the host. In any case the
mail data is entered into the user's mailbox. The mail
transaction is successful if the message is delivered the
mailbox.
<span class="grey">Postel [Page 11]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
The same reply codes that are used for the MAIL commands are used
for these commands.
[Page 12] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
3.5. OPENING AND CLOSING
At the time the transmission channel is opened there is an
exchange to ensure that the hosts are communicating with the hosts
they think they are.
The following two commands are used in transmission channel
opening and closing:
HELO <SP> <domain> <CRLF>
QUIT <CRLF>
In the HELO command the host sending the command identifies
itself; the command may be interpreted as saying "Hello, I am
<domain>".
-------------------------------------------------------------
Example of Connection Opening
R: 220 BBN-UNIX.ARPA Simple Mail Transfer Service Ready
S: HELO USC-ISIF.ARPA
R: 250 BBN-UNIX.ARPA
Example 5
-------------------------------------------------------------
-------------------------------------------------------------
Example of Connection Closing
S: QUIT
R: 221 BBN-UNIX.ARPA Service closing transmission channel
Example 6
-------------------------------------------------------------
<span class="grey">Postel [Page 13]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
3.6. RELAYING
The forward-path may be a source route of the form
"@ONE,@TWO:JOE@THREE", where ONE, TWO, and THREE are hosts. This
form is used to emphasize the distinction between an address and a
route. The mailbox is an absolute address, and the route is
information about how to get there. The two concepts should not
be confused.
Conceptually the elements of the forward-path are moved to the
reverse-path as the message is relayed from one server-SMTP to
another. The reverse-path is a reverse source route, (i.e., a
source route from the current location of the message to the
originator of the message). When a server-SMTP deletes its
identifier from the forward-path and inserts it into the
reverse-path, it must use the name it is known by in the
environment it is sending into, not the environment the mail came
from, in case the server-SMTP is known by different names in
different environments.
If when the message arrives at an SMTP the first element of the
forward-path is not the identifier of that SMTP the element is not
deleted from the forward-path and is used to determine the next
SMTP to send the message to. In any case, the SMTP adds its own
identifier to the reverse-path.
Using source routing the receiver-SMTP receives mail to be relayed
to another server-SMTP The receiver-SMTP may accept or reject the
task of relaying the mail in the same way it accepts or rejects
mail for a local user. The receiver-SMTP transforms the command
arguments by moving its own identifier from the forward-path to
the beginning of the reverse-path. The receiver-SMTP then becomes
a sender-SMTP, establishes a transmission channel to the next SMTP
in the forward-path, and sends it the mail.
The first host in the reverse-path should be the host sending the
SMTP commands, and the first host in the forward-path should be
the host receiving the SMTP commands.
Notice that the forward-path and reverse-path appear in the SMTP
commands and replies, but not necessarily in the message. That
is, there is no need for these paths and especially this syntax to
appear in the "To:" , "From:", "CC:", etc. fields of the message
header.
If a server-SMTP has accepted the task of relaying the mail and
[Page 14] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
later finds that the forward-path is incorrect or that the mail
cannot be delivered for whatever reason, then it must construct an
"undeliverable mail" notification message and send it to the
originator of the undeliverable mail (as indicated by the
reverse-path).
This notification message must be from the server-SMTP at this
host. Of course, server-SMTPs should not send notification
messages about problems with notification messages. One way to
prevent loops in error reporting is to specify a null reverse-path
in the MAIL command of a notification message. When such a
message is relayed it is permissible to leave the reverse-path
null. A MAIL command with a null reverse-path appears as follows:
MAIL FROM:<>
An undeliverable mail notification message is shown in example 7.
This notification is in response to a message originated by JOE at
HOSTW and sent via HOSTX to HOSTY with instructions to relay it on
to HOSTZ. What we see in the example is the transaction between
HOSTY and HOSTX, which is the first step in the return of the
notification message.
<span class="grey">Postel [Page 15]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
-------------------------------------------------------------
Example Undeliverable Mail Notification Message
S: MAIL FROM:<>
R: 250 ok
S: RCPT TO:<@HOSTX.ARPA:JOE@HOSTW.ARPA>
R: 250 ok
S: DATA
R: 354 send the mail data, end with .
S: Date: 23 Oct 81 11:22:33
S: From: SMTP@HOSTY.ARPA
S: To: JOE@HOSTW.ARPA
S: Subject: Mail System Problem
S:
S: Sorry JOE, your message to SAM@HOSTZ.ARPA lost.
S: HOSTZ.ARPA said this:
S: "550 No Such User"
S: .
R: 250 ok
Example 7
-------------------------------------------------------------
[Page 16] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-17" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
3.7. DOMAINS
Domains are a recently introduced concept in the ARPA Internet
mail system. The use of domains changes the address space from a
flat global space of simple character string host names to a
hierarchically structured rooted tree of global addresses. The
host name is replaced by a domain and host designator which is a
sequence of domain element strings separated by periods with the
understanding that the domain elements are ordered from the most
specific to the most general.
For example, "USC-ISIF.ARPA", "Fred.Cambridge.UK", and
"PC7.LCS.MIT.ARPA" might be host-and-domain identifiers.
Whenever domain names are used in SMTP only the official names are
used, the use of nicknames or aliases is not allowed.
<span class="grey">Postel [Page 17]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-18" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
3.8. CHANGING ROLES
The TURN command may be used to reverse the roles of the two
programs communicating over the transmission channel.
If program-A is currently the sender-SMTP and it sends the TURN
command and receives an ok reply (250) then program-A becomes the
receiver-SMTP.
If program-B is currently the receiver-SMTP and it receives the
TURN command and sends an ok reply (250) then program-B becomes
the sender-SMTP.
To refuse to change roles the receiver sends the 502 reply.
Please note that this command is optional. It would not normally
be used in situations where the transmission channel is TCP.
However, when the cost of establishing the transmission channel is
high, this command may be quite useful. For example, this command
may be useful in supporting be mail exchange using the public
switched telephone system as a transmission channel, especially if
some hosts poll other hosts for mail exchanges.
[Page 18] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-19" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. THE SMTP SPECIFICATIONS</span>
4.1. SMTP COMMANDS
4.1.1. COMMAND SEMANTICS
The SMTP commands define the mail transfer or the mail system
function requested by the user. SMTP commands are character
strings terminated by <CRLF>. The command codes themselves are
alphabetic characters terminated by <SP> if parameters follow
and <CRLF> otherwise. The syntax of mailboxes must conform to
receiver site conventions. The SMTP commands are discussed
below. The SMTP replies are discussed in the <a href="#section-4.2">Section 4.2</a>.
A mail transaction involves several data objects which are
communicated as arguments to different commands. The
reverse-path is the argument of the MAIL command, the
forward-path is the argument of the RCPT command, and the mail
data is the argument of the DATA command. These arguments or
data objects must be transmitted and held pending the
confirmation communicated by the end of mail data indication
which finalizes the transaction. The model for this is that
distinct buffers are provided to hold the types of data
objects, that is, there is a reverse-path buffer, a
forward-path buffer, and a mail data buffer. Specific commands
cause information to be appended to a specific buffer, or cause
one or more buffers to be cleared.
HELLO (HELO)
This command is used to identify the sender-SMTP to the
receiver-SMTP. The argument field contains the host name of
the sender-SMTP.
The receiver-SMTP identifies itself to the sender-SMTP in
the connection greeting reply, and in the response to this
command.
This command and an OK reply to it confirm that both the
sender-SMTP and the receiver-SMTP are in the initial state,
that is, there is no transaction in progress and all state
tables and buffers are cleared.
<span class="grey">Postel [Page 19]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-20" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
MAIL (MAIL)
This command is used to initiate a mail transaction in which
the mail data is delivered to one or more mailboxes. The
argument field contains a reverse-path.
The reverse-path consists of an optional list of hosts and
the sender mailbox. When the list of hosts is present, it
is a "reverse" source route and indicates that the mail was
relayed through each host on the list (the first host in the
list was the most recent relay). This list is used as a
source route to return non-delivery notices to the sender.
As each relay host adds itself to the beginning of the list,
it must use its name as known in the IPCE to which it is
relaying the mail rather than the IPCE from which the mail
came (if they are different). In some types of error
reporting messages (for example, undeliverable mail
notifications) the reverse-path may be null (see Example 7).
This command clears the reverse-path buffer, the
forward-path buffer, and the mail data buffer; and inserts
the reverse-path information from this command into the
reverse-path buffer.
RECIPIENT (RCPT)
This command is used to identify an individual recipient of
the mail data; multiple recipients are specified by multiple
use of this command.
The forward-path consists of an optional list of hosts and a
required destination mailbox. When the list of hosts is
present, it is a source route and indicates that the mail
must be relayed to the next host on the list. If the
receiver-SMTP does not implement the relay function it may
user the same reply it would for an unknown local user
(550).
When mail is relayed, the relay host must remove itself from
the beginning forward-path and put itself at the beginning
of the reverse-path. When mail reaches its ultimate
destination (the forward-path contains only a destination
mailbox), the receiver-SMTP inserts it into the destination
mailbox in accordance with its host mail conventions.
[Page 20] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-21" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
For example, mail received at relay host A with arguments
FROM:<USERX@HOSTY.ARPA>
TO:<@HOSTA.ARPA,@HOSTB.ARPA:USERC@HOSTD.ARPA>
will be relayed on to host B with arguments
FROM:<@HOSTA.ARPA:USERX@HOSTY.ARPA>
TO:<@HOSTB.ARPA:USERC@HOSTD.ARPA>.
This command causes its forward-path argument to be appended
to the forward-path buffer.
DATA (DATA)
The receiver treats the lines following the command as mail
data from the sender. This command causes the mail data
from this command to be appended to the mail data buffer.
The mail data may contain any of the 128 ASCII character
codes.
The mail data is terminated by a line containing only a
period, that is the character sequence "<CRLF>.<CRLF>" (see
<a href="#section-4.5.2">Section 4.5.2</a> on Transparency). This is the end of mail
data indication.
The end of mail data indication requires that the receiver
must now process the stored mail transaction information.
This processing consumes the information in the reverse-path
buffer, the forward-path buffer, and the mail data buffer,
and on the completion of this command these buffers are
cleared. If the processing is successful the receiver must
send an OK reply. If the processing fails completely the
receiver must send a failure reply.
When the receiver-SMTP accepts a message either for relaying
or for final delivery it inserts at the beginning of the
mail data a time stamp line. The time stamp line indicates
the identity of the host that sent the message, and the
identity of the host that received the message (and is
inserting this time stamp), and the date and time the
message was received. Relayed messages will have multiple
time stamp lines.
When the receiver-SMTP makes the "final delivery" of a
message it inserts at the beginning of the mail data a
<span class="grey">Postel [Page 21]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-22" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
return path line. The return path line preserves the
information in the <reverse-path> from the MAIL command.
Here, final delivery means the message leaves the SMTP
world. Normally, this would mean it has been delivered to
the destination user, but in some cases it may be further
processed and transmitted by another mail system.
It is possible for the mailbox in the return path be
different from the actual sender's mailbox, for example,
if error responses are to be delivered a special error
handling mailbox rather than the message senders.
The preceding two paragraphs imply that the final mail data
will begin with a return path line, followed by one or more
time stamp lines. These lines will be followed by the mail
data header and body [<a href="#ref-2">2</a>]. See Example 8.
Special mention is needed of the response and further action
required when the processing following the end of mail data
indication is partially successful. This could arise if
after accepting several recipients and the mail data, the
receiver-SMTP finds that the mail data can be successfully
delivered to some of the recipients, but it cannot be to
others (for example, due to mailbox space allocation
problems). In such a situation, the response to the DATA
command must be an OK reply. But, the receiver-SMTP must
compose and send an "undeliverable mail" notification
message to the originator of the message. Either a single
notification which lists all of the recipients that failed
to get the message, or separate notification messages must
be sent for each failed recipient (see Example 7). All
undeliverable mail notification messages are sent using the
MAIL command (even if they result from processing a SEND,
SOML, or SAML command).
[Page 22] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-23" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
-------------------------------------------------------------
Example of Return Path and Received Time Stamps
Return-Path: <@GHI.ARPA,@DEF.ARPA,@ABC.ARPA:JOE@ABC.ARPA>
Received: from GHI.ARPA by JKL.ARPA ; 27 Oct 81 15:27:39 PST
Received: from DEF.ARPA by GHI.ARPA ; 27 Oct 81 15:15:13 PST
Received: from ABC.ARPA by DEF.ARPA ; 27 Oct 81 15:01:59 PST
Date: 27 Oct 81 15:01:01 PST
From: JOE@ABC.ARPA
Subject: Improved Mailing System Installed
To: SAM@JKL.ARPA
This is to inform you that ...
Example 8
-------------------------------------------------------------
SEND (SEND)
This command is used to initiate a mail transaction in which
the mail data is delivered to one or more terminals. The
argument field contains a reverse-path. This command is
successful if the message is delivered to a terminal.
The reverse-path consists of an optional list of hosts and
the sender mailbox. When the list of hosts is present, it
is a "reverse" source route and indicates that the mail was
relayed through each host on the list (the first host in the
list was the most recent relay). This list is used as a
source route to return non-delivery notices to the sender.
As each relay host adds itself to the beginning of the list,
it must use its name as known in the IPCE to which it is
relaying the mail rather than the IPCE from which the mail
came (if they are different).
This command clears the reverse-path buffer, the
forward-path buffer, and the mail data buffer; and inserts
the reverse-path information from this command into the
reverse-path buffer.
SEND OR MAIL (SOML)
This command is used to initiate a mail transaction in which
the mail data is delivered to one or more terminals or
<span class="grey">Postel [Page 23]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-24" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
mailboxes. For each recipient the mail data is delivered to
the recipient's terminal if the recipient is active on the
host (and accepting terminal messages), otherwise to the
recipient's mailbox. The argument field contains a
reverse-path. This command is successful if the message is
delivered to a terminal or the mailbox.
The reverse-path consists of an optional list of hosts and
the sender mailbox. When the list of hosts is present, it
is a "reverse" source route and indicates that the mail was
relayed through each host on the list (the first host in the
list was the most recent relay). This list is used as a
source route to return non-delivery notices to the sender.
As each relay host adds itself to the beginning of the list,
it must use its name as known in the IPCE to which it is
relaying the mail rather than the IPCE from which the mail
came (if they are different).
This command clears the reverse-path buffer, the
forward-path buffer, and the mail data buffer; and inserts
the reverse-path information from this command into the
reverse-path buffer.
SEND AND MAIL (SAML)
This command is used to initiate a mail transaction in which
the mail data is delivered to one or more terminals and
mailboxes. For each recipient the mail data is delivered to
the recipient's terminal if the recipient is active on the
host (and accepting terminal messages), and for all
recipients to the recipient's mailbox. The argument field
contains a reverse-path. This command is successful if the
message is delivered to the mailbox.
The reverse-path consists of an optional list of hosts and
the sender mailbox. When the list of hosts is present, it
is a "reverse" source route and indicates that the mail was
relayed through each host on the list (the first host in the
list was the most recent relay). This list is used as a
source route to return non-delivery notices to the sender.
As each relay host adds itself to the beginning of the list,
it must use its name as known in the IPCE to which it is
relaying the mail rather than the IPCE from which the mail
came (if they are different).
This command clears the reverse-path buffer, the
[Page 24] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-25" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
forward-path buffer, and the mail data buffer; and inserts
the reverse-path information from this command into the
reverse-path buffer.
RESET (RSET)
This command specifies that the current mail transaction is
to be aborted. Any stored sender, recipients, and mail data
must be discarded, and all buffers and state tables cleared.
The receiver must send an OK reply.
VERIFY (VRFY)
This command asks the receiver to confirm that the argument
identifies a user. If it is a user name, the full name of
the user (if known) and the fully specified mailbox are
returned.
This command has no effect on any of the reverse-path
buffer, the forward-path buffer, or the mail data buffer.
EXPAND (EXPN)
This command asks the receiver to confirm that the argument
identifies a mailing list, and if so, to return the
membership of that list. The full name of the users (if
known) and the fully specified mailboxes are returned in a
multiline reply.
This command has no effect on any of the reverse-path
buffer, the forward-path buffer, or the mail data buffer.
HELP (HELP)
This command causes the receiver to send helpful information
to the sender of the HELP command. The command may take an
argument (e.g., any command name) and return more specific
information as a response.
This command has no effect on any of the reverse-path
buffer, the forward-path buffer, or the mail data buffer.
<span class="grey">Postel [Page 25]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-26" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
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.
This command has no effect on any of the reverse-path
buffer, the forward-path buffer, or the mail data buffer.
QUIT (QUIT)
This command specifies that the receiver must send an OK
reply, and then close the transmission channel.
The receiver should not close the transmission channel until
it receives and replies to a QUIT command (even if there was
an error). The sender should not close the transmission
channel until it send a QUIT command and receives the reply
(even if there was an error response to a previous command).
If the connection is closed prematurely the receiver should
act as if a RSET command had been received (canceling any
pending transaction, but not undoing any previously
completed transaction), the sender should act as if the
command or transaction in progress had received a temporary
error (4xx).
TURN (TURN)
This command specifies that the receiver must either (1)
send an OK reply and then take on the role of the
sender-SMTP, or (2) send a refusal reply and retain the role
of the receiver-SMTP.
If program-A is currently the sender-SMTP and it sends the
TURN command and receives an OK reply (250) then program-A
becomes the receiver-SMTP. Program-A is then in the initial
state as if the transmission channel just opened, and it
then sends the 220 service ready greeting.
If program-B is currently the receiver-SMTP and it receives
the TURN command and sends an OK reply (250) then program-B
becomes the sender-SMTP. Program-B is then in the initial
state as if the transmission channel just opened, and it
then expects to receive the 220 service ready greeting.
To refuse to change roles the receiver sends the 502 reply.
[Page 26] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-27" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
There are restrictions on the order in which these command may
be used.
The first command in a session must be the HELO command.
The HELO command may be used later in a session as well. If
the HELO command argument is not acceptable a 501 failure
reply must be returned and the receiver-SMTP must stay in
the same state.
The NOOP, HELP, EXPN, and VRFY commands can be used at any
time during a session.
The MAIL, SEND, SOML, or SAML commands begin a mail
transaction. Once started a mail transaction consists of
one of the transaction beginning commands, one or more RCPT
commands, and a DATA command, in that order. A mail
transaction may be aborted by the RSET command. There may
be zero or more transactions in a session.
If the transaction beginning command argument is not
acceptable a 501 failure reply must be returned and the
receiver-SMTP must stay in the same state. If the commands
in a transaction are out of order a 503 failure reply must
be returned and the receiver-SMTP must stay in the same
state.
The last command in a session must be the QUIT command. The
QUIT command can not be used at any other time in a session.
4.1.2. COMMAND SYNTAX
The commands consist of a command code followed by an argument
field. 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 "TO" or "to" for the forward-path. Command codes and
the argument fields are separated by one or more spaces.
However, within the reverse-path and forward-path arguments
case is important. In particular, in some hosts the user
"smith" is different from the user "Smith".
<span class="grey">Postel [Page 27]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-28" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
The argument field consists of a variable length character
string ending with the character sequence <CRLF>. The receiver
is to take no action until this sequence is received.
Square brackets denote an optional argument field. If the
option is not taken, the appropriate default is implied.
[Page 28] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-29" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
The following are the SMTP commands:
HELO <SP> <domain> <CRLF>
MAIL <SP> FROM:<reverse-path> <CRLF>
RCPT <SP> TO:<forward-path> <CRLF>
DATA <CRLF>
RSET <CRLF>
SEND <SP> FROM:<reverse-path> <CRLF>
SOML <SP> FROM:<reverse-path> <CRLF>
SAML <SP> FROM:<reverse-path> <CRLF>
VRFY <SP> <string> <CRLF>
EXPN <SP> <string> <CRLF>
HELP [<SP> <string>] <CRLF>
NOOP <CRLF>
QUIT <CRLF>
TURN <CRLF>
<span class="grey">Postel [Page 29]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-30" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
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.
<reverse-path> ::= <path>
<forward-path> ::= <path>
<path> ::= "<" [ <a-d-l> ":" ] <mailbox> ">"
<a-d-l> ::= <at-domain> | <at-domain> "," <a-d-l>
<at-domain> ::= "@" <domain>
<domain> ::= <element> | <element> "." <domain>
<element> ::= <name> | "#" <number> | "[" <dotnum> "]"
<mailbox> ::= <local-part> "@" <domain>
<local-part> ::= <dot-string> | <quoted-string>
<name> ::= <a> <ldh-str> <let-dig>
<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
<let-dig> ::= <a> | <d>
<let-dig-hyp> ::= <a> | <d> | "-"
<dot-string> ::= <string> | <string> "." <dot-string>
<string> ::= <char> | <char> <string>
<quoted-string> ::= """ <qtext> """
<qtext> ::= "\" <x> | "\" <x> <qtext> | <q> | <q> <qtext>
<char> ::= <c> | "\" <x>
<dotnum> ::= <snum> "." <snum> "." <snum> "." <snum>
<number> ::= <d> | <d> <number>
<CRLF> ::= <CR> <LF>
[Page 30] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-31" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
<CR> ::= the carriage return character (ASCII code 13)
<LF> ::= the line feed character (ASCII code 10)
<SP> ::= the space character (ASCII code 32)
<snum> ::= one, two, or three digits representing a decimal
integer value in the range 0 through 255
<a> ::= any one of the 52 alphabetic characters A through Z
in upper case and a through z in lower case
<c> ::= any one of the 128 ASCII characters, but not any
<special> or <SP>
<d> ::= any one of the ten digits 0 through 9
<q> ::= any one of the 128 ASCII characters except <CR>,
<LF>, quote ("), or backslash (\)
<x> ::= any one of the 128 ASCII characters (no exceptions)
<special> ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "."
| "," | ";" | ":" | "@" """ | the control
characters (ASCII codes 0 through 31 inclusive and
127)
Note that the backslash, "\", is a quote character, which is
used to indicate that the next character is to be used
literally (instead of its normal interpretation). For example,
"Joe\,Smith" could be used to indicate a single nine character
user field with comma being the fourth character of the field.
Hosts are generally known by names which are translated to
addresses in each host. Note that the name elements of domains
are the official names -- no use of nicknames or aliases is
allowed.
Sometimes a host is not known to the translation function and
communication is blocked. To bypass this barrier two numeric
forms are also allowed for host "names". One form is a decimal
integer prefixed by a pound sign, "#", which indicates the
number is the address of the host. Another form is four small
decimal integers separated by dots and enclosed by brackets,
e.g., "[123.255.37.2]", which indicates a 32-bit ARPA Internet
Address in four 8-bit fields.
<span class="grey">Postel [Page 31]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-32" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
The time stamp line and the return path line are formally
defined as follows:
<return-path-line> ::= "Return-Path:" <SP><reverse-path><CRLF>
<time-stamp-line> ::= "Received:" <SP> <stamp> <CRLF>
<stamp> ::= <from-domain> <by-domain> <opt-info> ";"
<daytime>
<from-domain> ::= "FROM" <SP> <domain> <SP>
<by-domain> ::= "BY" <SP> <domain> <SP>
<opt-info> ::= [<via>] [<with>] [<id>] [<for>]
<via> ::= "VIA" <SP> <link> <SP>
<with> ::= "WITH" <SP> <protocol> <SP>
<id> ::= "ID" <SP> <string> <SP>
<for> ::= "FOR" <SP> <path> <SP>
<link> ::= The standard names for links are registered with
the Network Information Center.
<protocol> ::= The standard names for protocols are
registered with the Network Information Center.
<daytime> ::= <SP> <date> <SP> <time>
<date> ::= <dd> <SP> <mon> <SP> <yy>
<time> ::= <hh> ":" <mm> ":" <ss> <SP> <zone>
<dd> ::= the one or two decimal integer day of the month in
the range 1 to 31.
<mon> ::= "JAN" | "FEB" | "MAR" | "APR" | "MAY" | "JUN" |
"JUL" | "AUG" | "SEP" | "OCT" | "NOV" | "DEC"
<yy> ::= the two decimal integer year of the century in the
range 00 to 99.
[Page 32] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-33" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
<hh> ::= the two decimal integer hour of the day in the
range 00 to 24.
<mm> ::= the two decimal integer minute of the hour in the
range 00 to 59.
<ss> ::= the two decimal integer second of the minute in the
range 00 to 59.
<zone> ::= "UT" for Universal Time (the default) or other
time zone designator (as in [<a href="#ref-2">2</a>]).
-------------------------------------------------------------
Return Path Example
Return-Path: <@CHARLIE.ARPA,@BAKER.ARPA:JOE@ABLE.ARPA>
Example 9
-------------------------------------------------------------
-------------------------------------------------------------
Time Stamp Line Example
Received: FROM ABC.ARPA BY XYZ.ARPA ; 22 OCT 81 09:23:59 PDT
Received: from ABC.ARPA by XYZ.ARPA via TELENET with X25
id M12345 for Smith@PDQ.ARPA ; 22 OCT 81 09:23:59 PDT
Example 10
-------------------------------------------------------------
<span class="grey">Postel [Page 33]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-34" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
4.2. SMTP REPLIES
Replies to SMTP commands are devised to ensure the synchronization
of requests and actions in the process of mail transfer, and to
guarantee that the sender-SMTP always knows the state of the
receiver-SMTP. Every command must generate exactly one reply.
The details of the command-reply sequence are made explicit in
<a href="#section-5.3">Section 5.3</a> on Sequencing and <a href="#section-5.4">Section 5.4</a> State Diagrams.
An SMTP 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-SMTP need not 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 and context dependent, so there are
likely to be varying texts for each reply code. A discussion of
the theory of reply codes is given in <a href="#appendix-E">Appendix E</a>. Formally, a
reply is defined to be the sequence: a three-digit code, <SP>,
one line of text, and <CRLF>, or a multiline reply (as defined in
<a href="#appendix-E">Appendix E</a>). Only the EXPN and HELP commands are expected to
result in multiline replies in normal circumstances, however
multiline replies are allowed for any command.
[Page 34] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-35" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
4.2.1. REPLY CODES BY FUNCTION GROUPS
500 Syntax error, command unrecognized
[This may include errors such as command line too long]
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented
211 System status, or system help reply
214 Help message
[Information on how to use the receiver or the meaning of a
particular non-standard command; this reply is useful only
to the human user]
220 <domain> Service ready
221 <domain> Service closing transmission channel
421 <domain> Service not available,
closing transmission channel
[This may be a reply to any command if the service knows it
must shut down]
250 Requested mail action okay, completed
251 User not local; will forward to <forward-path>
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: error in processing
551 User not local; please try <forward-path>
452 Requested action not taken: insufficient system storage
552 Requested mail action aborted: exceeded storage allocation
553 Requested action not taken: mailbox name not allowed
[E.g., mailbox syntax incorrect]
354 Start mail input; end with <CRLF>.<CRLF>
554 Transaction failed
<span class="grey">Postel [Page 35]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-36" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
4.2.2. NUMERIC ORDER LIST OF REPLY CODES
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]
220 <domain> Service ready
221 <domain> Service closing transmission channel
250 Requested mail action okay, completed
251 User not local; will forward to <forward-path>
354 Start mail input; end with <CRLF>.<CRLF>
421 <domain> Service not available,
closing transmission channel
[This may be a reply to any command if the service knows it
must shut down]
450 Requested mail action not taken: mailbox unavailable
[E.g., mailbox busy]
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognized
[This may include errors such as command line too long]
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented
550 Requested action not taken: mailbox unavailable
[E.g., mailbox not found, no access]
551 User not local; please try <forward-path>
552 Requested mail action aborted: exceeded storage allocation
553 Requested action not taken: mailbox name not allowed
[E.g., mailbox syntax incorrect]
554 Transaction failed
[Page 36] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-37" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
4.3. SEQUENCING OF COMMANDS AND REPLIES
The communication between the sender and receiver is intended to
be an alternating dialogue, controlled by the sender. As such,
the sender issues a command and the receiver responds with a
reply. The sender must wait for this response before sending
further commands.
One important reply is the connection greeting. Normally, a
receiver will send a 220 "Service ready" reply when the connection
is completed. The sender should wait for this greeting message
before sending any commands.
Note: all the greeting type replies have the official name of
the server host as the first word following the reply code.
For example,
220 <SP> USC-ISIF.ARPA <SP> Service ready <CRLF>
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
Each command is listed with its possible replies. The prefixes
used before the possible replies are "P" for preliminary (not
used in SMTP), "I" for intermediate, "S" for success, "F" for
failure, and "E" for error. The 421 reply (service not
available, closing transmission channel) may be given to any
command if the SMTP-receiver knows it must shut down. This
listing forms the basis for the State Diagrams in <a href="#section-4.4">Section 4.4</a>.
CONNECTION ESTABLISHMENT
S: 220
F: 421
HELO
S: 250
E: 500, 501, 504, 421
MAIL
S: 250
F: 552, 451, 452
E: 500, 501, 421
<span class="grey">Postel [Page 37]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-38" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
RCPT
S: 250, 251
F: 550, 551, 552, 553, 450, 451, 452
E: 500, 501, 503, 421
DATA
I: 354 -> data -> S: 250
F: 552, 554, 451, 452
F: 451, 554
E: 500, 501, 503, 421
RSET
S: 250
E: 500, 501, 504, 421
SEND
S: 250
F: 552, 451, 452
E: 500, 501, 502, 421
SOML
S: 250
F: 552, 451, 452
E: 500, 501, 502, 421
SAML
S: 250
F: 552, 451, 452
E: 500, 501, 502, 421
VRFY
S: 250, 251
F: 550, 551, 553
E: 500, 501, 502, 504, 421
EXPN
S: 250
F: 550
E: 500, 501, 502, 504, 421
HELP
S: 211, 214
E: 500, 501, 502, 504, 421
NOOP
S: 250
E: 500, 421
QUIT
S: 221
E: 500
TURN
S: 250
F: 502
E: 500, 503
[Page 38] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-39" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
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.
<span class="grey">Postel [Page 39]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-40" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
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.
[Page 40] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-41" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
4.5. DETAILS
4.5.1. MINIMUM IMPLEMENTATION
In order to make SMTP workable, the following minimum
implementation is required for all receivers:
COMMANDS -- HELO
MAIL
RCPT
DATA
RSET
NOOP
QUIT
4.5.2. TRANSPARENCY
Without some provision for data transparency the character
sequence "<CRLF>.<CRLF>" ends the mail text and cannot be sent
by the user. In general, users are not aware of such
"forbidden" sequences. To allow all user composed text to be
transmitted transparently the following procedures are used.
1. Before sending a line of mail text the sender-SMTP checks
the first character of the line. If it is a period, one
additional period is inserted at the beginning of the line.
2. When a line of mail text is received by the receiver-SMTP
it checks the line. If the line is composed of a single
period it is the end of mail. If the first character is a
period and there are other characters on the line, the first
character is deleted.
The mail data may contain any of the 128 ASCII characters. All
characters are to be delivered to the recipient's mailbox
including format effectors and other control characters. If
the transmission channel provides an 8-bit byte (octets) data
stream, the 7-bit ASCII codes are transmitted right justified
in the octets with the high order bits cleared to zero.
In some systems it may be necessary to transform the data as
it is received and stored. This may be necessary for hosts
that use a different character set than ASCII as their local
character set, or that store data in records rather than
<span class="grey">Postel [Page 41]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-42" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
strings. If such transforms are necessary, they must be
reversible -- especially if such transforms are applied to
mail being relayed.
4.5.3. SIZES
There are several objects that have required minimum maximum
sizes. That is, every implementation must be able to receive
objects of at least these sizes, but must not send objects
larger than these sizes.
****************************************************
* *
* TO THE MAXIMUM EXTENT POSSIBLE, IMPLEMENTATION *
* TECHNIQUES WHICH IMPOSE NO LIMITS ON THE LENGTH *
* OF THESE OBJECTS SHOULD BE USED. *
* *
****************************************************
user
The maximum total length of a user name is 64 characters.
domain
The maximum total length of a domain name or number is 64
characters.
path
The maximum total length of a reverse-path or
forward-path is 256 characters (including the punctuation
and element separators).
command line
The maximum total length of a command line including the
command word and the <CRLF> is 512 characters.
reply line
The maximum total length of a reply line including the
reply code and the <CRLF> is 512 characters.
[Page 42] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-43" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
text line
The maximum total length of a text line including the
<CRLF> is 1000 characters (but not counting the leading
dot duplicated for transparency).
recipients buffer
The maximum total number of recipients that must be
buffered is 100 recipients.
****************************************************
* *
* TO THE MAXIMUM EXTENT POSSIBLE, IMPLEMENTATION *
* TECHNIQUES WHICH IMPOSE NO LIMITS ON THE LENGTH *
* OF THESE OBJECTS SHOULD BE USED. *
* *
****************************************************
Errors due to exceeding these limits may be reported by using
the reply codes, for example:
500 Line too long.
501 Path too long
552 Too many recipients.
552 Too much mail data.
<span class="grey">Postel [Page 43]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-44" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
APPENDIX A
TCP Transport service
The Transmission Control Protocol [<a href="#ref-3">3</a>] is used in the ARPA
Internet, and in any network following the US DoD standards for
internetwork protocols.
Connection Establishment
The SMTP transmission channel is a TCP connection established
between the sender process port U and the receiver process port
L. This single full duplex connection is used as the
transmission channel. This protocol is assigned the service
port 25 (31 octal), that is L=25.
Data Transfer
The TCP connection supports the transmission of 8-bit bytes.
The SMTP data is 7-bit ASCII characters. Each character is
transmitted as an 8-bit byte with the high-order bit cleared to
zero.
[Page 44] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-45" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
APPENDIX B
NCP Transport service
The ARPANET Host-to-Host Protocol [<a href="#ref-4">4</a>] (implemented by the Network
Control Program) may be used in the ARPANET.
Connection Establishment
The SMTP transmission channel is established via NCP between
the sender process socket U and receiver process socket L. The
Initial Connection Protocol [<a href="#ref-5">5</a>] is followed resulting in a pair
of simplex connections. This pair of connections is used as
the transmission channel. This protocol is assigned the
contact socket 25 (31 octal), that is L=25.
Data Transfer
The NCP data connections are established in 8-bit byte mode.
The SMTP data is 7-bit ASCII characters. Each character is
transmitted as an 8-bit byte with the high-order bit cleared to
zero.
<span class="grey">Postel [Page 45]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-46" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
APPENDIX C
NITS
The Network Independent Transport Service [<a href="#ref-6">6</a>] may be used.
Connection Establishment
The SMTP transmission channel is established via NITS between
the sender process and receiver process. The sender process
executes the CONNECT primitive, and the waiting receiver
process executes the ACCEPT primitive.
Data Transfer
The NITS connection supports the transmission of 8-bit bytes.
The SMTP data is 7-bit ASCII characters. Each character is
transmitted as an 8-bit byte with the high-order bit cleared to
zero.
[Page 46] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-47" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
APPENDIX D
X.25 Transport service
It may be possible to use the X.25 service [<a href="#ref-7">7</a>] as provided by the
Public Data Networks directly, however, it is suggested that a
reliable end-to-end protocol such as TCP be used on top of X.25
connections.
<span class="grey">Postel [Page 47]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-48" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
APPENDIX E
Theory of Reply Codes
The three digits of the reply each have a special significance.
The first digit denotes whether the response is good, bad or
incomplete. An unsophisticated sender-SMTP will be able to
determine its next action (proceed as planned, redo, retrench,
etc.) by simply examining this first digit. A sender-SMTP 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 command has been accepted, but the requested action
is being held in abeyance, pending confirmation of the
information in this reply. The sender-SMTP should send
another command specifying whether to continue or abort
the action.
[Note: SMTP does not have any commands that allow this
type of reply, and so does not have the continue or
abort commands.]
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-SMTP 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
[Page 48] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-49" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
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- SMTPs) must
agree on the interpretation. Each reply in this category
might have a different time value, but the sender-SMTP 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
and 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-SMTP 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-SMTP 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 the account status).
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
transmission channel.
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
<span class="grey">Postel [Page 49]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-50" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
illustrates 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.
For example, a command such as NOOP whose successful execution
does not offer the sender-SMTP any new information will return
a 250 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.
The reply text may be longer than a single line; in these cases
the complete text must be marked so the sender-SMTP knows when it
can stop reading the reply. This requires a special format to
indicate a multiple line reply.
The format for multiline replies requires that every line,
except the last, begin with the reply code, followed
immediately by a hyphen, "-" (also known as minus), followed by
text. The last line will begin with the reply code, followed
immediately by <SP>, optionally some text, and <CRLF>.
For example:
123-First line
123-Second line
123-234 text beginning with numbers
123 The last line
In many cases the sender-SMTP then simply needs to search for
the reply code followed by <SP> at the beginning of a line, and
ignore all preceding lines. In a few cases, there is important
data for the sender in the reply "text". The sender will know
these cases from the current context.
[Page 50] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-51" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
APPENDIX F
Scenarios
This section presents complete scenarios of several types of SMTP
sessions.
A Typical SMTP Transaction Scenario
This SMTP example shows mail sent by Smith at host USC-ISIF, to
Jones, Green, and Brown at host BBN-UNIX. Here we assume that
host USC-ISIF contacts host BBN-UNIX directly. The mail is
accepted for Jones and Brown. Green does not have a mailbox at
host BBN-UNIX.
-------------------------------------------------------------
R: 220 BBN-UNIX.ARPA Simple Mail Transfer Service Ready
S: HELO USC-ISIF.ARPA
R: 250 BBN-UNIX.ARPA
S: MAIL FROM:<Smith@USC-ISIF.ARPA>
R: 250 OK
S: RCPT TO:<Jones@BBN-UNIX.ARPA>
R: 250 OK
S: RCPT TO:<Green@BBN-UNIX.ARPA>
R: 550 No such user here
S: RCPT TO:<Brown@BBN-UNIX.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 BBN-UNIX.ARPA Service closing transmission channel
Scenario 1
-------------------------------------------------------------
<span class="grey">Postel [Page 51]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-52" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
Aborted SMTP Transaction Scenario
-------------------------------------------------------------
R: 220 MIT-Multics.ARPA Simple Mail Transfer Service Ready
S: HELO ISI-VAXA.ARPA
R: 250 MIT-Multics.ARPA
S: MAIL FROM:<Smith@ISI-VAXA.ARPA>
R: 250 OK
S: RCPT TO:<Jones@MIT-Multics.ARPA>
R: 250 OK
S: RCPT TO:<Green@MIT-Multics.ARPA>
R: 550 No such user here
S: RSET
R: 250 OK
S: QUIT
R: 221 MIT-Multics.ARPA Service closing transmission channel
Scenario 2
-------------------------------------------------------------
[Page 52] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-53" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
Relayed Mail Scenario
-------------------------------------------------------------
Step 1 -- Source Host to Relay Host
R: 220 USC-ISIE.ARPA Simple Mail Transfer Service Ready
S: HELO MIT-AI.ARPA
R: 250 USC-ISIE.ARPA
S: MAIL FROM:<JQP@MIT-AI.ARPA>
R: 250 OK
S: RCPT TO:<@USC-ISIE.ARPA:Jones@BBN-VAX.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Date: 2 Nov 81 22:33:44
S: From: John Q. Public <JQP@MIT-AI.ARPA>
S: Subject: The Next Meeting of the Board
S: To: Jones@BBN-Vax.ARPA
S:
S: Bill:
S: The next meeting of the board of directors will be
S: on Tuesday.
S: John.
S: .
R: 250 OK
S: QUIT
R: 221 USC-ISIE.ARPA Service closing transmission channel
<span class="grey">Postel [Page 53]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-54" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
Step 2 -- Relay Host to Destination Host
R: 220 BBN-VAX.ARPA Simple Mail Transfer Service Ready
S: HELO USC-ISIE.ARPA
R: 250 BBN-VAX.ARPA
S: MAIL FROM:<@USC-ISIE.ARPA:JQP@MIT-AI.ARPA>
R: 250 OK
S: RCPT TO:<Jones@BBN-VAX.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Received: from MIT-AI.ARPA by USC-ISIE.ARPA ;
2 Nov 81 22:40:10 UT
S: Date: 2 Nov 81 22:33:44
S: From: John Q. Public <JQP@MIT-AI.ARPA>
S: Subject: The Next Meeting of the Board
S: To: Jones@BBN-Vax.ARPA
S:
S: Bill:
S: The next meeting of the board of directors will be
S: on Tuesday.
S: John.
S: .
R: 250 OK
S: QUIT
R: 221 USC-ISIE.ARPA Service closing transmission channel
Scenario 3
-------------------------------------------------------------
[Page 54] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-55" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
Verifying and Sending Scenario
-------------------------------------------------------------
R: 220 SU-SCORE.ARPA Simple Mail Transfer Service Ready
S: HELO MIT-MC.ARPA
R: 250 SU-SCORE.ARPA
S: VRFY Crispin
R: 250 Mark Crispin <Admin.MRC@SU-SCORE.ARPA>
S: SEND FROM:<EAK@MIT-MC.ARPA>
R: 250 OK
S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 SU-SCORE.ARPA Service closing transmission channel
Scenario 4
-------------------------------------------------------------
<span class="grey">Postel [Page 55]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-56" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
Sending and Mailing Scenarios
First the user's name is verified, then an attempt is made to
send to the user's terminal. When that fails, the messages is
mailed to the user's mailbox.
-------------------------------------------------------------
R: 220 SU-SCORE.ARPA Simple Mail Transfer Service Ready
S: HELO MIT-MC.ARPA
R: 250 SU-SCORE.ARPA
S: VRFY Crispin
R: 250 Mark Crispin <Admin.MRC@SU-SCORE.ARPA>
S: SEND FROM:<EAK@MIT-MC.ARPA>
R: 250 OK
S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
R: 450 User not active now
S: RSET
R: 250 OK
S: MAIL FROM:<EAK@MIT-MC.ARPA>
R: 250 OK
S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 SU-SCORE.ARPA Service closing transmission channel
Scenario 5
-------------------------------------------------------------
[Page 56] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-57" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
Doing the preceding scenario more efficiently.
-------------------------------------------------------------
R: 220 SU-SCORE.ARPA Simple Mail Transfer Service Ready
S: HELO MIT-MC.ARPA
R: 250 SU-SCORE.ARPA
S: VRFY Crispin
R: 250 Mark Crispin <Admin.MRC@SU-SCORE.ARPA>
S: SOML FROM:<EAK@MIT-MC.ARPA>
R: 250 OK
S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
R: 250 User not active now, so will do mail.
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 SU-SCORE.ARPA Service closing transmission channel
Scenario 6
-------------------------------------------------------------
<span class="grey">Postel [Page 57]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-58" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
Mailing List Scenario
First each of two mailing lists are expanded in separate sessions
with different hosts. Then the message is sent to everyone that
appeared on either list (but no duplicates) via a relay host.
-------------------------------------------------------------
Step 1 -- Expanding the First List
R: 220 MIT-AI.ARPA Simple Mail Transfer Service Ready
S: HELO SU-SCORE.ARPA
R: 250 MIT-AI.ARPA
S: EXPN Example-People
R: 250-<ABC@MIT-MC.ARPA>
R: 250-Fred Fonebone <Fonebone@USC-ISIQ.ARPA>
R: 250-Xenon Y. Zither <XYZ@MIT-AI.ARPA>
R: 250-Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA>
R: 250-<joe@foo-unix.ARPA>
R: 250 <xyz@bar-unix.ARPA>
S: QUIT
R: 221 MIT-AI.ARPA Service closing transmission channel
[Page 58] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-59" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
Step 2 -- Expanding the Second List
R: 220 MIT-MC.ARPA Simple Mail Transfer Service Ready
S: HELO SU-SCORE.ARPA
R: 250 MIT-MC.ARPA
S: EXPN Interested-Parties
R: 250-Al Calico <ABC@MIT-MC.ARPA>
R: 250-<XYZ@MIT-AI.ARPA>
R: 250-Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA>
R: 250-<fred@BBN-UNIX.ARPA>
R: 250 <xyz@bar-unix.ARPA>
S: QUIT
R: 221 MIT-MC.ARPA Service closing transmission channel
<span class="grey">Postel [Page 59]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-60" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
Step 3 -- Mailing to All via a Relay Host
R: 220 USC-ISIE.ARPA Simple Mail Transfer Service Ready
S: HELO SU-SCORE.ARPA
R: 250 USC-ISIE.ARPA
S: MAIL FROM:<Account.Person@SU-SCORE.ARPA>
R: 250 OK
S: RCPT TO:<@USC-ISIE.ARPA:ABC@MIT-MC.ARPA>
R: 250 OK
S: RCPT TO:<@USC-ISIE.ARPA:Fonebone@USC-ISIQA.ARPA>
R: 250 OK
S: RCPT TO:<@USC-ISIE.ARPA:XYZ@MIT-AI.ARPA>
R: 250 OK
S: RCPT
TO:<@USC-ISIE.ARPA,@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA>
R: 250 OK
S: RCPT TO:<@USC-ISIE.ARPA:joe@FOO-UNIX.ARPA>
R: 250 OK
S: RCPT TO:<@USC-ISIE.ARPA:xyz@BAR-UNIX.ARPA>
R: 250 OK
S: RCPT TO:<@USC-ISIE.ARPA:fred@BBN-UNIX.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 USC-ISIE.ARPA Service closing transmission channel
Scenario 7
-------------------------------------------------------------
[Page 60] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-61" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
Forwarding Scenarios
-------------------------------------------------------------
R: 220 USC-ISIF.ARPA Simple Mail Transfer Service Ready
S: HELO LBL-UNIX.ARPA
R: 250 USC-ISIF.ARPA
S: MAIL FROM:<mo@LBL-UNIX.ARPA>
R: 250 OK
S: RCPT TO:<fred@USC-ISIF.ARPA>
R: 251 User not local; will forward to <Jones@USC-ISI.ARPA>
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 USC-ISIF.ARPA Service closing transmission channel
Scenario 8
-------------------------------------------------------------
<span class="grey">Postel [Page 61]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-62" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
-------------------------------------------------------------
Step 1 -- Trying the Mailbox at the First Host
R: 220 USC-ISIF.ARPA Simple Mail Transfer Service Ready
S: HELO LBL-UNIX.ARPA
R: 250 USC-ISIF.ARPA
S: MAIL FROM:<mo@LBL-UNIX.ARPA>
R: 250 OK
S: RCPT TO:<fred@USC-ISIF.ARPA>
R: 251 User not local; will forward to <Jones@USC-ISI.ARPA>
S: RSET
R: 250 OK
S: QUIT
R: 221 USC-ISIF.ARPA Service closing transmission channel
Step 2 -- Delivering the Mail at the Second Host
R: 220 USC-ISI.ARPA Simple Mail Transfer Service Ready
S: HELO LBL-UNIX.ARPA
R: 250 USC-ISI.ARPA
S: MAIL FROM:<mo@LBL-UNIX.ARPA>
R: 250 OK
S: RCPT TO:<Jones@USC-ISI.ARPA>
R: OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 USC-ISI.ARPA Service closing transmission channel
Scenario 9
-------------------------------------------------------------
[Page 62] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-63" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
Too Many Recipients Scenario
-------------------------------------------------------------
R: 220 BERKELEY.ARPA Simple Mail Transfer Service Ready
S: HELO USC-ISIF.ARPA
R: 250 BERKELEY.ARPA
S: MAIL FROM:<Postel@USC-ISIF.ARPA>
R: 250 OK
S: RCPT TO:<fabry@BERKELEY.ARPA>
R: 250 OK
S: RCPT TO:<eric@BERKELEY.ARPA>
R: 552 Recipient storage full, try again in another transaction
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: MAIL FROM:<Postel@USC-ISIF.ARPA>
R: 250 OK
S: RCPT TO:<eric@BERKELEY.ARPA>
R: 250 OK
S: DATA
R: 354 Start mail input; end with <CRLF>.<CRLF>
S: Blah blah blah...
S: ...etc. etc. etc.
S: .
R: 250 OK
S: QUIT
R: 221 BERKELEY.ARPA Service closing transmission channel
Scenario 10
-------------------------------------------------------------
Note that a real implementation must handle many recipients as
specified in <a href="#section-4.5.3">Section 4.5.3</a>.
<span class="grey">Postel [Page 63]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-64" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
GLOSSARY
ASCII
American Standard Code for Information Interchange [<a href="#ref-1">1</a>].
command
A request for a mail service action sent by the sender-SMTP to the
receiver-SMTP.
domain
The hierarchially structured global character string address of a
host computer in the mail system.
end of mail data indication
A special sequence of characters that indicates the end of the
mail data. In particular, the five characters carriage return,
line feed, period, carriage return, line feed, in that order.
host
A computer in the internetwork environment on which mailboxes or
SMTP processes reside.
line
A a sequence of ASCII characters ending with a <CRLF>.
mail data
A sequence of ASCII characters of arbitrary length, which conforms
to the standard set in the Standard for the Format of ARPA
Internet Text Messages (<a href="./rfc822">RFC 822</a> [<a href="#ref-2">2</a>]).
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@domain". Additionally, the "container" in which mail
is stored.
[Page 64] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-65" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
receiver-SMTP process
A process which transfers mail in cooperation with a sender-SMTP
process. It waits for a connection to be established via the
transport service. It receives SMTP commands from the
sender-SMTP, sends replies, and performs the specified operations.
reply
A reply is an acknowledgment (positive or negative) sent from
receiver to sender via the transmission channel in response to a
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.
sender-SMTP process
A process which transfers mail in cooperation with a receiver-SMTP
process. A local language may be used in the user interface
command/reply dialogue. The sender-SMTP initiates the transport
service connection. It initiates SMTP commands, receives replies,
and governs the transfer of mail.
session
The set of exchanges that occur while the transmission channel is
open.
transaction
The set of exchanges required for one message to be transmitted
for one or more recipients.
transmission channel
A full-duplex communication path between a sender-SMTP and a
receiver-SMTP for the exchange of commands, replies, and mail
text.
transport service
Any reliable stream-oriented data communication services. For
example, NCP, TCP, NITS.
<span class="grey">Postel [Page 65]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-66" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
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.
word
A sequence of printing characters.
<CRLF>
The characters carriage return and line feed (in that order).
<SP>
The space character.
[Page 66] Postel</pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-67" ></span>
<a href="./rfc821">RFC 821</a> August 1982
Simple Mail Transfer Protocol
REFERENCES
[<a id="ref-1">1</a>] ASCII
ASCII, "USA Code for Information Interchange", United States of
America Standards Institute, X3.4, 1968. Also in: Feinler, E.
and J. Postel, eds., "ARPANET Protocol Handbook", NIC 7104, for
the Defense Communications Agency by SRI International, Menlo
Park, California, Revised January 1978.
[<a id="ref-2">2</a>] <a href="./rfc822">RFC 822</a>
Crocker, D., "Standard for the Format of ARPA Internet Text
Messages," <a href="./rfc822">RFC 822</a>, Department of Electrical Engineering,
University of Delaware, August 1982.
[<a id="ref-3">3</a>] TCP
Postel, J., ed., "Transmission Control Protocol - DARPA Internet
Program Protocol Specification", <a href="./rfc793">RFC 793</a>, USC/Information Sciences
Institute, NTIS AD Number A111091, September 1981. Also in:
Feinler, E. and J. Postel, eds., "Internet Protocol Transition
Workbook", SRI International, Menlo Park, California, March 1982.
[<a id="ref-4">4</a>] NCP
McKenzie,A., "Host/Host Protocol for the ARPA Network", NIC 8246,
January 1972. Also in: Feinler, E. and J. Postel, eds., "ARPANET
Protocol Handbook", NIC 7104, for the Defense Communications
Agency by SRI International, Menlo Park, California, Revised
January 1978.
[<a id="ref-5">5</a>] Initial Connection Protocol
Postel, J., "Official Initial Connection Protocol", NIC 7101,
11 June 1971. Also in: Feinler, E. and J. Postel, eds., "ARPANET
Protocol Handbook", NIC 7104, for the Defense Communications
Agency by SRI International, Menlo Park, California, Revised
January 1978.
[<a id="ref-6">6</a>] NITS
PSS/SG3, "A Network Independent Transport Service", Study Group 3,
The Post Office PSS Users Group, February 1980. Available from
the DCPU, National Physical Laboratory, Teddington, UK.
<span class="grey">Postel [Page 67]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-68" ></span>
<span class="grey">August 1982 <a href="./rfc821">RFC 821</a></span>
Simple Mail Transfer Protocol
[<a id="ref-7">7</a>] X.25
CCITT, "Recommendation X.25 - Interface Between Data Terminal
Equipment (DTE) and Data Circuit-terminating Equipment (DCE) for
Terminals Operating in the Packet Mode on Public Data Networks,"
CCITT Orange Book, Vol. VIII.2, International Telephone and
Telegraph Consultative Committee, Geneva, 1976.
[Page 68] Postel
</pre>
|