NPv.Mail.Abstractions
1.1.1
dotnet add package NPv.Mail.Abstractions --version 1.1.1
NuGet\Install-Package NPv.Mail.Abstractions -Version 1.1.1
<PackageReference Include="NPv.Mail.Abstractions" Version="1.1.1" />
<PackageVersion Include="NPv.Mail.Abstractions" Version="1.1.1" />
<PackageReference Include="NPv.Mail.Abstractions" />
paket add NPv.Mail.Abstractions --version 1.1.1
#r "nuget: NPv.Mail.Abstractions, 1.1.1"
#:package NPv.Mail.Abstractions@1.1.1
#addin nuget:?package=NPv.Mail.Abstractions&version=1.1.1
#tool nuget:?package=NPv.Mail.Abstractions&version=1.1.1
NPv.Mail.Abstractions
A lightweight set of abstractions for email sending and templating in .NET applications.
✨ 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 | 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. |
-
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.