Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full-stop in mail content is treated by SMTP as last line

Tags:

java

sockets

smtp

I am sending the user's input in a textbox as an email's content and send it over the socket through SMTP. I'm doing this in Java. However, the thing is when the user enters input such as...

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

The SMTP takes that full-stop as the last line and then the contents below it will not be delivered! How can I let SMTP know that the full-stop is part of the content of the email and not an indication that email has ended?

like image 249
Carven Avatar asked Oct 20 '25 17:10

Carven


1 Answers

Simply add another period.

4.5.2 Transparency

   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.

For full details, see RFC 2821.

like image 51
sarnold Avatar answered Oct 23 '25 05:10

sarnold



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!