Better log in my ip/domain blacklist

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
User avatar
bagu
Normal user
Normal user
Posts: 211
Joined: 2005-06-17 03:08
Location: France
Contact:

Better log in my ip/domain blacklist

Post by bagu » 2017-09-26 11:03

Hello,

I use this script :

Code: Select all

'   Sub OnClientConnect(oClient)
Sub OnClientConnect(oClient)
Dim GeoIP
Dim Country
Set GeoIP = CreateObject("GeoIPCOMEx.GeoIPEx")

GeoIP.set_db_path("D:\geoip\")
GeoIP.find_by_addr(oClient.IPAddress)
Country = GeoIP.country_code

Select Case Country
Case "BE","CA","CL","DE","DK","FR","GB","LN","US" 'LN = Local Network

'EventLog.Write("Geo-IP accepted" + Chr(34) + vbTab + Chr(34) + oClient.IPAddress + Chr(34) + vbTab + Chr(34) + GeoIP.country_code + Chr(34) + vbTab + Chr(34) + GeoIP.country_name)
Result.Value = 0

Case Else

EventLog.Write("Geo-IP rejected" + Chr(34) + vbTab + Chr(34) + oClient.IPAddress + Chr(34) + vbTab + Chr(34) + GeoIP.country_code + Chr(34) + vbTab + Chr(34) + GeoIP.country_name)
Result.Value = 1
End Select

Set GeoIP = Nothing
End Sub
'   End Sub

'   Sub OnSMTPData(oClient, oMessage)
Sub OnSMTPData(oClient, oMessage)
   Result.Value = 0
   blockedVarLenEnd = Array(".trade", ".bid", ".stream")
   For Each bEmail in blockedVarLenEnd
      If right(oMessage.FromAddress,len(bEmail)) = bEmail Then Result.Value = 1
      If right(oMessage.FromAddress,len(bEmail)) = bEmail Then EventLog.Write("OnSMTPData rejected" + Chr(34) + vbTab + Chr(34) + oClient.IPAddress)
   Next
End Sub
'   End Sub
The first part block countries wich are not in whitelist, and the second part block some domain wich only send spam.
But, for the second part, i try to get (without success) the entire mail address wich have been blocked.

How can i do that ?

An other question is : how can i rewrite the double if right to get the log and result value in one test ?

Thanks.
hMailServer 5.6.8 With SpamAssassin 3.4.2

User avatar
jimimaseye
Moderator
Moderator
Posts: 8265
Joined: 2011-09-08 17:48

Re: Better log in my ip/domain blacklist

Post by jimimaseye » 2017-09-26 23:27

bagu wrote:But, for the second part, i try to get (without success) the entire mail address wich have been blocked.

How can i do that ?
https://www.hmailserver.com/documentati ... onSMTPdata

Write out the oMessage.FromAddress.
An other question is : how can i rewrite the double if right to get the log and result value in one test ?
Sorry, I dont understand the question.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
bagu
Normal user
Normal user
Posts: 211
Joined: 2005-06-17 03:08
Location: France
Contact:

Re: Better log in my ip/domain blacklist

Post by bagu » 2017-09-27 00:16

Thanks for the first part ;)

I'm sorry for my bad english. Is there a better way to write :

Code: Select all

      If right(oMessage.FromAddress,len(bEmail)) = bEmail Then Result.Value = 1
      If right(oMessage.FromAddress,len(bEmail)) = bEmail Then EventLog.Write("OnSMTPData rejected" + Chr(34) + vbTab + Chr(34) + oClient.IPAddress)
if then + if then for the same rule is not really good...no ?
hMailServer 5.6.8 With SpamAssassin 3.4.2

User avatar
jimimaseye
Moderator
Moderator
Posts: 8265
Joined: 2011-09-08 17:48

Re: Better log in my ip/domain blacklist

Post by jimimaseye » 2017-09-27 00:29

Code: Select all

  If right(oMessage.FromAddress,len(bEmail)) = bEmail Then
     EventLog.Write("OnSMTPData rejected" + Chr(34) + vbTab + Chr(34) + oClient.IPAddress)
     Result.Value = 1
  End if
although your original 2 line option is the same. (There is no right or wrong way....just ways.) :mrgreen:
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
bagu
Normal user
Normal user
Posts: 211
Joined: 2005-06-17 03:08
Location: France
Contact:

Re: Better log in my ip/domain blacklist

Post by bagu » 2017-09-27 00:41

I found the same solution just one second before reading your message ;)

Thanks a lot ;)
hMailServer 5.6.8 With SpamAssassin 3.4.2

Post Reply