Re: Infinite Loop in Indy SMTP-Relay Demo? (MORE INFO)

Giganews Newsgroups
Subject: Re: Infinite Loop in Indy SMTP-Relay Demo? (MORE INFO)
Posted by:  Julz (SundayMorni…@xtra.co.nz)
Date: Wed, 22 Jun 2005

The loop appears to be in the recursive procedure "InternalSend"

Internal send calls itself, with one of the parameters being:
AEmailAddresses: TIdEMailAddressList;

The procedure should exit when AEmailAddresses.count=0
However I dont see anywhere (obvious) in the function that decrements the
items in AEmailAddresses, so I dont see how the terminating case could ever
occur.

Any suggetions? This is the first time I have ever used Indy.

Procedure pasted below. Look for: //****

Kind Regards,

Julz.

  procedure InternalSend(const AMsg: TIdMessage;const AEmailAddresses:
TIdEMailAddressList);
  var
    ServerIndex:Integer;
  begin
    if AEmailAddresses.Count = 0 then  //****
    begin                                              //****
      Exit;                                              //****
    end;                                                //****
    if Assigned(FOnDirectSMTPStatus) then
    begin
      FOnDirectSMTPStatus(Self, AEmailAddresses[0], dmWorkBegin);
    end;
    try
      try
        if Assigned(FOnDirectSMTPStatus) then
        begin
          FOnDirectSMTPStatus(Self, AEmailAddresses[0], dmResolveMS);
        end;
        ResolveMXServers(AEMailAddresses[0].Address);
      ServerIndex:=0;

      if Assigned(FOnDirectSMTPStatus) then
        begin
          FOnDirectSMTPStatus(Self, AEmailAddresses[0], dmConecting);
        end;
        while (ServerIndex<=FMXServerList.Count-1) and not Connected do
begin
          FHost := FMXServerList[ServerIndex];
          Connect(AEmailAddresses[0]);
        end;

        if not Connected then
        begin
          raise
EIdTCPConnectionError.Create(Format(RSDirSMTPCantConnectToSMTPSvr,[AEmailAddresses[0].Address]));
        end;
        if Assigned(FOnDirectSMTPStatus) then
        begin
          FOnDirectSMTPStatus(Self, AEmailAddresses[0], dmConected);
        end;
      if Assigned(FOnDirectSMTPStatus) then
        begin
          FOnDirectSMTPStatus(Self, AEmailAddresses[0], dmSending);
        end;
        if MailAgent <>'' then
        begin
          AMsg.ExtraHeaders.Values[XMAILER_HEADER] := MailAgent;
        end;
        InternalSend(AMsg,AEmailAddresses);//****
        With FStatusList.Add do
        begin
          EmailAddress:=AEmailAddresses[0].Address;
          Sent:=True;
        end;
      if Assigned(FOnDirectSMTPStatus) then
        begin
          FOnDirectSMTPStatus(Self, AEmailAddresses[0], dmWorkEndOK);
        end;
      except
        on E : Exception do
        begin
          ProcessException(E,AEmailAddresses[0]);
        end;
      end;
    finally
      Disconnect;
    end;
  end;

"Julz" <SundayMorni…@xtra.co.nz> wrote in message
news:09F8E6FD8ECFE240SundayMorni…@xtra.co.nz...
> Good day all,
>
> I am running indy 10 with delphi 7.
>
> When I compile and run the IdSMTPRelay demo from the indy site, it appears
> to have an infinite loop? This occurs when "IdSMTPRelay1.Send(IdMessage)
> is called"
>
> The symptom of the loop is:
> (a) the code never progresses past the "Send" call
> (b) the OnDirectSMTPStatus event is fired again & again & again...
>
> I have altered nothing in the demo code.
>
> Any suggestions?
>
> Kind Regards,
>
> Julz.

Replies

None

In response to

Infinite Loop in Indy SMTP-Relay Demo? posted by Julz on Wed, 22 Jun 2005