Here is how to encode a message. Insert a dot in front of any line that already starts with a dot. Concatenate all the lines, with \015\012 between each pair of lines; the result ends with \015\012 (unless the original message had no lines), since the final line is empty. Append a dot followed by \015\012.
This encoding is self-delimiting. An encoded message ends with the five-byte sequence "\015\012.\015\012", and does not contain the same sequence anywhere else. (Exception: the three-byte sequence ".\015\012" is an encoded message, representing a zero-line message.)
For example, the string "This is a test.\015\012.... Three dots\015\012.\015\012" is an encoded message. It represents the three-line text message
This is a test. ... Three dotswhich under Windows would be stored as the string "This is a test.\015\012... Three dots\015\012". Notice that the encoded message starts with four dots on the second line.
RFC 1123 says that ``mailer software MUST be able to send and receive messages of at least 64K bytes in length (including header), and a much larger maximum size is highly desirable.''