Soenneker.Email.Sender 11.0.1565

Prefix Reserved
dotnet add package Soenneker.Email.Sender --version 11.0.1565
                    
NuGet\Install-Package Soenneker.Email.Sender -Version 11.0.1565
                    
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="11.0.1565" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Email.Sender" Version="11.0.1565" />
                    
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 11.0.1565
                    
#r "nuget: Soenneker.Email.Sender, 11.0.1565"
                    
#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@11.0.1565
                    
#: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=11.0.1565
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Email.Sender&version=11.0.1565
                    
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 net11.0 is compatible. 
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
11.0.1565 43 11/30/2026
11.0.1564 42 11/30/2026
11.0.1563 46 11/30/2026
11.0.1562 45 11/30/2026
11.0.1561 45 11/30/2026
11.0.1560 52 11/29/2026
11.0.1559 52 11/29/2026
11.0.1558 60 11/29/2026
11.0.1557 115 11/22/2026
11.0.1556 114 11/19/2026
11.0.1555 97 11/19/2026
11.0.1554 94 11/19/2026
11.0.1553 92 11/19/2026
11.0.1552 102 11/18/2026
11.0.1551 98 11/18/2026
11.0.1549 102 11/18/2026
11.0.1548 98 11/18/2026
11.0.1545 105 11/18/2026
11.0.1542 101 11/18/2026
11.0.1541 107 11/15/2026
Loading failed

Updated Soenneker.Utils.Json to 11.0.2802