I have a log for a simple SMTP transaction. (Its a bit long so access it here ). It shows the exchange of low-level handshakes such as HELO
, MAIL
, etc.
When the server which is supposed to receive an email is ready to accept email data, it send the following (line 12 in the log):
RawSmtp Information: 0 : << 354 Start mail input; end with <CRLF>.<CRLF>
However, the end of transmission is a bit confusing (lines 74/75):
RawSmtp Information: 0 : >> cannot foresee
RawSmtp Information: 0 : >>
RawSmtp Information: 0 : << 250 OK
which when viewed in notepad looks like:
The code however is simply written like this:
WriteResponse(writer, "354 Start mail input; end with <CRLF>.<CRLF>");
string line;
while ((line = reader.ReadLine()) != null && line != ".")
{
//do stuff
}
Is that standard? I mean sending something like <CRLF>.<CRLF>
and only checking for the dot ( .
)...?
It is checking for a whole line with just a .
in it. This is the standard technique for indicating the end of a DATA section. See here .
Also, as @jstedfast points out, the StreamReader.ReadLine()
method removes the "\\r\\n"
end-of-line sequence from the strings that it returns, so in that case, the resulting string will be "."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.