现状:大部分HMAIL上的用户可以对内网互相发送邮件,可以收发内外网的邮件;但是不可以对外网发送邮件。
实现方式:IP ranges 中,内部用户的IP设置我勾选了SMTP,POP3,IMAP,ANTI-SPAM,ANTI-VIRUS local to local e-mail addresses;local to external e-mailaddresses;external to local e-mail address;local to local e-mail addresses;local to external e-mail address
关于服务器的IP:127.0.0.1的IP ranges 中勾选了SMTP,ANTI-SPAM,ANTI-VIRUS, ALLOW DELIVERIES FROM全部;Require smtp authentication全部。
尝试过的方式,都是通过脚本控制,每次更新脚本文件都是会RELOAD,然后在WINDOWS服务中重启HMAIL服务,但都没有效果。
尝试一:本论坛
代码: 全选
Sub OnSMTPData(oClient, oMessage)
If (oClient.Username <> "") Then
Const NotPermitted = "test@hmailserver.org"
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 Subhttps://www.hmailserver.com/forum/viewt ... =9&t=17190
尝试三:
代码: 全选
Sub OnAcceptMessage(oClient, oMessage)
dim fromemail, fromemail_domain, authenuser, authenuser_value
authenuser = Split ( (oClient.Username) , "@")
authenuser_value = authenuser(1)
fromemail = Split ( (oMessage.FromAddress) , "@" )
fromemail_domain = fromemail(1)
If oClient.Username<>"" Then
If LCase(authenuser_value)=LCase(fromemail_domain) and LCase(fromemail_domain)<>LCase("yourdomain.com") Then
'如果用户不是以发件者发送邮件且不是本地域名则提示没有被授权
Result.Value = 2
Result.Message = "You are not allow to send mail"
ElseIf LCase(authenuser_value) = LCase(fromemail_domain) Then
set FSO=CreateObject("Scripting.FileSystemObject")
Set txtfile = FSO.OpenTextFile("H:\hMailServer\Events\LimitUsers.txt",1,TriStateTrue)
Do Until txtfile.AtEndOfStream
strtxt = Trim(txtfile.ReadLine)
if oClient.Username = strtxt then
'如果是受限邮件账号(内部邮件账号)则检查外发邮件地址是否是本域地址,如果非本域地址则禁止发送
dim toemail, tomail_value, CountRecipients
CountRecipients = oMessage.Recipients.Count
for i = 0 to CountRecipients
toemail = Split( (oMessage.Recipients(i).Address) , "@" )
toemail_value = toemail(1)
if LCase (toemail_value)<>LCase("yourdomain.com") then
Result.Value = 2
Result.Message = "You are not allow to send external mail to " + oMessage.Recipients(i).Address +" ,please remove this address then tray again!"
Set FSO2 = CreateObject("Scripting.FileSystemObject")
Set str = FSO2.OpenTextFile("D:\hMailServer\Logs\LimitUsers.log",8,True)
strResponses = str.Writeline(CStr(Now)+"–>"+oClient.Username+"–>"+oMessage.Recipients(i).Address)
str.Close
Exit For
End If
Next
end if
Loop
txtfile.Close
End If
End If
End Sub
