Abstract error when sned mail by IdSmtp

Giganews Newsgroups
Subject: Abstract error when sned mail by IdSmtp
Posted by:  Avi Jackobson (omerso…@inter.net.il)
Date: Sat, 4 Jul 2009

Hello ,

I'm using d7 and indy10 components.

Try to create app that send mails with attach file from host Smtp.Gmail.Com.

Email Demo App Taken form indy10demo use TIdSMTP & TIdMessage.

Set  the  next values :
          idSMTP.Host  :=  'smtp.gmail.com';
          idSMTP.Port  :=  25;  //smtp service usually runs on this port , 467 ?  / 587 ?

          idSMTP.Username  :=  -> 'My Account In Gmail'
          idSMTP.Password  := ->  'My Psw';

When run i recieve the message -> "Must issue a STARTTLS command first"

I follow the Instruction from indy knowlege base
{}
Indy 10 supports SMTP with explicit TLS.  In the Indy 10's TIdSMTP, you simply have to assign a TIdSSLIOHandlerSocketBase descendent to the TIdSMTP.IOHandler property and set the UseTLS property to either utUseRequireTLS if you do not want to use an unencrypted connection or utUseExplicitTLS if you are willing to use an unencrypted connection
{}

I Add :
          idSMTP.IOHandler := TIdSSLIOHandlerSocketBase.Create(nil);
          idSMTP.UseTLS := utUseRequireTLS;
                    // more options ->  utUseExplicitTLS;  -> utNoTLSSupport

Now when run I recieve the Error -> "Abstract Error"

Trace the source during runing  -> The Error Occure in SendGreeting -> unit IdSMTPBase

Program flow :
    try
      idSMTP.Connect;
      idSMTP.send(idmessage);
    except

when idSMTP.Connect; excuted -> SendGreeting Ok !

the error apear when idSMTP.send(idmessage);

    when the function <(SendCmd('EHLO ' + LNameToSend )>    excuted

{}  snip form  SendGreeting
    LNameToSend := GStack.HostName;
    if LNameToSend = '' then
    begin
      LNameToSend := IndyComputerName;
    end;
  end;

  if UseEhlo and (SendCmd('EHLO ' + LNameToSend ) = 250) then begin
                                  //APR: user can prevent EHLO    {Do not Localize}
    Capabilities.AddStrings(LastCmdResult.Text);
    if Capabilities.Count > 0 then begin
      //we drop the initial greeting.  We only want the feature list
      Capabilities.Delete(0);
    end;

function TIdTCPConnection.SendCmd(AOut: string; const AResponse: Array of SmallInt;
  AEncoding: TIdTextEncoding = nil): SmallInt;
begin
  CheckConnected;
  PrepareCmd(AOut);
  IOHandler.WriteLn(AOut, AEncoding);    <---  the error occure in this line ,AOut contain -> 'EHLO + computer name' & AEncoding = nil
  Result := GetResponse(AResponse, AEncoding);
end;
{}

Any Idea How To Solve This Issue ?

TIA

Avi Jackobson

(I Post Also At Embarcadero Forum)

Replies