A number of buffers need to be kept between commands. These hold the forward and reverse paths, and the mail data. This can be seen in 4.1.1.
RFC Text
A mail transaction involves several data objects that 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 that 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.
Lines must end with CRLF per 2.3.8.
RFC Text
Lines consist of zero or more data characters terminated by the sequence ASCII character "CR" (hex value 0D) followed immediately by ASCII character "LF" (hex value 0A). This termination sequence is denoted as in this document. Conforming implementations MUST NOT recognize or generate any other character or character sequence as a line terminator. Limits MAY be imposed on line lengths by servers (see Section 4).
Commands in RFC 5321. The descriptions are not complete, but should currently be at least enough to implement these commands correctly enough for an MVP.
Used to identity the client. Must be sent before a mail transaction is started.
Prefer EHLO
for modern client implementation.
This command may appear anywhere.
The domain of the client.
helo = "HELO" SP Domain CRLF
Used to identify the client. This can be sent instead of HELO
. The server should
respond with supported extensions.
This command may appear anywhere.
The domain or address (IPv4/IPv6) of the client.
ehlo = "EHLO" SP ( Domain / address-literal ) CRLF
Error if no service extensions.
RFC Text
If the SMTP server, in violation of this specification, does not support any SMTP service extensions, it will generate an error response.
If there are service extensions, 250-Domain
and then 250-KEYWORD
for each extension,
indicating the last one by removing the hyphen: 250 KEYWORD
.
Full Response Grammar
ehlo-ok-rsp = ( "250" SP Domain [ SP ehlo-greet ] CRLF )
/ ( "250-" Domain [ SP ehlo-greet ] CRLF
*( "250-" ehlo-line CRLF )
"250" SP ehlo-line CRLF )
ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127)
; string of any characters other than CR or LF
ehlo-line = ehlo-keyword *( SP ehlo-param )
ehlo-keywor = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-")
; additional syntax of ehlo-params depends on
; ehlo-keyword
ehlo-param = 1*(%d33-126)
; any CHAR excluding <SP> and all
; control characters (US-ASCII 0-31 and 127
; inclusive)
On success, clear all buffers as if RSET
was received.
On failure, leave the buffers as they are.
Used to start a mail transaction.
You must not send another MAIL
command if
a transaction is open. If a server receives this command while a transaction
is ongoing, the server should return a 503
for commands out of order.
The reverse path (sender's address).
mail = "MAIL FROM:" Reverse-path [SP Mail-parameters] CRLF
On success, clear all buffers and enter the reverse path into the reverse path buffer. On failure no buffers should be cleared and the server should stay in the same state.
Used to identify an individual recipient of mail data.
This command may be sent multiple times to indicate multiple recipients.
The forward path (receiver's address).
rcpt = "RCPT TO:" ( "<Postmaster@" Domain ">" / "<Postmaster>" /
Forward-path ) [SP Rcpt-parameters] CRLF
Note that, in a departure from the usual rules for local-parts, the "Postmaster" string shown above is treated as case-insensitive.
Used to indicate that the incoming data is the mail data.
To indicate an end to mail data, a line with a single period is sent. That is,
mail data is known to be finished when the sequence <CRLF>.<CRLF>
is seen.
data = "DATA" CRLF
Servers should send a 354
which means "start mail input".
Used to reset the SMTP servers state and buffers as if it just received
a HELO
/EHLO
command.
This command may be sent at any time.
rset = "RSET" CRLF
Servers must respond with a success (250
)
All buffers are cleared and the start is reset as if the client has just introduced itself.
Used to ask the server if the argument identifies a user or mailbox.
A string for the server to lookup, possibly identifying a user or mailbox.
vrfy = "VRFY" SP String CRLF
Used to ask the server if the argument is a valid mailing list and, if so, to return the members of that list.
A string for the server to lookup, possibly identifying a mailing list.
expn = "EXPN" SP String CRLF
Used to get helpful information.
If present, it should be a command name you'd like help text for.
help = "HELP" [ SP String ] CRLF
A no-operation command.
If present, they should be ignored.
noop = "NOOP" [ SP String ] CRLF
The OK status code, 250
.
The end of the connection.
This command may be sent at any time. Any in-progress transaction should be aborted.
quit = "QUIT" CRLF
The "service closing" status code, 221
.