NPv.Mail.Abstractions 1.0.0

Suggested Alternatives

NPv.Mail.Abstractions 1.0.2

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

NPv.Common.Mail.Abstractions

A lightweight abstraction for sending email in .NET applications.

Features

  • IMailSender interface for sending email.
  • MailRequest DTO with optional file attachments.
  • SmtpSettings class for configuration binding via IOptions<T>.

Installation

Add a reference to the NuGet package (coming soon):

Install-Package NPv.Common.Mail.Abstractions

Usage

Configure services in Program.cs

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

builder.Services.AddTransient<IMailSender, MailKitMailSender>();

Send an email

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

await mailSender.SendAsync(message);

Configuration

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

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 — you are free to use this in commercial and open-source software.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NPv.Mail.Abstractions:

Package Downloads
NPv.Mail

SMTP and templated email sender implementation for NPv.Mail.Abstractions. Provides MailKit-based delivery, Scriban-based template rendering, and seamless configuration via Microsoft.Extensions.Options. Designed for clean architecture, DI integration, and testability.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 145 9/11/2025
1.1.0 166 6/4/2025
1.0.2 109 6/1/2025
1.0.1 150 6/1/2025 1.0.1 is deprecated because it has critical bugs.
1.0.0 152 5/31/2025 1.0.0 is deprecated because it has critical bugs.