Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdSmtpServer not freeing threads
#10
(10-26-2018, 02:29 AM)bluewwol Wrote: I dropped a log intercept on the server and trapped the following:
...
What I observe here in that the threads that are hanging originate from gmail.  while from some others succeeds just fine.  The GMail thread sends the reply back to google that the address is ok, google (hotmail too) never respond after that.  they do not disconnect either.

Setting a reasonable ReadTimeout for each client connection would handle that scenario. I seriously doubt that a high-profile email provider like GMail or Hotmail would exhibit behavior like this, though.

Did you verify the hung clients are REALLY who they claim to be?  You can perform a reverse DNS lookup on the client's IP address to get its actual hostname so you can check its domain name.

Optionally, also use the OnSPFCheck event to check if that hostname is authentic.  Just because a client claims to be Google or Hotmail does not mean it REALLY is.

For example:

Code:
type
 TmySmtpItem = class
   ...
   HostName: string;
 end;

procedure TdSmtpServ.WwolSmtpServConnect(AContext: TContext);
begin
 // FYI, I would suggest deriving a new class from TIdSMTPServerContext
 // and assign it to the TIdSMTPServer.ContextClass property, instead of
 // using the TIdContext.Data property...
 ASender.Data := TmySmtpItem.Create;
 ...
 with AContext.Binding do
   TmySmtpItem(ASender.Data).HostName := GStack.HostByAddress(PeerIP, IPVersion);
end;

procedure TdSmtpServ.WwolSmtpServSPFCheck(ASender: TIdSMTPServerContext;
 const AIP, ADomain, AIdentity: String; var VAction: TIdSPFReply);
begin
 // perform a DNS query, such as with TIdDNSResolver, on the client's hostname
 // to check for the existence of valid SPF records that validate the client really
 // does belong to the domain that it claims.  Read RFCs 4405-4408 for more details.
 //
 // AIP is the client's actual IP address.
 // ADomain is the domain to query.
 // AIdentity is the identity to check that domain for.
 // ASender.HeloString is the identity the client claims to be (AIdentity is this string for HELO/EHLO commands).
 // TmySmtpItem(ASender.Data).HostName is the client's actual hostname

 VAction := ...;
 // set to the result of the validation. spfNeutral is the default.
 // spfNone, spfNeutral, spfPass, and spfSoftFail are success actions.
 // spfFail, spfTempError, and spfPermErrorand are failure actions.
end;

Reply


Messages In This Thread
TIdSmtpServer not freeing threads - by bluewwol - 10-24-2018, 05:04 PM
RE: TIdSmtpServer not freeing threads - by rlebeau - 10-26-2018, 08:14 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)