maxSize plugin enforces message size limits by rejecting emails that exceed a specified byte threshold. This helps protect your server from resource exhaustion and ensures compliance with message size policies.
What It Does
The maxSize plugin:- Monitors incoming message size during the DATA phase
- Rejects messages that exceed the configured byte limit
- Returns an RFC-compliant 552 error code when the limit is exceeded
Function Signature
Parameters
Maximum message size in bytes. Messages exceeding this limit will be rejected with a 552 error code.
Usage
Import and configure the maxSize plugin with your desired byte limit:Important: You must set If
FumiOptions.size to the same byte value when creating your Fumi instance. This enables the underlying SMTP library to track message size and set the sizeExceeded flag on the stream.FumiOptions.size is not set, the plugin will not function correctly.Example with Different Limits
Error Response
When a message exceeds the size limit, clients receive:Implementation
The plugin hooks into theonData event and checks the sizeExceeded flag after the message stream is consumed:
Common Size Limits
- 1 MB:
1_000_000or1 * 1024 * 1024 - 5 MB:
5_000_000or5 * 1024 * 1024 - 10 MB:
10_000_000or10 * 1024 * 1024 - 25 MB:
25_000_000or25 * 1024 * 1024(Gmail’s limit)