Zetian 1.0.1
Prefix ReservedSee the version list below for details.
dotnet add package Zetian --version 1.0.1
NuGet\Install-Package Zetian -Version 1.0.1
<PackageReference Include="Zetian" Version="1.0.1" />
<PackageVersion Include="Zetian" Version="1.0.1" />
<PackageReference Include="Zetian" />
paket add Zetian --version 1.0.1
#r "nuget: Zetian, 1.0.1"
#:package Zetian@1.0.1
#addin nuget:?package=Zetian&version=1.0.1
#tool nuget:?package=Zetian&version=1.0.1
Zetian SMTP Server Library
A professional, high-performance SMTP server library for .NET with minimal dependencies. Build custom SMTP servers with ease using a fluent API and extensible architecture.
Features
- 🚀 High Performance: Built with System.IO.Pipelines for efficient I/O operations
- 🔒 Security: Full TLS/SSL support with STARTTLS
- 🔑 Authentication: Built-in PLAIN and LOGIN mechanisms, easily extensible
- 🛡️ Rate Limiting: Protect against abuse with configurable rate limits
- 📊 Event-Driven: Rich event system for message processing and monitoring
- 🔧 Extensible: Plugin architecture for custom authentication, filtering, and processing
- 📦 Minimal Dependencies: Only essential packages required
- 🎯 Multi-Framework: Supports .NET 6.0, 7.0, and 8.0
Installation
dotnet add package Zetian
Or via NuGet Package Manager:
Install-Package Zetian
Quick Start
Basic SMTP Server
using Zetian;
// Create and start a basic SMTP server
using var server = SmtpServerBuilder.CreateBasic();
server.MessageReceived += (sender, e) =>
{
Console.WriteLine($"Received message from {e.Message.From}");
Console.WriteLine($"Subject: {e.Message.Subject}");
};
await server.StartAsync();
Console.WriteLine($"Server running on {server.Endpoint}");
// Keep running...
Console.ReadKey();
await server.StopAsync();
Authenticated SMTP Server
using var server = new SmtpServerBuilder()
.Port(587)
.RequireAuthentication()
.SimpleAuthentication("user", "password")
.Build();
await server.StartAsync();
Secure SMTP Server with TLS
using var server = new SmtpServerBuilder()
.Port(587)
.Certificate("certificate.pfx", "password")
.RequireSecureConnection()
.Build();
await server.StartAsync();
Advanced Configuration
Using the Fluent Builder
var server = new SmtpServerBuilder()
.Port(587)
.BindTo(IPAddress.Any)
.ServerName("My SMTP Server")
.MaxMessageSizeMB(25)
.MaxRecipients(100)
.MaxConnections(50)
.MaxConnectionsPerIP(5)
// Security
.Certificate(certificate)
.RequireAuthentication()
.RequireSecureConnection()
// Authentication
.AddAuthenticationMechanism("PLAIN")
.AddAuthenticationMechanism("LOGIN")
.AuthenticationHandler(async (username, password) =>
{
// Your authentication logic
if (await ValidateUser(username, password))
return AuthenticationResult.Succeed(username);
return AuthenticationResult.Fail();
})
// Features
.EnablePipelining()
.Enable8BitMime()
// Timeouts
.ConnectionTimeout(TimeSpan.FromMinutes(5))
.CommandTimeout(TimeSpan.FromSeconds(30))
.DataTimeout(TimeSpan.FromMinutes(2))
// Logging
.LoggerFactory(loggerFactory)
.EnableVerboseLogging()
.Build();
Extensions
Rate Limiting
using Zetian.Extensions;
using Zetian.Extensions.RateLimiting;
server.AddRateLimiting(
RateLimitConfiguration.PerHour(100)
);
Message Filtering
// Add spam filter
server.AddSpamFilter(new[] { "spam.com", "junk.org" });
// Add size filter (10MB max)
server.AddSizeFilter(10 * 1024 * 1024);
// Add custom filter
server.AddMessageFilter(message =>
{
// Your filtering logic
return !message.Subject?.Contains("SPAM") ?? true;
});
Message Storage
// Save messages to directory
server.SaveMessagesToDirectory(@"C:\smtp_messages");
// Custom message processing
server.MessageReceived += async (sender, e) =>
{
// Save to database
await SaveToDatabase(e.Message);
// Forward to another service
await ForwardMessage(e.Message);
// Send notification
await NotifyAdministrator(e.Message);
};
Domain Validation
// Only accept emails for specific domains
server.AddAllowedDomains("example.com", "mycompany.com");
// Custom recipient validation
server.AddRecipientValidation(recipient =>
{
return IsValidRecipient(recipient.Address);
});
Event Handling
// Session events
server.SessionCreated += (s, e) =>
Console.WriteLine($"New session from {e.Session.RemoteEndPoint}");
server.SessionCompleted += (s, e) =>
Console.WriteLine($"Session completed: {e.Session.Id}");
// Message events
server.MessageReceived += (s, e) =>
{
Console.WriteLine($"Message: {e.Message.Subject}");
// Reject message if needed
if (IsSpam(e.Message))
{
e.Cancel = true;
e.Response = new SmtpResponse(550, "Message rejected as spam");
}
};
// Error events
server.ErrorOccurred += (s, e) =>
Console.WriteLine($"Error: {e.Exception.Message}");
Custom Authentication
// Register custom authenticator
AuthenticatorFactory.Register("CUSTOM", () =>
new CustomAuthenticator());
// Or use the authentication handler
server.AuthenticationHandler(async (username, password) =>
{
// Check against database
var user = await db.GetUser(username);
if (user != null && VerifyPassword(password, user.PasswordHash))
{
return AuthenticationResult.Succeed(username);
}
return AuthenticationResult.Fail();
});
Message Processing
server.MessageReceived += async (sender, e) =>
{
var message = e.Message;
// Access message properties
Console.WriteLine($"ID: {message.Id}");
Console.WriteLine($"From: {message.From?.Address}");
Console.WriteLine($"To: {string.Join(", ", message.Recipients)}");
Console.WriteLine($"Subject: {message.Subject}");
Console.WriteLine($"Size: {message.Size} bytes");
Console.WriteLine($"Has Attachments: {message.HasAttachments}");
Console.WriteLine($"Priority: {message.Priority}");
// Access headers
var messageId = message.GetHeader("Message-Id");
var contentType = message.GetHeader("Content-Type");
// Get message content
var textBody = message.TextBody;
var htmlBody = message.HtmlBody;
// Save message
await message.SaveToFileAsync($"{message.Id}.eml");
// Get raw data
var rawData = await message.GetRawDataAsync();
};
Examples
The examples directory contains comprehensive examples:
- BasicExample - Simple SMTP server without authentication
- AuthenticatedExample - SMTP server with authentication
- SecureExample - SMTP server with TLS/SSL support
- RateLimitedExample - SMTP server with rate limiting
- MessageStorageExample - Saving messages to disk
- CustomProcessingExample - Custom message processing and filtering
- FullFeaturedExample - Complete SMTP server with all features
Performance
Zetian is built for high performance:
- Efficient async/await patterns throughout
- System.IO.Pipelines for optimal I/O operations
- Connection pooling and throttling
- Minimal memory allocations
- Configurable buffer sizes
Security Considerations
- Always use TLS/SSL in production environments
- Implement proper authentication mechanisms
- Configure rate limiting to prevent abuse
- Validate and sanitize all inputs
- Implement proper logging and monitoring
- Keep the library updated with latest security patches
Requirements
- .NET 6.0, 7.0, or 8.0
- Windows, Linux, or macOS
Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, please open an issue on GitHub or contact the maintainers.
Acknowledgments
Built with ❤️ using modern .NET technologies.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
-
net6.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
- System.IO.Pipelines (>= 9.0.10)
-
net7.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
- System.IO.Pipelines (>= 9.0.10)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
- System.IO.Pipelines (>= 9.0.10)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on Zetian:
| Package | Downloads |
|---|---|
|
Zetian.AntiSpam
Comprehensive anti-spam solution for Zetian SMTP Server. Features include SPF/DKIM/DMARC email authentication, Bayesian spam filtering with machine learning, RBL/DNSBL reputation checks, greylisting, custom filters, and real-time threat detection. Easy integration with flexible configuration options. |
|
|
Zetian.Storage
Core storage abstraction layer for Zetian SMTP Server. Provides essential interfaces (IMessageStore) and base configurations for building custom storage providers. This package serves as the foundation for all Zetian storage implementations including SQL Server, PostgreSQL, MongoDB, Redis, and cloud storage providers. |
|
|
Zetian.Monitoring
Comprehensive monitoring and metrics collection for Zetian SMTP Server. Features include real-time metrics, Prometheus/Grafana integration, OpenTelemetry support, command-level statistics, and performance monitoring. |
|
|
Zetian.HealthCheck
Health check monitoring extension for Zetian SMTP Server. Provides HTTP endpoints for liveness, readiness, and detailed health status monitoring with customizable checks, metrics, and Kubernetes integration support. Perfect for production monitoring and orchestration systems. |
|
|
Zetian.Relay
SMTP relay and proxy extension for Zetian SMTP Server. Features include smart host support, queue management, load balancing, and failover mechanisms. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.0.15 | 1,071 | 12/1/2025 | |
| 1.0.14 | 329 | 11/1/2025 | |
| 1.0.13 | 596 | 10/29/2025 | |
| 1.0.12 | 234,483 | 10/25/2025 | |
| 1.0.11 | 1,914 | 10/23/2025 | |
| 1.0.10 | 200,603 | 10/23/2025 | |
| 1.0.9 | 9,355 | 10/22/2025 | |
| 1.0.8 | 229,140 | 10/21/2025 | |
| 1.0.7 | 6,806 | 10/21/2025 | |
| 1.0.6 | 5,075 | 10/21/2025 | |
| 1.0.5 | 6,816 | 10/21/2025 | |
| 1.0.4 | 2,327 | 10/20/2025 | |
| 1.0.3 | 3,864 | 10/20/2025 | |
| 1.0.2 | 8,286 | 10/20/2025 | |
| 1.0.1 | 7,023 | 10/19/2025 | |
| 1.0.0 | 3,745 | 10/19/2025 |