OnAcceptMessage(oClient as hMailServer.Client, oMessage as hMailServer.Message)
The built-in SMTP authentication functionality checks only the sender address to determine whether SMTP authentication is required. Often, you want to check sender address as well. The following script makes hMailServer require authentication, if the senders address contains @example.com.
VB-script:
Sub OnAcceptMessage(oClient, oMessage)
if (InStr(1, oMessage.FromAddress, "@example.com", 1) > 0) Then
' Local user.
If (oClient.Username = "") Then
Result.Message = "You must be authenticated to send from local domain."
Result.Value = 2
End If
End If
End Sub
VB-script:
Sub OnAcceptMessage(oClient, oMessage)
If oMessage.Size > 10 Then
' Reject the message since it's larger
' than 10 kb.
Result.Message = "This message is too large"
Result.Value = 2
Else
' Accept the message
Result.Value = 0
End If
End Sub