Soenneker.Email.Sender 4.0.1303

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Email.Sender

Renders EmailMessage payloads with Scriban templates, converts them to MIME, and sends them through the configured SMTP utility.

Install

dotnet add package Soenneker.Email.Sender

Resource layout

Email resources are loaded relative to the application's output directory:

LocalResources/
  Email/
    Templates/
      default.html
    Contents/
      welcome.html

When TemplateFileName is null, default.html is used. ContentFileName is optional; when supplied, that content is rendered first and exposed to the outer template as bodyText. Message tokens and partials become Scriban globals, and the subject token is always overwritten with the message subject.

Template and content names must resolve beneath their respective directories. Absolute paths and traversal outside those roots are rejected.

Configuration

{
  "Email": {
    "Enabled": true,
    "DefaultAddress": "mailer@example.com",
    "DefaultName": "Example App"
  },
  "Smtp": {
    "Enable": true,
    "Host": "smtp.example.com",
    "Port": 587,
    "Username": "mailer@example.com",
    "Password": "use-a-secret-provider",
    "UseSsl": false,
    "UseStartTls": true
  }
}

Email:Enabled, Email:DefaultAddress, Email:DefaultName, and Smtp:Enable are read when the sender is constructed. A send returns false without rendering when either enable flag is false. SMTP connection settings are documented by Soenneker.Email.Mime and should come from a secret provider where appropriate.

Registration

using Soenneker.Email.Sender.Registrars;

services.AddEmailSenderAsSingleton();

This registers IEmailSender and its MIME and template dependencies as singletons. AddEmailSenderAsScoped() registers the sender, MIME utility, and template utility as scoped services while their intentionally shared lower-level dependencies remain reusable according to their own registrations.

Send an email

using Soenneker.Email.Senders.Abstract;
using Soenneker.Enums.Email.Format;
using Soenneker.Enums.Email.Priority;
using Soenneker.Messages.Email;

var message = new EmailMessage
{
    Type = "email.welcome.v1",
    Id = Guid.NewGuid().ToString("N"),
    Queue = "email",
    Sender = "accounts-api",
    CreatedAt = DateTimeOffset.UtcNow,
    To = ["recipient@example.net"],
    Subject = "Welcome, Alex",
    Format = EmailFormat.Html,
    Priority = EmailPriority.Normal,
    ContentFileName = "welcome.html",
    Tokens = new Dictionary<string, string>
    {
        ["first_name"] = "Alex"
    }
};

IEmailSender sender = serviceProvider.GetRequiredService<IEmailSender>();
bool sent = await sender.Send(message, cancellationToken);

Name and Address fall back to the configured defaults. ReplyTo, Format, Priority, To, Cc, and Bcc are carried into the MIME message. Rendering, address parsing, or SMTP failures are logged and rethrown.

The string overload deserializes messageContent as EmailMessage; its type argument is transport metadata and does not select an arbitrary CLR type.

Recipient addresses are logged only as counts at information and error levels. Debug logging includes recipient addresses, and the underlying MIME utility can optionally log full message content, so choose production log levels with email privacy in mind.

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
4.0.1303 0 9/4/2026
4.0.1302 0 9/4/2026
4.0.1299 0 9/4/2026
4.0.1298 40 9/3/2026
4.0.1296 77 9/1/2026
4.0.1293 73 9/1/2026
4.0.1292 81 8/31/2026
4.0.1291 74 8/31/2026
4.0.1290 81 8/31/2026
4.0.1287 79 8/31/2026
4.0.1286 79 8/31/2026
4.0.1283 80 8/30/2026
4.0.1281 84 8/30/2026
4.0.1279 81 8/30/2026
4.0.1276 82 8/30/2026
4.0.1274 76 8/30/2026
4.0.1271 84 8/30/2026
4.0.1270 74 8/30/2026
4.0.1269 77 8/29/2026
4.0.1265 78 8/29/2026
Loading failed

Updated Multiple NuGet packages