OnAcceptMessage

Signature

OnAcceptMessage(oClient as hMailServer.Client, oMessage as hMailServer.Message)

Result values

0 - hMailServer accepts the message

1 - hMailServer rejects the message with the error 542 Rejected

2 - hMailServer rejects the message with a script-defined error.

Examples

Require authentication for local senders

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