API Reference

Detailed documentation of all classes, interfaces and methods of Zetian SMTP Server.

Core Classes

SmtpServer

Main SMTP server class that handles connections and messages

Properties

Configuration
IsRunning
Endpoint

Methods

StartAsync()
StopAsync()
Dispose()

Events

MessageReceived
SessionCreated
SessionCompleted
ErrorOccurred

SmtpServerBuilder

Fluent builder for configuring SMTP servers

Methods

Port(int)
BindTo(IPAddress)
ServerName(string)
MaxMessageSize(long)
MaxMessageSizeMB(int)
MaxRecipients(int)
MaxConnections(int)
MaxConnectionsPerIP(int)
EnablePipelining(bool)
Enable8BitMime(bool)
EnableSmtpUtf8(bool)
Certificate(X509Certificate2)
Certificate(string, string)
SslProtocols(SslProtocols)
RequireAuthentication(bool)
RequireSecureConnection(bool)
AllowPlainTextAuthentication(bool)
AddAuthenticationMechanism(string)
AuthenticationHandler(handler)
SimpleAuthentication(user, pass)
ConnectionTimeout(TimeSpan)
CommandTimeout(TimeSpan)
DataTimeout(TimeSpan)
LoggerFactory(ILoggerFactory)
EnableVerboseLogging(bool)
Banner(string)
Greeting(string)
BufferSize(read, write)
MessageStore(IMessageStore)
WithFileMessageStore(dir, createFolders)
MailboxFilter(IMailboxFilter)
WithSenderDomainWhitelist(domains)
WithSenderDomainBlacklist(domains)
WithRecipientDomainWhitelist(domains)
WithRecipientDomainBlacklist(domains)
Build()

SmtpServerConfiguration

Configuration settings for SMTP server

Properties

Port
IpAddress
ServerName
MaxMessageSize
MaxRecipients
MaxConnections
MaxConnectionsPerIp
EnablePipelining
Enable8BitMime
EnableSmtpUtf8
Certificate
SslProtocols
RequireAuthentication
RequireSecureConnection
AllowPlainTextAuthentication
AuthenticationMechanisms
ConnectionTimeout
CommandTimeout
DataTimeout
ReadBufferSize
WriteBufferSize
Banner
Greeting
LoggerFactory
EnableVerboseLogging
MessageStore
MailboxFilter

Methods

Validate()

Core Interfaces

ISmtpMessage

Represents an SMTP message

Properties

Id
From (MailAddress?)
Recipients (IReadOnlyList<MailAddress>)
Subject
TextBody
HtmlBody
Headers
Size
Date
Priority
HasAttachments
AttachmentCount

Methods

GetRawData()
GetRawDataAsync()
GetRawDataStream()
GetHeader(string)
GetHeaders(string)
SaveToFile(string)
SaveToFileAsync(string)
SaveToStream(Stream)
SaveToStreamAsync(Stream)

ISmtpSession

Represents an SMTP session

Properties

Id
RemoteEndPoint
LocalEndPoint
IsSecure
IsAuthenticated
AuthenticatedIdentity
ClientDomain
StartTime
Properties
ClientCertificate
MessageCount
PipeliningEnabled
EightBitMimeEnabled
BinaryMimeEnabled
MaxMessageSize

IMessageStore

Message storage interface

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

IMailboxFilter

Mailbox filtering interface

Methods

CanAcceptFromAsync(ISmtpSession, string, long, CancellationToken)
CanDeliverToAsync(ISmtpSession, string, string, CancellationToken)

Authentication

IAuthenticator

Authentication mechanism interface

Properties

Mechanism

Methods

AuthenticateAsync(session, initialResponse, reader, writer, ct)

AuthenticationResult

Authentication result

Properties

Success
Identity
ErrorMessage

Methods

Succeed(string)
Fail(string?)

PlainAuthenticator

Authentication with PLAIN mechanism

LoginAuthenticator

Authentication with LOGIN mechanism

Storage

FileMessageStore

Saving messages to file system

Properties

Directory
CreateDateFolders

Methods

SaveAsync()

NullMessageStore

Null store that does not save messages

Methods

SaveAsync()

Filtering

DomainMailboxFilter

Domain-based filtering

Properties

AllowedFromDomains
BlockedFromDomains
AllowedToDomains
BlockedToDomains

Methods

AllowFromDomains()
BlockFromDomains()
AllowToDomains()
BlockToDomains()

CompositeMailboxFilter

Combining multiple filters

Properties

Mode
Filters

Methods

AddFilter()
RemoveFilter()

AcceptAllMailboxFilter

Filter that accepts all messages

Event Arguments

MessageEventArgs

Event args for message events

Properties

Message
Session
Cancel
Response

SessionEventArgs

Event args for session events

Properties

Session

AuthenticationEventArgs

Event args for authentication events

Properties

Mechanism
Username
Password
Session
IsAuthenticated
AuthenticatedIdentity

ErrorEventArgs

Event args for error events

Properties

Exception
Session

Protocol

SmtpResponse

SMTP protocol response

Properties

Code
Lines
Message
IsPositive
IsError
IsSuccess

Methods

ToString()

Static Members

Ok (250)
ServiceReady (220)
ServiceClosing (221)
StartMailInput (354)
AuthenticationRequired (530)
AuthenticationSuccessful (235)
AuthenticationFailed (535)
ServiceNotAvailable (421)
SyntaxError (500)
BadSequence (503)
TransactionFailed (554)

SmtpCommand

SMTP protocol command

Properties

Name
Parameters

Methods

Parse(string)
IsValid()

Extensions

SmtpServerExtensions

Extension methods for SMTP server

Methods

AddRateLimiting(IRateLimiter)
AddRateLimiting(RateLimitConfiguration)
AddMessageFilter(Func<ISmtpMessage, bool>)
AddSpamFilter(blacklistedDomains)
AddSizeFilter(maxSizeBytes)
SaveMessagesToDirectory(directory)
LogMessages(logger)
ForwardMessages(forwarder)
AddRecipientValidation(validator)
AddAllowedDomains(domains)
AddStatistics(collector)

RateLimitConfiguration

Rate limiting configuration

Properties

MaxRequests
Window
UseSlidingWindow

Methods

PerMinute(maxRequests)
PerHour(maxRequests)
PerDay(maxRequests)

IRateLimiter

Rate limiting interface

Methods

IsAllowedAsync(key)
IsAllowedAsync(IPAddress)
RecordRequestAsync(key)
RecordRequestAsync(IPAddress)
ResetAsync(key)
GetRemainingAsync(key)

InMemoryRateLimiter

In-memory rate limiter implementation

Properties

Configuration
For detailed examples and usageExamples pagevisit