Email.Smtp 1.4.1

dotnet add package Email.Smtp --version 1.4.1
                    
NuGet\Install-Package Email.Smtp -Version 1.4.1
                    
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="Email.Smtp" Version="1.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Email.Smtp" Version="1.4.1" />
                    
Directory.Packages.props
<PackageReference Include="Email.Smtp" />
                    
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 Email.Smtp --version 1.4.1
                    
#r "nuget: Email.Smtp, 1.4.1"
                    
#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 Email.Smtp@1.4.1
                    
#: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=Email.Smtp&version=1.4.1
                    
Install as a Cake Addin
#tool nuget:?package=Email.Smtp&version=1.4.1
                    
Install as a Cake Tool

Email.Smtp

Transactional email for .NET behind one IEmailService abstraction, with a config-driven provider switch: send via SMTP (MailKit) or the Resend HTTP API by flipping a single config value — zero code change. Compatible with Mailpit (dev), self-hosted Maddy/Postal, any standard SMTP server, or Resend.

Features

  • One IEmailService abstraction, multiple transports (Email:Provider = Smtp | Resend | Postmark)
  • MailKit-based SMTP sending (replaces deprecated System.Net.Mail.SmtpClient)
  • Resend HTTP API provider for high-deliverability managed sending
  • Code-based HTML email templates (embedded resources)
  • {{Placeholder}} template rendering with caching
  • SSL/TLS support for production SMTP servers
  • Optional authentication (skip for Mailpit in dev)
  • Shared email_sent / email_failed log tokens across every provider (Loki-greppable)

Provider selection (config-driven, zero code change)

Register once with AddTransactionalEmail(IConfiguration) and switch transports via config:

// In Program.cs — reads Email:Provider, defaults to Smtp when absent
builder.Services.AddTransactionalEmail(builder.Configuration);
// SMTP (default) — options read from the existing "Smtp" section
{
  "Email": { "Provider": "Smtp" },
  "Smtp": { "Host": "mailpit", "Port": 1025, "UseSsl": false,
            "FromAddress": "noreply@localhost", "FromName": "SaaS Platform" }
}

// Resend — flip Provider, add the Email:Resend section, no code change
{
  "Email": { "Provider": "Resend" },
  "Email:Resend": {
    "ApiKey": "re_xxx",                       // secret; supply via env/secret store
    "FromAddress": "noreply@dloizides.com",   // must be a Resend-verified domain
    "FromName": "SaaS Platform"
  }
}

Postmark is a reserved provider value (recognised by the switch) but not yet implemented — selecting it throws a clear NotSupportedException. You can also register a single provider directly with AddSmtpEmail(...) or AddResendEmail(...).

Templates Included

Template Placeholders
otp-code AppName, Code, ExpiryMinutes
welcome AppName, UserName, TenantName, DashboardUrl
password-reset AppName, ResetUrl, ExpiryMinutes
payment-receipt AppName, PlanName, Amount, Date, InvoiceNumber
payment-failed AppName, PlanName, Amount, BillingUrl
account-deletion AppName

Usage

// In Program.cs or DI setup
builder.Services.AddSmtpEmail(options =>
    builder.Configuration.GetSection("Smtp").Bind(options));

// In appsettings.json
{
  "Smtp": {
    "Host": "mailpit",     // or "postal.yourdomain.com"
    "Port": 1025,          // or 587 for TLS
    "UseSsl": false,
    "FromAddress": "noreply@localhost",
    "FromName": "SaaS Platform"
  }
}

// Send a templated email
var result = await emailService.SendTemplatedAsync(
    EmailTemplateNames.OtpCode,
    new EmailRecipient { Address = "user@example.com" },
    "Your Verification Code",
    new Dictionary<string, string>
    {
        ["AppName"] = "My SaaS",
        ["Code"] = "123456",
        ["ExpiryMinutes"] = "5"
    });
Product Compatible and additional computed target framework versions.
.NET 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.4.1 96 7/27/2026
1.4.0 96 7/27/2026
1.3.1 129 7/8/2026
1.0.0 236 3/15/2026