SMTP 将邮件内容中的句号视为最后一行

Car*_*ven 4 java sockets smtp

我将用户在文本框中的输入作为电子邮件内容发送,并通过 SMTP 通过套接字发送。我正在用 Java 做这个。然而,问题是当用户输入诸如......

<CLRF>
.
<CLRF>
Other content blah blah blah...
Run Code Online (Sandbox Code Playgroud)

SMTP 将该句号作为最后一行,然后其下面的内容将不会被传送!如何让 SMTP 知道句号是电子邮件内容的一部分,而不是表明电子邮件已结束?

sar*_*old 6

只需添加另一个句点即可。

4.5.2 透明度

   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:

   -  Before sending a line of mail text, the SMTP client checks the
      first character of the line.  If it is a period, one additional
      period is inserted at the beginning of the line.

   -  When a line of mail text is received by the SMTP server, it checks
      the line.  If the line is composed of a single period, it is
      treated as the end of mail indicator.  If the first character is a
      period and there are other characters on the line, the first
      character is deleted.
Run Code Online (Sandbox Code Playgroud)

有关完整详细信息,请参阅RFC 2821