-
-
Notifications
You must be signed in to change notification settings - Fork 183
Add configurable max message size enforcement #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cosullivan
merged 3 commits into
cosullivan:master
from
tinohager:feature/max-message-size
Aug 3, 2025
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| namespace SmtpServer | ||
| { | ||
| /// <summary> | ||
| /// Defines configuration options for enforcing a maximum allowed message size according to the SMTP SIZE extension (RFC 1870). | ||
| /// Includes the size limit in bytes and the handling strategy for oversized messages. | ||
| /// </summary> | ||
| public interface IMaxMessageSizeOptions | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the maximum allowed message size in bytes. | ||
| /// </summary> | ||
| int Length { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the handling type an oversized message. | ||
| /// </summary> | ||
| MaxMessageSizeHandling Handling { get; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| namespace SmtpServer | ||
| { | ||
| /// <summary> | ||
| /// Choose how MaxMessageSize limit should be considered | ||
| /// </summary> | ||
| public enum MaxMessageSizeHandling | ||
| { | ||
| /// <summary> | ||
| /// Use the size limit for the SIZE extension of ESMTP | ||
| /// </summary> | ||
| Ignore = 0, | ||
|
|
||
| /// <summary> | ||
| /// Close the session after too much data has been sent | ||
| /// </summary> | ||
| Strict = 1, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
|
|
||
| namespace SmtpServer | ||
| { | ||
| /// <summary> | ||
| /// Represents configuration settings for enforcing a maximum message size in SMTP, | ||
| /// including the size limit in bytes and the behavior when that limit is exceeded. | ||
| /// </summary> | ||
| public class MaxMessageSizeOptions : IMaxMessageSizeOptions | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the maximum allowed message size in bytes, | ||
| /// as specified by the SMTP SIZE extension (RFC 1870). | ||
| /// </summary> | ||
| public int Length { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the handling strategy for messages that exceed the maximum allowed size. | ||
| /// </summary> | ||
| public MaxMessageSizeHandling Handling { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="MaxMessageSizeOptions"/> class | ||
| /// with the specified handling strategy and message size limit. | ||
| /// </summary> | ||
| /// <param name="handling">The strategy for handling messages that exceed the maximum allowed size.</param> | ||
| /// <param name="length">The maximum allowed message size in bytes.</param> | ||
| public MaxMessageSizeOptions(MaxMessageSizeHandling handling, int length) | ||
| { | ||
| Length = length; | ||
| Handling = handling; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="MaxMessageSizeOptions"/> class with default values. | ||
| /// </summary> | ||
| public MaxMessageSizeOptions() | ||
| { | ||
|
|
||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Src/SmtpServer/Protocol/MaxMessageSizeExceededException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using System; | ||
|
|
||
| namespace SmtpServer.Protocol | ||
| { | ||
| /// <summary> | ||
| /// Exception thrown when a message exceeds the maximum allowed size as defined by the SMTP SIZE extension (RFC 1870). | ||
| /// </summary> | ||
| public sealed class MaxMessageSizeExceededException : Exception | ||
| { | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.