oGeoip is working because I do print some messages in the hmailserver_events.log in the script, no messages from the AutoBan function though even though I know that it is called after some of the messages that I print from the script before calling the function.

No Ip is added in IpRanges. Checked the temp folder in hMailServer and no autolock.lck file was created automaticaly, created it myself. Checked the permission and the SYSTEM account, the one that hMailServer is running under, has read/write permission on Temp folder.

This is really odd. I used to do autoban with the following function, without LockFile and everything was working:

At 4-5 hours hMailServer just stops working without any errors, I had only Application and SMTP logging enabled. When in this state, I cannot send/receive any emails. Also webmail (Afterlogic) does not work, when trying to login I get the error: "Can't connect to IMAP4 server, check IMAP4 server settings" and in the log of Afterlogic I get: "[INFO] Error: Socket connection has been refused by remote host. InnerException message follows: No connection could be made because the target machine actively refused it 127.0.0.1:993"

Now I have activated in hMailServer logging for IMAP, TCP/IP and Debug but as I said, it is crashing once every 4-5 hours, now it is working...

mattg, autoban entries are set at priority 20, my localhost is never banned

SorenR, I tried the following thing just to be sure that problem comes from disconnect.

1. telnet from another computer to the mail server
2. in cmd, ran Disconnect.exe to see all connections
3. tried Disconnect.exe Ip_Address without any other parameters and everything worked, connection was closed
4. tried anything after Ip_Address like ", 0, True" or " 0, True" or some variations and I get this error results:

...and in the log of Afterlogic I get: "[INFO] Error: Socket connection has been refused by remote host. InnerException message follows: No connection could be made because the target machine actively refused it 127.0.0.1:993"

Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

@SorenR, still the same, copy pasted your function, thought that maybe there is something spelled wrong in my function, but the same function is working on another server... same Windows 2008 R2, same version of hMailServer... This is odd

@mattg, as I said, I am on the latest RvdH build - 5.6.8, the problem with priority is in 5.7, my autoban priority is 20 and also, since disabling disconnect everything is working great. I cannot disconnect localhost because in the script I exclude the posibility that localhost or local lan to be autobanned.