代码: 全选
Sub OnSMTPData(oClient, oMessage)
If (oClient.Username <> "") Then
Const NotPermitted = "xxxxx@xx.com"
Dim i
If InStr(NotPermitted, oClient.Username) Then
For i = 0 To oMessage.Recipients.Count -1
If (Not oMessage.Recipients(i).IsLocalUser) Then
Result.Value = 2
Result.Message = "You are only allowed to send internally"
End If
Next
End If
End If
End Sub代码: 全选
Sub OnSMTPData(oClient, oMessage)
If (oClient.Username <> "") Then
Dim k, i, j, aUsername, oApp, oDomain, oDistributionList
Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate("Administrator", "*secretpassword*")
aUsername = Split(oClient.Username,"@")
Set oDomain = oApp.Domains.ItemByName(aUsername(1))
For k = 0 To oDomain.DistributionLists.Count -1
If lcase(oDomain.DistributionLists.Item(k).Address) = lcase("AllowedSenders@" & aUsername(1)) Then
Set oDistributionList = oDomain.DistributionLists.Item(k)
if oDistributionList.Active then
For j = 0 To oMessage.Recipients.Count -1
If (Not oMessage.Recipients(j).IsLocalUser) Then
For i = 0 To oDistributionList.Recipients.Count -1
If lcase(oDistributionList.Recipients.Item(i).RecipientAddress) = lcase(oClient.Username) Then
Exit Sub
End If
Next
Result.Value = 2
Result.Message = "You are only allowed to send internally"
End If
Next
End If
End If
Next
End If
End Sub代码: 全选
Sub OnSMTPData(oClient, oMessage)
If (oClient.Username <> "") Then
Dim k, i, j, aUsername, oApp, oDomain, oDistributionList
Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate("Administrator", "*secret password*")
aUsername = Split(oClient.Username,"@")
Set oDomain = oApp.Domains.ItemByName(aUsername(1))
For k = 0 To oDomain.DistributionLists.Count -1
If lcase(oDomain.DistributionLists.Item(k).Address) = lcase("NonSenders@" & aUsername(1)) Then
Set oDistributionList = oDomain.DistributionLists.Item(k)
if oDistributionList.Active then
For j = 0 To oMessage.Recipients.Count -1
If (Not oMessage.Recipients(j).IsLocalUser) Then
For i = 0 To oDistributionList.Recipients.Count -1
If lcase(oDistributionList.Recipients.Item(i).RecipientAddress) = lcase(oClient.Username) Then
Result.Value = 2
Result.Message = "You are only allowed to send internally"
Exit Sub
End If
Next
End If
Next
End If
End If
Next
End If
End Sub

