API Reference

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

Core Classes

Namespace: Zetian.Server

SmtpServer

Main SMTP server class that handles connections and messages

Properties

ActiveSessionCount
Configuration
StartTime
IsRunning
Endpoint

Methods

StartAsync()
StopAsync()
Dispose()

Events

SessionCompleted
MessageReceived
SessionCreated
ErrorOccurred

SmtpServerBuilder

Fluent builder for configuring SMTP servers

Methods

Port(int)
BindTo(IPAddress)
BindTo(string)
ServerName(string)
MaxMessageSize(long)
MaxMessageSizeMB(int)
MaxRecipients(int)
MaxConnections(int)
MaxConnectionsPerIP(int)
EnablePipelining(bool)
Enable8BitMime(bool)
EnableSmtpUtf8(bool)
Certificate(X509Certificate2)
Certificate(string path, string? password)
CertificateFromPfx(string path, string? password, X509KeyStorageFlags flags)
CertificateFromPem(string certPath, string? keyPath)
CertificateFromCer(string path)
SslProtocols(SslProtocols)
RequireAuthentication(bool)
RequireSecureConnection(bool)
AllowPlainTextAuthentication(bool)
AddAuthenticationMechanism(string)
AuthenticationHandler(AuthenticationHandler)
SimpleAuthentication(username, password)
ConnectionTimeout(TimeSpan)
CommandTimeout(TimeSpan)
DataTimeout(TimeSpan)
MaxRetryCount(int)
LoggerFactory(ILoggerFactory)
EnableVerboseLogging(bool)
Banner(string)
Greeting(string)
BufferSize(readSize, writeSize)
MessageStore(IMessageStore)
WithFileMessageStore(directory, createDateFolders)
MailboxFilter(IMailboxFilter)
WithSenderDomainWhitelist(params string[])
WithSenderDomainBlacklist(params string[])
WithRecipientDomainWhitelist(params string[])
WithRecipientDomainBlacklist(params string[])
Build()
CreateBasic()
CreateSecure(X509Certificate2)
CreateAuthenticated(int, AuthenticationHandler)

Configuration

Namespace: Zetian.Configuration

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
MaxRetryCount
ReadBufferSize
WriteBufferSize
Banner
Greeting
LoggerFactory
EnableVerboseLogging
MessageStore
MailboxFilter

Methods

Validate()

Core Interfaces

Namespace: Zetian.Abstractions

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)

IStatisticsCollector

Interface for statistics collection

Properties

TotalSessions
TotalMessages
TotalErrors
TotalBytes

Methods

RecordSession()
RecordMessage(ISmtpMessage)
RecordError(Exception)

Authentication

Namespace: Zetian.Authentication & Zetian.Abstractions

IAuthenticator

Authentication mechanism interface (Zetian.Abstractions)

Properties

Mechanism

Methods

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

AuthenticationResult

Authentication result (Zetian.Models)

Properties

Success
Identity
ErrorMessage

Methods

Succeed(string identity)
Fail(string? errorMessage)

PlainAuthenticator

PLAIN mechanism authentication implementation

Properties

Mechanism

Methods

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

LoginAuthenticator

LOGIN mechanism authentication implementation

Properties

Mechanism

Methods

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

AuthenticatorFactory

Factory for creating authenticators

Methods

Create(mechanism)
SetDefaultHandler(handler)
GetDefaultHandler()
ClearDefaultHandler()

Storage

Namespace: Zetian.Storage

FileMessageStore

Saving messages to file system

Properties

Directory
CreateDateFolders

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

NullMessageStore

Null store that does not save messages

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

BaseStorageConfiguration

Base configuration for all storage providers

Properties

MaxMessageSizeMB
CompressMessageBody
CompressionThresholdKB
EnableRetry
MaxRetryAttempts
RetryDelayMs
ConnectionTimeoutSeconds
LogErrors
Logger

Methods

Validate()

Storage Providers

Namespace: Zetian.Storage.Providers

SqlServerMessageStore

SQL Server and Azure SQL Database storage provider

Properties

ConnectionString
Configuration

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

SqlServerStorageConfiguration

Configuration for SQL Server storage

Properties

TableName
SchemaName
AutoCreateTable
StoreAttachmentsSeparately
AttachmentsTableName
CommandTimeoutSeconds
BulkCopyBatchSize

Methods

Validate()
GetFullTableName()
GetAttachmentsTableName()

PostgreSqlMessageStore

PostgreSQL storage provider with JSONB support

Properties

ConnectionString
Configuration

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

PostgreSqlStorageConfiguration

Configuration for PostgreSQL storage

Properties

TableName
SchemaName
AutoCreateTable
UseJsonbForHeaders
EnablePartitioning
PartitionInterval
CreateIndexes
RetentionMonths

Methods

Validate()
GetFullTableName()
GetPartitionName(DateTime)

MongoDbMessageStore

MongoDB NoSQL storage provider with GridFS support

Properties

ConnectionString
DatabaseName
Configuration

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

MongoDbStorageConfiguration

Configuration for MongoDB storage

Properties

CollectionName
GridFsBucketName
UseGridFsForLargeMessages
GridFsThresholdMB
AutoCreateIndexes
EnableTTL
TTLDays
ShardKeyField

Methods

Validate()
ShouldUseGridFS(long sizeInBytes)

RedisMessageStore

Redis in-memory cache storage provider

Properties

ConnectionString
Configuration
ConnectionMultiplexer

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

RedisStorageConfiguration

Configuration for Redis storage

Properties

DatabaseNumber
KeyPrefix
MessageTTLSeconds
UseChunking
ChunkSizeKB
UseCompression
EnablePubSub
PubSubChannel
UseStreams
StreamName

Methods

Validate()
GetMessageKey(string messageId)
GetChunkKey(string messageId, int chunkIndex)

S3MessageStore

Amazon S3 and S3-compatible storage provider

Properties

AccessKeyId
SecretAccessKey
BucketName
Configuration
S3Client

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

S3StorageConfiguration

Configuration for S3 storage

Properties

Region
ServiceUrl
KeyPrefix
StorageClass
EnableServerSideEncryption
KmsKeyId
EnableVersioning
UseTransferAcceleration
TransitionToIADays
TransitionToGlacierDays
ForcePathStyle

Methods

Validate()
GetObjectKey(string messageId)
GetS3Config()

AzureBlobMessageStore

Azure Blob Storage provider with Azure AD support

Properties

ConnectionString
Configuration
BlobServiceClient
ContainerClient

Methods

SaveAsync(ISmtpSession, ISmtpMessage, CancellationToken)

AzureBlobStorageConfiguration

Configuration for Azure Blob storage

Properties

ContainerName
StorageAccountName
UseAzureAdAuthentication
AccessTier
EnableSoftDelete
SoftDeleteRetentionDays
EnableVersioning
UseHierarchicalNamespace
BlobPrefix

Methods

Validate()
GetBlobName(string messageId)
GetServiceClient()

Filtering

Namespace: Zetian.Storage

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

Namespace: Zetian.Models.EventArgs

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

Namespace: Zetian.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()

Clustering

Namespace: Zetian.Clustering

IClusterManager

Main interface for cluster management and coordination

Properties

NodeId
ClusterPort
IsLeader
Nodes
State

Methods

EnableClusteringAsync(options)
StartAsync()
StopAsync()
GetHealthAsync()
GetMetrics()
ReplicateStateAsync(key, data, options)
GetReplicatedStateAsync<T>(key)
MigrateSessionsAsync(fromNodeId)
EnterMaintenanceModeAsync(options)
ExitMaintenanceModeAsync()

Events

NodeJoined
NodeLeft
NodeFailed
LeaderChanged
StateChanged

ClusterOptions

Configuration options for clustering

Properties

NodeId
ClusterPort
BindAddress
DiscoveryMethod
Seeds
ReplicationFactor
ConsistencyLevel
EnableEncryption
SharedSecret
HeartbeatInterval
ElectionTimeout
FailureDetectionTimeout

Methods

Validate()

IClusterNode

Represents a node in the cluster

Properties

Id
Address
Port
State
IsLeader
CurrentLoad
MaxLoad
LastSeen

Methods

GetHealthAsync()
SendAsync(message)

LoadBalancingStrategy

Enum for load balancing strategies

Values

RoundRobin
LeastConnections
WeightedRoundRobin
IpHash

NodeState

Enum for node states

Values

Initializing
Joining
Active
Maintenance
Draining
Failed

ConsistencyLevel

Enum for read/write consistency levels

Values

One
Two
Three
Quorum
All

DiscoveryMethod

Enum for node discovery methods

Values

Static
DNS
Multicast
Kubernetes
Consul
Etcd

Extensions

Namespace: Zetian.Extensions

SmtpServerExtensions

Extension methods for SMTP server

Methods

AddRateLimiting(IRateLimiter)
AddRateLimiting(RateLimitConfiguration)
AddMessageFilter(Func<ISmtpMessage, bool>)
AddSpamFilter(string[] blacklistedDomains)
AddSizeFilter(long maxSizeBytes)
SaveMessagesToDirectory(string directory)
LogMessages(ILogger logger)
ForwardMessages(IMessageForwarder forwarder)
AddRecipientValidation(Func<string, Task<bool>> validator)
AddAllowedDomains(params string[] domains)
AddStatistics(IStatisticsCollector collector)

SmtpServerBuilderExtensions

Extension methods for SMTP server builder

Methods

WithRecipientDomainWhitelist(params string[] domains)
WithRecipientDomainBlacklist(params string[] domains)

StorageBuilderExtensions

Extension methods for storage providers

Methods

WithSqlServerStorage(string connectionString)
WithSqlServerStorage(string connectionString, Action<SqlServerStorageConfiguration> configure)
WithPostgreSqlStorage(string connectionString)
WithPostgreSqlStorage(string connectionString, Action<PostgreSqlStorageConfiguration> configure)
WithMongoDbStorage(string connectionString, string databaseName)
WithMongoDbStorage(string connectionString, string databaseName, Action<MongoDbStorageConfiguration> configure)
WithRedisStorage(string connectionString)
WithRedisStorage(string connectionString, Action<RedisStorageConfiguration> configure)
WithS3Storage(string accessKeyId, string secretAccessKey, string bucketName)
WithS3Storage(string accessKeyId, string secretAccessKey, string bucketName, Action<S3StorageConfiguration> configure)
WithS3CompatibleStorage(string serviceUrl, string accessKeyId, string secretAccessKey, string bucketName)
WithS3CompatibleStorage(string serviceUrl, string accessKeyId, string secretAccessKey, string bucketName, Action<S3StorageConfiguration> configure)
WithAzureBlobStorage(string connectionString)
WithAzureBlobStorage(string connectionString, Action<AzureBlobStorageConfiguration> configure)
WithAzureBlobStorageAD(string storageAccountName)
WithAzureBlobStorageAD(string storageAccountName, Action<AzureBlobStorageConfiguration> configure)

Rate Limiting

Namespace: Zetian.Models & Zetian.RateLimiting & Zetian.Abstractions

RateLimitConfiguration

Rate limiting configuration (Zetian.Models)

Properties

MaxRequests
Window
UseSlidingWindow

Methods

PerMinute(int maxRequests)
PerHour(int maxRequests)
PerDay(int maxRequests)
PerCustom(int maxRequests, TimeSpan window)

IRateLimiter

Rate limiting interface (Zetian.Abstractions)

Methods

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

InMemoryRateLimiter

In-memory implementation of rate limiter (Zetian.RateLimiting)

Properties

Configuration

Methods

IsAllowedAsync(string key)
IsAllowedAsync(IPAddress address)
RecordRequestAsync(string key)
RecordRequestAsync(IPAddress address)
ResetAsync(string key)
GetRemainingAsync(string key)
CleanupExpiredWindows()
Dispose()

Delegates

Namespace: Zetian.Delegates

AuthenticationHandler

Delegate for handling authentication

Signature

Task<AuthenticationResult> AuthenticationHandler(string? username, string? password)

Enums

Namespace: Zetian.Enums

CompositeMode

Composite filter mode for combining multiple filters

Values

All (AND logic)
Any (OR logic)

SmtpSessionState

SMTP session state enumeration

Values

Connected
AwaitingCommand
ReceivingData
Closing

PartitionInterval

PostgreSQL table partition interval for storage

Values

Daily
Weekly
Monthly
Yearly

BlobNamingFormat

Azure Blob Storage blob naming format options

Values

Flat
DateHierarchy
YearMonth
DomainBased

BlobAccessTier

Azure Blob Storage access tier for cost optimization

Values

Hot
Cool
Archive

Health Check

Namespace: Zetian.HealthCheck

IHealthCheck

Interface for implementing health checks

Methods

CheckHealthAsync(CancellationToken)

HealthCheckResult

Represents the result of a health check

Properties

Status
Description
Exception
Data

Methods

Healthy(description?, data?)
Degraded(description?, exception?, data?)
Unhealthy(description?, exception?, data?)

HealthCheckService

HTTP service for health check endpoints

Properties

Options
IsRunning
HttpListener

Methods

StartAsync(CancellationToken)
StopAsync(CancellationToken)
AddHealthCheck(name, check)
AddHealthCheck(name, checkFunc)

SmtpServerHealthCheck

Health check implementation for SMTP server

Properties

Server
Options

Methods

CheckHealthAsync(CancellationToken)

HealthCheckServiceOptions

Options for health check service

Properties

Host
Port
Endpoints
Timeout
DetailedErrors

SmtpHealthCheckOptions

Options for SMTP server health check

Properties

DegradedThreshold
UnhealthyThreshold
MemoryThresholdMB
CheckInterval

Health Check Extensions

Namespace: Zetian.HealthCheck.Extensions

HealthCheckExtensions

Extension methods for adding health checks to SMTP server

Methods

EnableHealthCheck(port)
EnableHealthCheck(hostname, port)
EnableHealthCheck(IPAddress, port)
EnableHealthCheck(options)
StartWithHealthCheckAsync(port, ct)
StartWithHealthCheckAsync(port, configureHealthChecks, ct)
StartWithHealthCheckAsync(hostname, port, ct)
StartWithHealthCheckAsync(hostname, port, configureHealthChecks, ct)
StartWithHealthCheckAsync(IPAddress, port, ct)
StartWithHealthCheckAsync(IPAddress, port, configureHealthChecks, ct)
AddHealthCheck(healthCheckService, name, check)
AddHealthCheck(healthCheckService, name, checkFunc)

Health Check Enums

Namespace: Zetian.HealthCheck.Enums

HealthStatus

Health status enumeration

Values

Healthy (0)
Degraded (1)
Unhealthy (2)

Relay Extension

Namespace: Zetian.Relay

RelayConfiguration

Configuration for relay service

Properties

DefaultSmartHost
SmartHosts
UseMxRouting
DomainRouting
MaxRetryCount
MessageLifetime
ConnectionTimeout
QueueProcessingInterval
CleanupInterval
MaxConcurrentDeliveries
EnableBounceMessages
BounceSender
LocalDomains
RelayDomains
RelayNetworks
RequireAuthentication
EnableTls
RequireTls
SslProtocols
DnsServers

SmartHostConfiguration

Smart host server configuration

Properties

Host
Port
Priority
Weight
Credentials
UseTls
UseStartTls
SslProtocols
MaxConnections
ConnectionTimeout

RelayBuilder

Fluent builder for relay configuration

Methods

WithSmartHost(host, port, username, password)
AddSmartHost(SmartHostConfiguration)
MaxConcurrentDeliveries(int)
MaxRetries(int)
MessageLifetime(TimeSpan)
ConnectionTimeout(TimeSpan)
EnableTls(enable, require)
LocalDomain(string)
AddLocalDomains(params string[])
AddRelayDomains(params string[])
RequireAuthentication(bool)
EnableBounce(enable, senderAddress)
Build()

RelayService

Background service for message relay

Properties

Queue
Configuration
IsRunning

Methods

StartAsync(CancellationToken)
StopAsync(CancellationToken)
QueueMessageAsync(RelayMessage)
GetStatisticsAsync()

IRelayQueue

Interface for relay queue implementation

Methods

EnqueueAsync(RelayMessage)
DequeueAsync(CancellationToken)
GetAllAsync()
GetByStatusAsync(RelayStatus)
UpdateAsync(RelayMessage)
RemoveAsync(string)
GetStatisticsAsync()
ClearExpiredAsync()

RelayMessage

Message in relay queue

Properties

Id
MessageId
From
Recipients
Data
Priority
Status
RetryCount
NextRetryTime
CreatedTime
LastAttemptTime
SmartHost
Error

Relay Enums

Namespace: Zetian.Relay.Enums

RelayPriority

Message priority levels

Values

Urgent (0)
High (1)
Normal (2)
Low (3)

RelayStatus

Relay message status

Values

Queued
InProgress
Delivered
Failed
Deferred
Expired
Cancelled
PartiallyDelivered

AntiSpam Extension

Namespace: Zetian.AntiSpam

AntiSpamBuilder

Fluent builder for anti-spam configuration

Methods

EnableSpf(failScore)
EnableDkim(failScore, strictMode)
EnableDmarc(failScore, quarantineScore, enforcePolicy)
EnableRbl(params string[])
EnableBayesian(spamThreshold)
EnableGreylisting(initialDelay)
EnableEmailAuthentication(strictMode, enforcePolicy)
AddChecker(ISpamChecker)
WithDnsClient(IDnsClient)
WithOptions(AntiSpamOptions)
UseAggressive()
UseLenient()
Build()

AntiSpamService

Main anti-spam service

Properties

Checkers
Options
Statistics

Methods

CheckMessageAsync(ISmtpMessage, ISmtpSession, CancellationToken)
GetStatistics()
ResetStatistics()
EnableChecker(string)
DisableChecker(string)

ISpamChecker

Interface for spam checkers

Properties

Name
IsEnabled

Methods

CheckAsync(ISmtpMessage, ISmtpSession, CancellationToken)

SpfChecker

SPF (Sender Policy Framework) checker

Properties

FailScore
DnsClient

Methods

CheckAsync(ISmtpMessage, ISmtpSession, CancellationToken)

DkimChecker

DKIM signature verification

Properties

FailScore
StrictMode
DnsClient

Methods

CheckAsync(ISmtpMessage, ISmtpSession, CancellationToken)

DmarcChecker

DMARC policy enforcement

Properties

FailScore
QuarantineScore
EnforcePolicy
DnsClient

Methods

CheckAsync(ISmtpMessage, ISmtpSession, CancellationToken)

RblChecker

RBL/DNSBL blacklist checker

Properties

Providers
DnsClient

Methods

CheckAsync(ISmtpMessage, ISmtpSession, CancellationToken)

BayesianSpamFilter

Machine learning-based spam filter

Properties

SpamThreshold
MinTokenLength
MaxTokenLength

Methods

TrainSpamAsync(string)
TrainHamAsync(string)
ClassifyAsync(string)
GetStatistics()
SaveModelAsync(string)
LoadModelAsync(string)
CheckAsync(ISmtpMessage, ISmtpSession, CancellationToken)

GreylistingChecker

Greylisting implementation

Properties

InitialDelay
AutoWhitelistAfter
CleanupInterval

Methods

CheckAsync(ISmtpMessage, ISmtpSession, CancellationToken)
Whitelist(string)
RemoveWhitelist(string)
ClearExpired()

SpamCheckResult

Result of spam check

Properties

Score
Reason
IsSpam
Action

Methods

Spam(score, reason)
Clean(score)
TempFail(reason)
Reject(reason)

AntiSpam Models

Namespace: Zetian.AntiSpam.Models

AntiSpamOptions

Anti-spam configuration options

Properties

RejectThreshold
TempFailThreshold
RunChecksInParallel
CheckerTimeout
ContinueOnSpamDetection
EnableDetailedLogging

AntiSpamStatistics

Anti-spam statistics

Properties

MessagesChecked
MessagesBlocked
MessagesPassed
MessagesGreylisted
SpfFails
DkimFails
DmarcFails
RblHits
BayesianSpamDetected
AverageScore
CheckerStatistics

RblProvider

RBL/DNSBL provider configuration

Properties

Name
Zone
ExpectedResponses
Score
IsEnabled

AntiSpam Enums

Namespace: Zetian.AntiSpam.Enums

SpamAction

Action to take for spam

Values

Accept
TempFail
Reject
Discard
Quarantine

SpfResult

SPF check results

Values

Pass
Fail
SoftFail
Neutral
None
TempError
PermError

DkimResult

DKIM check results

Values

Pass
Fail
None
Policy
Neutral
TempError
PermError

DmarcResult

DMARC check results

Values

Pass
Fail
None
TempError
PermError

DmarcPolicy

DMARC policy actions

Values

None
Quarantine
Reject

Monitoring Extension

Namespace: Zetian.Monitoring

MonitoringConfiguration

Configuration for monitoring service

Properties

EnablePrometheus
PrometheusPort
PrometheusHost
EnableOpenTelemetry
OpenTelemetryEndpoint
UpdateInterval
EnableDetailedMetrics
EnableCommandMetrics
EnableThroughputMetrics
EnableHistograms
ServiceName
ServiceVersion
CustomLabels
CommandDurationBuckets
MessageSizeBuckets

Methods

Validate()

MonitoringBuilder

Fluent builder for monitoring configuration

Methods

EnablePrometheus(port)
EnablePrometheus(host, port)
EnableOpenTelemetry(endpoint)
WithServiceName(name)
WithServiceVersion(version)
EnableDetailedMetrics()
EnableCommandMetrics()
EnableThroughputMetrics()
EnableHistograms()
WithUpdateInterval(TimeSpan)
WithLabels(params (string, string)[])
WithCommandDurationBuckets(params double[])
WithMessageSizeBuckets(params double[])
Build()

MetricsCollector

Metrics collection service

Properties

Configuration
Statistics

Methods

RecordSession(ISmtpSession)
RecordMessage(ISmtpMessage, bool)
RecordCommand(command, success, durationMs)
RecordAuthentication(success, mechanism)
RecordConnection(accepted)
RecordTlsUpgrade(success)
RecordRejection(reason)
RecordError(type)
RecordBytes(direction, count)
GetStatistics()
ResetStatistics()

ServerStatistics

Comprehensive server statistics

Properties

Uptime
TotalSessions
ActiveSessions
TotalMessagesReceived
TotalMessagesDelivered
TotalMessagesRejected
DeliveryRate
RejectionRate
TotalBytesReceived
TotalBytesSent
TotalErrors
ConnectionMetrics
AuthenticationMetrics
CommandMetrics
CurrentThroughput
MemoryUsage
PeakMemoryUsage
LastReset

PrometheusExporter

Prometheus metrics exporter

Properties

Port
Host
MetricsUrl
IsRunning

Methods

StartAsync(CancellationToken)
StopAsync(CancellationToken)
UpdateMetrics(ServerStatistics)
RegisterCustomMetric(name, help, type)

OpenTelemetryExporter

OpenTelemetry tracing and metrics exporter

Properties

Endpoint
ServiceName
ServiceVersion

Methods

StartAsync(CancellationToken)
StopAsync(CancellationToken)
ExportMetrics(ServerStatistics)
CreateSpan(operationName)
RecordEvent(name, attributes)

Monitoring Models

Namespace: Zetian.Monitoring.Models

ConnectionMetrics

Connection-related metrics

Properties

TotalConnectionsReceived
AcceptedCount
RejectedCount
TlsUpgrades
TlsUsageRate
CurrentConnections
PeakConcurrentConnections
AverageConnectionDuration

AuthenticationMetrics

Authentication-related metrics

Properties

TotalAttempts
SuccessCount
FailureCount
SuccessRate
MechanismBreakdown
UniqueUsers
FailureReasons

CommandMetrics

SMTP command metrics

Properties

Command
TotalCount
SuccessCount
FailureCount
SuccessRate
AverageDurationMs
MinDurationMs
MaxDurationMs
P95DurationMs
P99DurationMs

ThroughputMetrics

Real-time throughput metrics

Properties

MessagesPerSecond
BytesPerSecond
CommandsPerSecond
SessionsPerSecond
AverageMessageSize
PeakMessagesPerSecond
PeakBytesPerSecond
For detailed examples and usageExamples pagevisit