Zetian.Storage.Providers 1.0.0

Prefix Reserved
Suggested Alternatives

Zetian.Storage

dotnet add package Zetian.Storage.Providers --version 1.0.0
                    
NuGet\Install-Package Zetian.Storage.Providers -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zetian.Storage.Providers" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zetian.Storage.Providers" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Zetian.Storage.Providers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zetian.Storage.Providers --version 1.0.0
                    
#r "nuget: Zetian.Storage.Providers, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zetian.Storage.Providers@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zetian.Storage.Providers&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Zetian.Storage.Providers&version=1.0.0
                    
Install as a Cake Tool

Zetian.Storage.Providers - Database & Cloud Storage for SMTP

NuGet-Version NuGet-Download License

Professional storage providers for Zetian SMTP Server, enabling persistent message storage in various databases and cloud storage systems. Store your SMTP messages in SQL Server, PostgreSQL, MongoDB, Redis, Azure Blob Storage, or Amazon S3.

⚡ Features

  • 🔒 Thread-safe - Concurrent access handling
  • 🔴 Redis - High-performance caching and temporary storage
  • 🪣 Amazon S3 - AWS cloud storage with lifecycle management
  • 🗜️ Compression - Optional message compression to save space
  • 🍃 MongoDB - NoSQL storage with GridFS for large attachments
  • ☁️ Azure Blob - Scalable cloud storage with Azure integration
  • 🔄 Automatic Retry - Built-in retry mechanism for resilience
  • 📊 Auto-indexing - Automatic index creation for optimal performance
  • 🐘 PostgreSQL - Advanced storage with JSONB support and partitioning
  • 🗄️ SQL Server - Full-featured relational database storage with compression

📦 Installation

# Install Zetian SMTP Server (required)
dotnet add package Zetian

# Install Storage Providers
dotnet add package Zetian.Storage.Providers

🚀 Quick Start

SQL Server Storage

using Zetian.Server;
using Zetian.Storage.Providers.Extensions;

var server = new SmtpServerBuilder()
    .Port(25)
    .WithSqlServerStorage(
        "Server=localhost;Database=SmtpDb;Trusted_Connection=true;",
        config =>
        {
            config.TableName = "EmailMessages";
            config.CompressMessageBody = true;
            config.MaxMessageSizeMB = 50;
        })
    .Build();

await server.StartAsync();

PostgreSQL Storage

var server = new SmtpServerBuilder()
    .Port(25)
    .WithPostgreSqlStorage(
        "Host=localhost;Database=smtp_db;Username=postgres;Password=secret",
        config =>
        {
            config.UseJsonbForHeaders = true;
            config.EnablePartitioning = true;
            config.PartitionInterval = PartitionInterval.Monthly;
        })
    .Build();

MongoDB Storage

var server = new SmtpServerBuilder()
    .Port(25)
    .WithMongoDbStorage(
        "mongodb://localhost:27017",
        "smtp_database",
        config =>
        {
            config.UseGridFsForLargeMessages = true;
            config.GridFsThresholdMB = 10;
            config.EnableTTL = true;
            config.TTLDays = 90;
        })
    .Build();

🛠️ Advanced Configuration

SQL Server with Full Options

var sqlConfig = new SqlServerStorageConfiguration
{
    ConnectionString = "Server=localhost;Database=SmtpDb;Trusted_Connection=true;",
    TableName = "SmtpMessages",
    SchemaName = "mail",
    AutoCreateTable = true,
    CompressMessageBody = true,
    MaxMessageSizeMB = 100,
    StoreAttachmentsSeparately = true,
    AttachmentsTableName = "SmtpAttachments",
    EnableRetry = true,
    MaxRetryAttempts = 3,
    RetryDelayMs = 1000
};

var store = new SqlServerMessageStore(sqlConfig);

var server = new SmtpServerBuilder()
    .MessageStore(store)
    .Build();

PostgreSQL with Partitioning

var pgConfig = new PostgreSqlStorageConfiguration
{
    ConnectionString = "Host=localhost;Database=smtp_db;Username=postgres;Password=secret",
    TableName = "messages",
    SchemaName = "smtp",
    EnablePartitioning = true,
    PartitionInterval = PartitionInterval.Monthly,
    UseJsonbForHeaders = true,
    CreateIndexes = true,
    CompressMessageBody = false
};

var store = new PostgreSqlMessageStore(pgConfig);

MongoDB with GridFS

var mongoConfig = new MongoDbStorageConfiguration
{
    ConnectionString = "mongodb://localhost:27017",
    DatabaseName = "smtp_server",
    CollectionName = "messages",
    UseGridFsForLargeMessages = true,
    GridFsThresholdMB = 5, // Use GridFS for messages > 5MB
    GridFsBucketName = "email_attachments",
    EnableTTL = true,
    TTLDays = 30, // Auto-delete after 30 days
    EnableSharding = true,
    ShardKeyField = "received_date"
};

var store = new MongoDbMessageStore(mongoConfig);

📊 Storage Provider Comparison

Provider Best For Pros Cons
Redis Caching, temporary storage Ultra-fast, simple Not for permanent storage
S3 AWS environments, archival Lifecycle policies, versioning Cloud costs, complexity
Azure Blob Cloud-native apps, large scale Unlimited storage, geo-redundancy Cloud costs, latency
PostgreSQL Open-source projects, complex queries Free, JSONB support, partitioning Setup complexity
MongoDB Large attachments, flexible schemas GridFS, TTL, horizontal scaling Memory usage, eventual consistency
SQL Server Enterprise environments, Windows-based systems Full ACID compliance, great tooling, compression License costs, Windows-centric

🔧 Configuration Options

Common Options (All Providers)

  • LogErrors - Error logging
  • RetryDelayMs - Delay between retries
  • EnableRetry - Automatic retry on failure
  • MaxRetryAttempts - Number of retry attempts
  • ConnectionTimeoutSeconds - Connection timeout

SQL Server Specific

  • CompressMessageBody - GZip compression
  • StoreAttachmentsSeparately - Separate table for attachments

PostgreSQL Specific

  • PartitionInterval - Daily/Monthly/Yearly
  • UseJsonbForHeaders - Store headers as JSONB
  • EnablePartitioning - Table partitioning by date

MongoDB Specific

  • EnableTTL - Auto-expiration
  • EnableSharding - Horizontal scaling
  • UseGridFsForLargeMessages - GridFS for large files

🏗️ Database Schema

SQL Server Schema

CREATE TABLE SmtpMessages (
    Id BIGINT IDENTITY PRIMARY KEY,
    MessageId NVARCHAR(255) NOT NULL,
    SessionId NVARCHAR(255) NOT NULL,
    FromAddress NVARCHAR(500),
    ToAddresses NVARCHAR(MAX),
    Subject NVARCHAR(1000),
    ReceivedDate DATETIME2,
    MessageSize BIGINT,
    MessageBody VARBINARY(MAX),
    IsCompressed BIT,
    Headers NVARCHAR(MAX),
    HasAttachments BIT,
    AttachmentCount INT,
    Priority NVARCHAR(50)
)

PostgreSQL Schema

CREATE TABLE smtp_messages (
    id BIGSERIAL PRIMARY KEY,
    message_id VARCHAR(255) NOT NULL,
    session_id VARCHAR(255) NOT NULL,
    from_address VARCHAR(500),
    to_addresses TEXT,
    subject VARCHAR(1000),
    received_date TIMESTAMPTZ,
    message_size BIGINT,
    message_body BYTEA,
    is_compressed BOOLEAN,
    headers JSONB,
    has_attachments BOOLEAN,
    attachment_count INTEGER,
    priority VARCHAR(50)
)

📈 Performance Tips

  1. Enable Compression for text-heavy emails
  2. Create Indexes on frequently queried fields
  3. Use GridFS in MongoDB for large attachments
  4. Set TTL in MongoDB to auto-clean old messages
  5. Use Connection Pooling for database connections
  6. Enable Partitioning in PostgreSQL for time-series data

🔍 Querying Stored Messages

SQL Server

using (var connection = new SqlConnection(connectionString))
{
    var messages = await connection.QueryAsync<Message>(
        "SELECT * FROM SmtpMessages WHERE ReceivedDate > @Date",
        new { Date = DateTime.UtcNow.AddDays(-7) }
    );
}

MongoDB

var filter = Builders<BsonDocument>.Filter.Gte("received_date", DateTime.UtcNow.AddDays(-7));
var messages = await collection.Find(filter).ToListAsync();

📋 Requirements

  • Windows, Linux, or macOS
  • .NET 6.0, 7.0, 8.0, 9.0, or 10.0
  • Zetian SMTP Server package

📚 Documentation & Support

🔒 Security Considerations

  • Always use connection string encryption
  • Enable SSL/TLS for database connections
  • Use least-privilege database accounts
  • Consider data encryption at rest
  • Implement access controls and auditing
  • Regular backup and recovery procedures

📄 License

MIT License - see LICENSE


Built with ❤️ for the .NET community

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 274 10/25/2025 1.0.0 is deprecated because it is no longer maintained.

All changes are detailed at https://zetian.soferity.com/changelog.