我将文本框中的用户输入作为电子邮件的内容发送,并通过SMTP通过套接字发送。我在Java中这样做。但是,当用户输入诸如......
之类的输入时<CLRF>
.
<CLRF>
Other content blah blah blah...
SMTP将该句号作为最后一行,然后下面的内容将不会被传递!我怎样才能让SMTP知道整站是电子邮件内容的一部分而不是电子邮件已经结束的迹象?
答案 0 :(得分:4)
只需添加另一个句号。
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.
有关详细信息,请参阅RFC 2821。
答案 1 :(得分:3)
没有为数据透明提供一些条款“。”结束邮件文本,用户无法发送。通常,用户不知道这种“禁止”序列。为了允许透明地传输所有用户组合文本,使用以下过程。
在发送一行邮件文本之前,sender-SMTP会检查该行的第一个字符。如果是句号,则在该行的开头插入一个额外的句号。
- 醇>
当接收方 - SMTP接收到一行邮件文本时,它会检查该行。如果该行由单个句点组成,则它是邮件的结尾。如果第一个字符是句点,并且该行上还有其他字符,则删除第一个字符。