NPv.Mail.Abstractions
2.1.0
dotnet add package NPv.Mail.Abstractions --version 2.1.0
NuGet\Install-Package NPv.Mail.Abstractions -Version 2.1.0
<PackageReference Include="NPv.Mail.Abstractions" Version="2.1.0" />
<PackageVersion Include="NPv.Mail.Abstractions" Version="2.1.0" />
<PackageReference Include="NPv.Mail.Abstractions" />
paket add NPv.Mail.Abstractions --version 2.1.0
#r "nuget: NPv.Mail.Abstractions, 2.1.0"
#:package NPv.Mail.Abstractions@2.1.0
#addin nuget:?package=NPv.Mail.Abstractions&version=2.1.0
#tool nuget:?package=NPv.Mail.Abstractions&version=2.1.0
NPv.Mail.Abstractions
A lightweight set of abstractions for email sending and templating in .NET applications.
π Breaking changes
v2.0.0
- Target framework updated to
net10.0(droppednet9.0support).
This is a personal library that focuses on the latest .NET runtime to keep maintenance simple and enjoyable.
β¨ Features
IMailSenderβ abstraction for sending emails.MailAttachmentβ DTO for file attachments.MailRequestβ DTO for email data, including optional file attachments.SmtpSettings- POCO for SMTP configuration, compatible with IConfiguration bindingEmailContent- DTO representing the rendered email content (subject and HTML body).IEmailTemplateModel- interface for providing localization data for email templates.IEmailTemplateRendererβ abstraction for rendering HTML email templates with localization and dynamic data.
π¦ Installation
Add a reference to the NuGet package (coming soon!):
Install-Package NPv.Mail.Abstractions
βοΈ Usage
Configure services in Program.cs
builder.Services.Configure<SmtpSettings>(
builder.Configuration.GetSection("Smtp")
);
// Register your implementations
builder.Services.AddTransient<IMailSender, MailKitMailSender>();
builder.Services.AddTransient<IEmailTemplateRenderer, ScribanTemplateRenderer>();
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);
Render a template
var content = _emailRender.Render(new ConfirmEmailTemplateModel(confirmUrl, "en"));
Console.WriteLine(emailContent.Subject);
Console.WriteLine(emailContent.HtmlBody);
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 | Versions 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. |
-
net10.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.