Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses
- IdReplySMTP;
- procedure TForm1.IdSMTPServer1Connect(AContext: TIdContext);
- var
- Reply: TIdReplySMTP;
- begin
- if IPTemporaryBanned(AContext.Binding.PeerIP) then
- begin
- Reply := TIdReplySMTP.Create(nil);
- try
- if not TIdSMTPServerContext(AContext).Ehlo then
- Reply.SetReply(421, 'IP temporarily banned.')
- else
- Reply.SetEnhReply(421, '4.2.1', 'IP temporarily banned.');
- AContext.Connection.IOHandler.Write(Reply.FormattedReply);
- finally
- Reply.Free;
- end;
- raise Exception.Create('IP temporarily banned.');
- end;
- end;
- // or optionally
- procedure TForm1.IdSMTPServer1Connect(AContext: TIdContext);
- var
- Reply: TIdReplySMTP;
- begin
- if IPTemporaryBanned(AContext.Binding.PeerIP) then
- begin
- Reply := TIdReplySMTP.Create(nil);
- try
- Reply.Code := 421;
- Reply.Text.Text := 'IP temporarily banned.';
- if TIdSMTPServerContext(AContext).Ehlo then
- Reply.EnhancedCode.ReplyAsStr := '4.2.1';
- AContext.Connection.IOHandler.Write(Reply.FormattedReply);
- finally
- Reply.Free;
- end;
- raise Exception.Create('IP temporarily banned.');
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement