Decode.Email.Smtp 2.0.0

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

Decode.Email.Smtp

SMTP email service provider implementation with console dev logger mode for the Decode ecosystem.

🚀 Features

  • SMTP Provider: Standard SMTP client supporting SSL/TLS, custom credentials, attachments, and Reply-To addresses.
  • Console Dev Logger Mode: Set UseConsoleLogger = true in development to simulate email sending via ILogger without needing a live SMTP server.
  • Template Engine Integration: Full support for HTML template rendering (#TAG# or {{TAG}}).
  • Options Validation: Native configuration validation on application startup (ValidateOnStart).

📦 Installation

Add the project reference to your API or Infrastructure project:

dotnet add reference ../Decode.Email.Smtp/Decode.Email.Smtp.csproj

🛠️ Setup

1. Configure Services in Program.cs

// 1. Register SMTP Email Provider bound to configuration section
builder.Services.AddDecodeSmtpEmail(builder.Configuration.GetSection("SmtpEmailOptions"));

// 2. (Optional) Register Embedded Email Templates from your Application Assembly
builder.Services.AddDecodeEmailEmbeddedTemplates(typeof(Program).Assembly, "MyApp.Domain.EmailTemplates");

2. Add Configuration in appsettings.json

{
  "SmtpEmailOptions": {
    "Host": "smtp.mailtrap.io",
    "Port": 2525,
    "Username": "your_username",
    "Password": "your_password",
    "EnableSsl": true,
    "DefaultFromEmail": "noreply@mydomain.com",
    "DefaultFromName": "My Application",
    "UseConsoleLogger": false
  }
}

3. Development / Staging Configuration (appsettings.Development.json)

To simulate email sending without connecting to a real SMTP server:

{
  "SmtpEmailOptions": {
    "Host": "localhost",
    "UseConsoleLogger": true
  }
}

📖 Usage Example

using Decode.Email.Abstractions.Interfaces;
using Decode.Email.Abstractions.Models;

public class PasswordRecoveryHandler(IEmailService emailService)
{
    public async Task HandleAsync(string userEmail, string recoveryCode)
    {
        // Sending an HTML template with dynamic replacements
        await emailService.SendTemplateAsync(
            to: new EmailAddress(userEmail),
            subject: "Password Recovery Code",
            templateName: "PasswordRecovery",
            model: new
            {
                CODE = recoveryCode,
                EXPIRATION = "15 minutes"
            }
        );
    }
}

📄 License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
3.0.0 106 9/14/2026
2.1.0 112 9/13/2026
2.0.2 99 9/13/2026
2.0.1 100 9/13/2026
2.0.0 131 7/28/2026
1.0.0 126 7/22/2026