Getting Started Guide
Install Zetian SMTP Server and run your first server in minutes.
Requirements
- • Windows, Linux, or macOS
- • .NET 6.0, 7.0, 8.0, 9.0, or 10.0
- • Administrator/root privileges (for low port numbers)
1
Installation
Add Zetian to your project using NuGet Package Manager:
dotnet add package Zetian
Alternatively, you can use Package Manager Console in Visual Studio or .NET CLI.Visit NuGet page →
2
Your First SMTP Server
Create a simple SMTP server:
Program.cs
using Zetian;
// Create a simple SMTP server
using var server = SmtpServerBuilder.CreateBasic();
// When message is received
server.MessageReceived += (sender, e) =>
{
Console.WriteLine($"From: {e.Message.From}");
Console.WriteLine($"To: {string.Join(", ", e.Message.Recipients)}");
Console.WriteLine($"Subject: {e.Message.Subject}");
};
// Start the server
await server.StartAsync();
Console.WriteLine($"SMTP Server running on {server.Endpoint}");
// Keep the server running
Console.ReadLine();
Port 25
Default SMTP port
Event-Driven
Listen to message events
Async/Await
Modern async pattern
3
Add Authentication
Add authentication mechanism for security:
Program.cs
using Zetian;
// Authenticated server
using var server = new SmtpServerBuilder()
.Port(587)
.RequireAuthentication()
.AllowPlainTextAuthentication() // For testing without TLS
.SimpleAuthentication("admin", "password123")
.Build();
// When a message is received from an authenticated user
server.MessageReceived += (sender, e) =>
{
if (e.Session.IsAuthenticated)
{
Console.WriteLine($"Authenticated user: {e.Session.AuthenticatedIdentity}");
Console.WriteLine($"Subject: {e.Message.Subject}");
}
};
await server.StartAsync();
4
TLS/SSL Security
Add encrypted connection support with STARTTLS:
Program.cs
using Zetian;
// Secure server with TLS/SSL support
using var server = new SmtpServerBuilder()
.Port(587)
.Certificate("certificate.pfx", "cert_password")
.RequireSecureConnection()
.RequireAuthentication()
.Build();
await server.StartAsync();
🎉 Congratulations! Your first SMTP server is ready!
Now you're ready to learn more advanced features: