-
-
Notifications
You must be signed in to change notification settings - Fork 183
Add support for custom SMTP greeting message #255
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
Add support for custom SMTP greeting message #255
Conversation
Introduces a CustomGreetingMessage property to ISmtpServerOptions and SmtpServerOptionsBuilder, allowing configuration of the initial SMTP greeting sent to clients. SmtpSession now uses this custom message if set, otherwise defaults to the standard greeting with server name and version.
| /// This message is returned after the client connects and before any commands are issued (e.g., "220 mail.example.com v1.0 ESMTP ready"). | ||
| /// If not set, a default greeting will be used. | ||
| /// </summary> | ||
| public string CustomGreetingMessage { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this should actually be something like
Func<ISmtpContext, string> CustomGreetingMessage
which would give the ability to make the message dynamic?
|
I've already thought about it. I think the only variable that is interesting is the version number but this is not in the SmtpContext.
|
I think its worth changing this to a function as people might want to rotate greeing messages or customize it somehow... even if what they need isnt in the context, they will still have customization if this is a function. |
|
An example of the server configuration var options = new SmtpServerOptionsBuilder()
.ServerName("SMTP Server")
.Port(9025)
.CustomGreetingMessage(MyCustomGreeting)
.Build();
private static string MyCustomGreeting(ISessionContext context)
{
return $"220 {context.ServerOptions.ServerName} hello";
}
|
|
@cosullivan Is this what you had in mind? It would now also be possible to return the following in the greeting during maintenance
|
Introduces a CustomGreetingMessage property to ISmtpServerOptions and SmtpServerOptionsBuilder, allowing configuration of the initial SMTP greeting sent to clients. SmtpSession now uses this custom message if set, otherwise defaults to the standard greeting with server name and version.
Fix issue
An example of the server configuration