Re: [twsocket] smtp component not connected/ready

2008-01-07 Thread retnyg
hi,

i changed the code as follows:

procedure TMailer.SmtpClientRequestDone;

  function isError : boolean;
  begin
result := false;
if ((Error  399) and (Error  600)) or (error = 1) then result := 
true;
if result then if assigned(FOnError) then  FOnError(FSmtp.ErrorMessage);
  end;

begin
  // it is possible that an exception arises here : smtp component not 
connected so
  with FSmtp do begin
if isError then Rset
else
if not Connected then exit //Rset // fehlerbehandlung einbauen
else
case RqType of
  smtpConnect:
  begin
if AuthType = smtpAuthNone then Helo else Ehlo;
  end;
  smtpHelo: MailFrom;
  smtpEhlo: Auth;
  smtpAuth: MailFrom;
  smtpMailFrom: RcptTo;
  smtpRcptTo: Data;
  smtpData: Quit;
//  smtpRset: Quit;
//  smtpQuit: begin
//FBusy := false;
//if assigned(FOnMailSent) then FOnMailSent(FMailId);
//  end;
end;
  end;
end;


still i get the error smtp component not connected, even if i check
explicitly for it.

any ideas ?

tia, retnyg


AG [EMAIL PROTECTED] wrote:
 hi there,
 
 is there also such a known bug in smtpprot.pas ?

AG No known issues. Please check your code. An error is anything  0!
AG This can be a winsock error code  1 or an SMTP error
AG code. The action to be taken depends on both current request
AG type and error code, read the RFCs for a description of SMTP
AG error codes. Also a reconnect should never be tried by calling
AG Connect from a component event handler but by posting a 
AG custom message, in the message handler calling Connect is safe. 

AG --
AG Arno Garrels [TeamICS]
AG http://www.overbyte.be/eng/overbyte/teamics.html


 (testing with a gmx account)
 my app receives mail through pop3prot.pas then forwards them through
 smtpprot.pas.
 
 at first i received the exception smtp component not connected in
 smtpclientrequestdone, now i built in a check if not connected, now i
 receive smtp component not ready.
 
 procedure TMailer.SmtpClientRequestDone;
 
   function isError : boolean;
   begin
 result := false;
 if (Error  399) and (Error  600) then result := true;
 if result then if assigned(FOnError) then 
 FOnError(FSmtp.ErrorMessage);   end;
 
 begin
   // it is possible that an exception arises here : smtp component
 not connected so   with FSmtp do begin
 if isError then Rset
 else
 if not Connected then Connect
 else
 case RqType of
   smtpConnect:
   begin
 if AuthType = smtpAuthNone then Helo else Ehlo;
   end;
 
 
 tia, retnyg



-- 
Mit freundlichen Grüßen
[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] smtp component not connected/ready

2008-01-07 Thread DZ-Jay

On Jan 7, 2008, at 06:56, Wilfried Mestdagh wrote:

 You call RSet if you have an error. If you have an error just call 
 Abort
 and try later again. Also check on any error, not only between those
 values:

 if Error  0 then begin
FSmtp.Abort;
SetSomeRetryMechanism; // retry with a timer or by posting a message
Exit;
 end;

You could call RSet if the error is between 500..599, which means a 
protocol error.  That way you could start the SMTP session anew.  
Anything else, you should call abort and retry like Wilfried says:

If (Error In [500..599]) Then Begin
FSmtp.RSet;
Exit;
End Else If (Error  0) Then Begin
FSmtp.Abort;
SetSomeRetryMechanism();
Exit;
End;

// No error occurred, do the normal stuff
// ...

But don't forget that RSet will reset the session to the point where 
you logged in, so you should treat it the same as your last log in 
command, which in your case is Auth:

case RqType of
smtpConnect:
begin
if AuthType = smtpAuthNone then Helo else Ehlo;
end;
smtpHelo: MailFrom;
smtpEhlo: Auth;

// Rset will return to this point
smtpAuth,
smtpRset: MailFrom;
...

dZ.

-- 
DZ-Jay [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be