Decode.Email.Smtp 3.0.0

dotnet add package Decode.Email.Smtp --version 3.0.0
                    
NuGet\Install-Package Decode.Email.Smtp -Version 3.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="3.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="3.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 3.0.0
                    
#r "nuget: Decode.Email.Smtp, 3.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@3.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=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Decode.Email.Smtp&version=3.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), applied by both registration overloads — bound to IConfiguration or configured in code.

📦 Installation

Add the package to your API or Infrastructure project:

dotnet add package Decode.Email.Smtp

🛠️ 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 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
3.0.0 106 9/14/2026
2.1.0 111 9/13/2026
2.0.2 99 9/13/2026
2.0.1 100 9/13/2026
2.0.0 130 7/28/2026
1.0.0 126 7/22/2026