Skip to content

Conversation

@tinohager
Copy link
Contributor

Introduces IMaxMessageSizeOptions, MaxMessageSizeOptions, and MaxMessageSizeHandling to allow configuration of maximum allowed message size and handling strategy. Updates relevant protocol and IO classes to enforce the limit, throwing MaxMessageSizeExceededException when exceeded in strict mode. Adjusts SmtpServerOptionsBuilder and ISmtpServerOptions to use the new options, and adds a test for strict enforcement.

Based on this existing pull request of @boba2fett

Fix the issue

The code should be largely backward compatible since the second parameter was declared as optional in the builder.

SmtpServerOptionsBuilder MaxMessageSize(int value)
SmtpServerOptionsBuilder MaxMessageSize(int length, MaxMessageSizeHandling handling = MaxMessageSizeHandling.Ignore)

An example of the server configuration (Allow max 50 bytes)

var options = new SmtpServerOptionsBuilder()
    .ServerName("SMTP Server")
    .Port(9025)
    .MaxMessageSize(50, MaxMessageSizeHandling.Strict)
    .Build();

Introduces IMaxMessageSizeOptions, MaxMessageSizeOptions, and MaxMessageSizeHandling to allow configuration of maximum allowed message size and handling strategy. Updates relevant protocol and IO classes to enforce the limit, throwing MaxMessageSizeExceededException when exceeded in strict mode. Adjusts SmtpServerOptionsBuilder and ISmtpServerOptions to use the new options, and adds a test for strict enforcement.

Based on this existing pull request of @boba2fett
- https://github.com/cosullivan/SmtpServer/pull/213/files#diff-3ef8e28e7d91fa5d1ac55f908d172fc69242455c3a25d0a009c79cadc71916a3
@tinohager
Copy link
Contributor Author

tinohager commented Jul 27, 2025 via email

@cosullivan cosullivan merged commit 6fba0aa into cosullivan:master Aug 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants