TailoredApps.Shared.Email
2.1.0
See the version list below for details.
dotnet add package TailoredApps.Shared.Email --version 2.1.0
NuGet\Install-Package TailoredApps.Shared.Email -Version 2.1.0
<PackageReference Include="TailoredApps.Shared.Email" Version="2.1.0" />
<PackageVersion Include="TailoredApps.Shared.Email" Version="2.1.0" />
<PackageReference Include="TailoredApps.Shared.Email" />
paket add TailoredApps.Shared.Email --version 2.1.0
#r "nuget: TailoredApps.Shared.Email, 2.1.0"
#:package TailoredApps.Shared.Email@2.1.0
#addin nuget:?package=TailoredApps.Shared.Email&version=2.1.0
#tool nuget:?package=TailoredApps.Shared.Email&version=2.1.0
TailoredApps.Shared.Email
Sending e-mail behind one interface, IEmailProvider. The package contains an SMTP provider, a console provider
for development, and IMailMessageBuilder implementations that build a message body from a template and a
dictionary of variables.
Installation
dotnet add package TailoredApps.Shared.Email
Registration
using TailoredApps.Shared.Email;
using TailoredApps.Shared.Email.MailMessageBuilder;
builder.Services.RegisterSmtpProvider(); // IEmailProvider -> SmtpEmailProvider (transient)
// builder.Services.RegisterConsoleProvider(); // IEmailProvider -> EmailServiceToConsolleWritter (writes to the console)
// Message bodies from template files. No IMailMessageBuilder is registered unless you add one.
builder.Services.Configure<TokenReplacingMailMessageBuilderOptions>(options =>
{
options.Location = Path.Combine(builder.Environment.ContentRootPath, "EmailTemplates");
options.FileExtension = "html";
});
builder.Services.AddTransient<IMailMessageBuilder, TokenReplacingMailMessageBuilder>();
Usage
public class WelcomeMailSender(IEmailProvider email, IMailMessageBuilder builder)
{
// EmailTemplates/welcome.html: <h1>Hello, {{UserName}}!</h1>
public Task<string> Send(string address, string userName)
{
var body = builder.Build("welcome.html", new Dictionary<string, string> { ["UserName"] = userName }, null);
return email.SendMail(address, "Welcome", body, attachments: null); // or file name -> byte[]
}
}
Configuration
SmtpEmailProvider reads the Mail:Providers:Smtp section:
{
"Mail": {
"Providers": {
"Smtp": {
"Host": "smtp.example.com",
"Port": 587,
"UserName": "noreply@example.com",
"Password": "<smtp-password>",
"From": "noreply@example.com",
"IsProd": true,
"CatchAll": "developers@example.com"
}
}
}
}
| Key | Meaning | Default |
|---|---|---|
Host, Port |
SMTP server address and port | none, 0 |
UserName, Password |
Credentials sent to the server | none |
From |
Sender address (From and Sender headers); required | none |
EnableSsl |
Encrypt the connection | true |
IsProd |
true: send to the given recipient; false: send everything to CatchAll |
false |
CatchAll |
Address that receives all mail when IsProd is false; required in that case |
none |
TokenReplacingMailMessageBuilderOptions is set in code: Location (template directory), FileExtension
(without the dot; empty means every file) and HtmlEncodeVariables (default true).
Good to know
IsProddefaults tofalse: until it is set, every message goes toCatchAll, and a missingCatchAllthrowsInvalidOperationException. A missingMail:Providers:Smtpsection throwsInvalidOperationExceptionwhen the options are first read; a missingFromthrowsArgumentNullException.SendMailtakes exactly one recipient. An address containing,,;or a line break throwsFormatException. It returns theMessage-IDheader it generated for the message.- Bodies are sent as HTML in UTF-8.
TokenReplacingMailMessageBuilderHTML-encodes{{Token}}values, inserts{{{Token}}}values as they are, leaves unknown tokens untouched and replaces in a single pass. - The template key is the file name with its extension.
Locationis searched with its sub-directories and read on everyBuildcall. An unknown key throwsKeyNotFoundException. DefaultMessageBuilderworks on thetemplatesdictionary passed toBuildand replaces the variable keys as plain text (no braces), HTML-encoding the values unless created withhtmlEncodeVariables: false.SmtpEmailProvider.GetMailis not implemented (NotImplementedException); the console provider returns an empty list. Reading a mailbox is whatTailoredApps.Shared.Email.Office365does.
Documentation
| 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. net11.0 is compatible. |
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.15)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.15)
- Microsoft.Extensions.Options (>= 10.0.15)
- TailoredApps.Shared.Email.Models (>= 2.1.0)
-
net11.0
- Microsoft.Extensions.Configuration.Binder (>= 11.0.0)
- TailoredApps.Shared.Email.Models (>= 2.1.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on TailoredApps.Shared.Email:
| Package | Downloads |
|---|---|
|
TailoredApps.Shared.MediatR.Email
Package Description |
|
|
TailoredApps.Shared.Email.Office365
Shared.Email.Office365 is a simple Office365 for Email for .NET |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-preview.2 | 53 | 11/12/2026 |
| 3.0.0-preview.1 | 65 | 11/12/2026 |
| 2.1.0 | 111 | 11/12/2026 |
| 2.0.1 | 105 | 11/12/2026 |
| 2.0.0 | 131 | 11/12/2026 |
| 1.6.0 | 129 | 11/12/2026 |
| 1.4.19 | 513 | 10/26/2026 |
| 1.4.18 | 606 | 10/23/2026 |
| 1.4.17 | 797 | 10/6/2026 |
| 1.4.16 | 141 | 9/28/2026 |
| 1.4.15 | 149 | 9/21/2026 |
| 1.4.14 | 175 | 8/20/2026 |
| 1.4.13 | 175 | 8/20/2026 |
| 1.4.12 | 174 | 8/20/2026 |
| 1.4.11 | 167 | 8/7/2026 |
| 1.4.10 | 273 | 7/8/2026 |
| 1.4.9 | 182 | 7/8/2026 |
| 1.4.8 | 182 | 7/6/2026 |
| 1.4.7 | 197 | 5/20/2026 |
| 1.4.6 | 184 | 5/20/2026 |