Sending text data WriteLn

Giganews Newsgroups
Subject: Sending text data WriteLn
Posted by:  Alexander Telegin (sitemast…@NOSPAMgmx.li)
Date: Tue, 29 Jun 2004

Hello,

I have strange situation when I'm trying to send raw email data with
following code:

FSMTPConnection.WriteLn(ABuffer + EOL + '.');

Most of the time this code works perfectly until message contain the line,
beginning with '.' The dot is stripping somewhere inside WriteLn, and it
makes some quoted-printable attachments corrupted. I've checked TIdSMTP
sources and found that Indy use interesting code to send text data:

procedure TIdMessageClient.WriteBodyText(AMsg: TIdMessage);
var
  i: integer;
begin
  for i := 0 to AMsg.Body.Count - 1 do
  begin
    if Copy(AMsg.Body[i], 1, 1) = '.' then
    begin
      WriteLn('.' + AMsg.Body[i]);
    end  begin
      WriteLn(AMsg.Body[i]);
    end;
  end;
end;

Question: why it's necessary to replace single dot with double dots and can
I avoid this by changing some sources lower WriteLn? I wouldn't like to
split my string ABuffer on lines (some emails may exceed 5MB) and check
first character for '.'.

Thanks,
Alex

Replies