NPv.Mail 2.1.1

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

NPv.Mail

SMTP and templated email sender implementation for NPv.Mail.Abstractions.

πŸ“Œ Breaking changes

v2.0.0

  • Target framework updated to net10.0 (dropped net9.0 support).

This is a personal library that focuses on the latest .NET runtime to keep maintenance simple and enjoyable.

✨ Overview

NPv.Mail provides a ready-to-use implementation for sending emails and rendering templates:

  • πŸ“§ MailKitMailSender – SMTP sender powered by MailKit and MimeKit.
  • πŸ“ ScribanEmailTemplateRenderer – template rendering engine based on Scriban.
  • βš™οΈ Options binding – strongly typed SmtpSettings with IOptions<T> integration.
  • πŸ”Œ Designed for clean architecture – works with NPv.Mail.Abstractions interfaces and fits naturally into DI.

Use this package in your application or infrastructure layers to actually deliver messages defined through abstractions.

πŸš€ Getting Started

1. Installation

dotnet add package NPv.Mail

You also need the abstractions:

dotnet add package NPv.Mail.Abstractions

2. Configuration

Add SMTP settings to your appsettings.json:

"Smtp": {
  "ServerName": "smtp.example.com",
  "ServerPort": 587,
  "UserName": "user@example.com",
  "Password": "yourpassword",
  "FromAddress": "noreply@example.com",
  "FromName": "Example Sender"
}

3. Register Services

builder.Services.Configure<SmtpSettings>(
    builder.Configuration.GetSection("Smtp"));

builder.Services.AddTransient<IMailSender, MailKitMailSender>();
builder.Services.AddTransient<IEmailTemplateRenderer>(sp =>
    new ScribanEmailTemplateRenderer([typeof(Program).Assembly]));

4. Send an Email

var sender = app.Services.GetRequiredService<IMailSender>();

var message = new MailRequest
{
    To = "recipient@example.com",
    Subject = "Welcome!",
    HtmlBody = "<p>Hello world!</p>",
    Attachments =
    [
        new MailAttachment
        {
            FileName = "hello.txt",
            Content = Encoding.UTF8.GetBytes("Hello world!"),
            ContentType = "text/plain"
        }
    ]
};

await sender.SendAsync(message);

5. Render a Template

var renderer = app.Services.GetRequiredService<IEmailTemplateRenderer>();

var content = renderer.Render(new ConfirmEmailTemplateModel(confirmUrl, "en"));

Console.WriteLine(content.Subject);
Console.WriteLine(content.HtmlBody);

Author's Note

This library grew out of my long-standing personal interest in structuring and publishing open source packages. Over time, I’ve revisited and refined earlier internal utilities and ideas, giving them a more consistent shape and preparing them for wider reuse. Along the way, I’ve also taken the opportunity to explore how open source distribution and licensing work in the .NET ecosystem.

It’s a small step toward something I’ve always wanted to try β€” sharing practical, minimal tools that reflect years of learning, experimentation, and refinement.

Hopefully, someone finds it useful.

Nikolai πŸ˜›

βš–οΈ License

MIT β€” free for commercial and open-source use.

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
2.1.1 122 4/22/2026
2.1.0 201 3/24/2026
2.0.3 139 3/7/2026
2.0.2 4,489 2/1/2026
2.0.1 12,239 12/24/2025
2.0.0 12,226 12/24/2025
1.0.3 14,224 9/13/2025
1.0.2 14,212 9/13/2025
1.0.1 14,205 9/13/2025
1.0.0 14,235 9/10/2025