Maximum message size

This section contains scripts that hMailServer has contributed with. hMailServer 4 is needed to use these.
Post Reply
User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Maximum message size

Post by martin » 2005-07-27 14:40

This script lets you define a server-wide maximum message size. To change the maximum message size, change the value 1024 to something else.

Requirements
hMailServer 4. Works fine in 4.1 as well, but in that version it's better and easier to use the built-in functionality to limit the message size. (The built-in functionality requires less CPU resources)

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
  
  Dim iMaximumMessageSizeKB
  iMaximumMessageSizeKB = 1024
  
  If oMessage.Size > iMaximumMessageSizeKB Then
     ' Reject the message since it's larger than 
     ' the maximum message size.
     Result.Message = "This message is to big. Maximum message size is " & iMaximumMessageSizeKB & " KB"
     Result.Value = 2            
  Else
     ' Accept the message
     Result.Value = 0 
  End If
  
End Sub

Post Reply