4.1.2. コマンド構文
コマンドは、コマンド・コードとそれに続く引数フィールドで構成される。コマンド・コードは 4 文字の英字である。英字の大文字と小文字は同一に扱う。したがって、次のいずれも mail コマンドを表しうる。
MAIL Mail mail MaIl mAIl
これは、forward-path の "TO" や "to" のように、パラメータ値を表す記号にも当てはまる。コマンド・コードと引数フィールドは、一つ以上の空白で区切る。ただし、reverse-path と forward-path の引数の内部では、大文字・小文字が重要である。特に、ホストによってはユーザー "smith" とユーザー "Smith" は別のユーザーである。
引数フィールドは、文字シーケンス <CRLF> で終わる可変長の文字列で構成される。受信側は、このシーケンスを受信するまで何の動作も行わない。
角括弧は、任意指定の引数フィールドを表す。そのオプションを指定しない場合は、適切な既定値が暗黙に適用される。
SMTP コマンドは次のとおりである。
HELO <SP> <host> <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>
上記の引数フィールドの構文を (該当する場合は BNF 表記を用いて) 以下に示す。"..." 表記は、フィールドを一回以上繰り返してよいことを示す。
<reverse-path> ::= <path>
<forward-path> ::= <path>
<path> ::= "<" ["@" <host> "," ...] <mailbox> ">"
<host> ::= <a> <string> | "#" <number> | "[" <dotnum> "]"
<mailbox> ::= <user> "@" <host>
<user> ::= <string>
<string> ::= <char> | <char> <string>
<char> ::= <c> | '\' <c> | '\' <s>
<dotnum> ::= <snum> "." <snum> "." <snum> "." <snum>
<number> ::= <d> | <d> <number>
<snum> ::= 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 except
<specials>
<d> ::= any one of the ten digits 0 through 9
<s> ::= any one of <specials>
<specials> ::= '<', '>', '(', ')', '\', ',', ';', ':', '@',
'"', and the control characters (ASCII codes 0 through 37
octal inclusive and 177 octal)
バックスラッシュ '\' は引用文字であり、次の文字を (通常の解釈ではなく) 文字どおりに用いることを示すために使う。例えば "Joe\,Smith" は、カンマが 4 文字目にある 9 文字の単一のユーザー・フィールドを示すために使える。
ホストは一般に名前で知られており、その名前は各ホスト内でアドレスに変換される。ホストが変換機能に知られていないために通信が妨げられることがある。この障壁を回避するため、ホストの「名前」には二つの数値形式も許されている。一つは、ポンド記号 "#" を前置した十進整数で、その数がホストのアドレスであることを示す。もう一つは、ドットで区切って括弧で囲んだ四つの小さな十進整数 (例: "[123.255.37.2]") で、4 個の 8 ビット・フィールドからなる 32 ビットの ARPA インターネット・アドレスを示す。
タイムスタンプ行と戻りパス行は、次のように形式的に定義される。
<return-path-line> ::= "Return-Path:" <SP><reverse-path><CRLF>
<time-stamp-line> ::= "Mail-From:" <SP> <stamp> <CRLF>
<stamp> ::= [<ptcl>] <from-host> <this-host> <daytime>
<ptcl> ::= <protocol> <SP> "host" <SP>
<from-host> ::= <host> <SP>
<this-host> ::= "received by" <SP> <host> <SP>
<protocol> ::= "TCP" | "NCP" | "NITS" | "X25" | "INTERNET" |
"ARPANET"
Note: INTERNET = TCP, ARPANET = NCP, and if the <ptcl> is
not present INTERNET is assumed.
<daytime> ::= "at" <SP> <date> <SP> <time>
<date> ::= <dd> "-" <mon> "-" <yy>
<time> ::= <hh> ":" <mm> ":" <ss> "-" <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 01 to 99.
<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> ::= a time zone designator (as in [2]) or "UT" for
Universal Time (the default).
戻りパスの例:
Return-Path: <@CHARLIE,@BAKER,JOE@ABLE>
Mail-From の例:
Mail-From: ABC received by XYZ at 22-OCT-81 09:23:59-PDT