Advertisement
TLama

Untitled

Nov 13th, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.16 KB | None | 0 0
  1. uses
  2.   IdReplySMTP;
  3.  
  4. procedure TForm1.IdSMTPServer1Connect(AContext: TIdContext);
  5. var
  6.   Reply: TIdReplySMTP;
  7. begin
  8.   if IPTemporaryBanned(AContext.Binding.PeerIP) then
  9.   begin
  10.     Reply := TIdReplySMTP.Create(nil);
  11.     try
  12.       if not TIdSMTPServerContext(AContext).Ehlo then
  13.         Reply.SetReply(421, 'IP temporarily banned.')
  14.       else
  15.         Reply.SetEnhReply(421, '4.2.1', 'IP temporarily banned.');
  16.       AContext.Connection.IOHandler.Write(Reply.FormattedReply);
  17.     finally
  18.       Reply.Free;
  19.     end;
  20.     raise Exception.Create('IP temporarily banned.');
  21.   end;
  22. end;
  23.  
  24. // or optionally
  25. procedure TForm1.IdSMTPServer1Connect(AContext: TIdContext);
  26. var
  27.   Reply: TIdReplySMTP;
  28. begin
  29.   if IPTemporaryBanned(AContext.Binding.PeerIP) then
  30.   begin
  31.     Reply := TIdReplySMTP.Create(nil);
  32.     try
  33.       Reply.Code := 421;
  34.       Reply.Text.Text := 'IP temporarily banned.';
  35.       if TIdSMTPServerContext(AContext).Ehlo then
  36.         Reply.EnhancedCode.ReplyAsStr := '4.2.1';
  37.       AContext.Connection.IOHandler.Write(Reply.FormattedReply);
  38.     finally
  39.       Reply.Free;
  40.     end;
  41.     raise Exception.Create('IP temporarily banned.');
  42.   end;
  43. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement