@@ -24,7 +24,7 @@ public ISmtpServerOptions Build()
2424 MaxAuthenticationAttempts = 3 ,
2525 NetworkBufferSize = 128 ,
2626 CommandWaitTimeout = TimeSpan . FromMinutes ( 5 ) ,
27- CustomGreetingMessage = null ,
27+ CustomSmtpGreeting = null ,
2828 } ;
2929
3030 _setters . ForEach ( setter => setter ( serverOptions ) ) ;
@@ -162,11 +162,15 @@ public SmtpServerOptionsBuilder CommandWaitTimeout(TimeSpan value)
162162 /// Sets the custom SMTP greeting message sent to the client upon connection,
163163 /// typically returned as the initial "220" response.
164164 /// </summary>
165- /// <param name="value">The greeting message to send to the client (e.g., "220 mail.example.com v1.0 ESMTP ready").</param>
165+ /// <param name="smtpGreetingFunc">
166+ /// A delegate that returns the greeting message to send to the client,
167+ /// based on the <see cref="ISessionContext"/> (e.g., client IP, TLS state).
168+ /// Example: <c>ctx => $"220 {sessionContext.ServerOptions.ServerName} ESMTP ready"</c>
169+ /// </param>
166170 /// <returns>An OptionsBuilder to continue building on.</returns>
167- public SmtpServerOptionsBuilder CustomGreetingMessage ( string value )
171+ public SmtpServerOptionsBuilder CustomGreetingMessage ( Func < ISessionContext , string > smtpGreetingFunc )
168172 {
169- _setters . Add ( options => options . CustomGreetingMessage = value ) ;
173+ _setters . Add ( options => options . CustomSmtpGreeting = smtpGreetingFunc ) ;
170174
171175 return this ;
172176 }
@@ -220,7 +224,7 @@ class SmtpServerOptions : ISmtpServerOptions
220224 /// This message is returned after the client connects and before any commands are issued (e.g., "220 mail.example.com v1.0 ESMTP ready").
221225 /// If not set, a default greeting will be used.
222226 /// </summary>
223- public string CustomGreetingMessage { get ; set ; }
227+ public Func < ISessionContext , string > CustomSmtpGreeting { get ; set ; }
224228 }
225229
226230 #endregion
0 commit comments