2011-10-16 22 views
3

我將用戶的輸入作爲電子郵件的內容發送到文本框中,並通過SMTP將其發送到套接字上。我正在用Java來做這件事。然而,就是當用戶輸入的輸入,如...郵件內容中的全部內容被SMTP視爲最後一行

<CLRF> 
. 
<CLRF> 
Other content blah blah blah... 

採用的是全站的最後一行,然後在它下面的內容將不會被傳遞的SMTP!我怎樣才能讓SMTP知道全站是電子郵件內容的一部分,而不是電子郵件已經結束的跡象?

回答

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

3

RFC 821解決了這個確切的問題Section 4.5.2

沒有一些規定數據透明度字符序列「」結束郵件文本並且不能由用戶發送。一般來說,用戶不知道這樣的「禁止」序列。爲了允許所有用戶組成的文本透明地傳輸,使用以下過程。

  1. 在發送一行郵件文本之前,sender-SMTP檢查該行的第一個字符。如果是一個時間段,則在該行的開頭插入一個附加時間段。

  2. 當收件人SMTP收到一行郵件文本時,它會檢查該行。如果該行由單個時段組成,則它是郵件的結束。如果第一個字符是一個句點,並且該行上還有其他字符,則會刪除第一個字符。

+1

贏得33秒。尼斯。 :) – sarnold

+0

這就是爲什麼你保存之前完成鍵入你的答案(: – Jacob