I do that in a script (for a different reason than you need, but same theory should apply)agserna wrote: but at the moment i need to get some info's on how can i distinct between emails sent to local accounts and emails sent from local accounts,
how can I obtain this information from hm_messages And/Or hm_messagesrecipient database tables?
Code: Select all
Sub OnAcceptMessage(oClient, oMessage)
dim oApp, i, j, Local
If oClient.Username <> "" Then
If LCase(oClient.Username) <> LCase(oMessage.FromAddress) Then
Result.Value = 2
Result.Message = "You are only allowed to send from your own account"
End If
End If
Local = 0
For i = 1 to oApp.domains.count
if (InStr(1, oMessage.FromAddress, "@" & oApp.Domains.item(i-1).name, 1) > 0) Then ' Local user.
local = local + 1
End If
For j = 1 to oApp.Domains.item(i-1).DomainAliases.count
if (InStr(1, oMessage.FromAddress, "@" & oApp.Domains.item(i-1).DomainAliases.item(j-1).AliasName, 1) > 0) Then ' Local user.
local = local + 1
End If
Next 'j
Next 'i
if oClient.IPaddress = "192.168.0.1" then
' from router
Result.value = 0
elseif oClient.IPaddress = "127.0.0.1" then
' from localhost
Result.value = 0
elseif local >0 then
If (oClient.Username = "") Then
Result.Value = 2
Result.Message = "You must be authenticated to send from local domain."
End If
End If
End Sub