Soenneker.Email.Sender 4.0.1487

Prefix Reserved
dotnet add package Soenneker.Email.Sender --version 4.0.1487
                    
NuGet\Install-Package Soenneker.Email.Sender -Version 4.0.1487
                    
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.1487" />
                    
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.1487" />
                    
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.1487
                    
#r "nuget: Soenneker.Email.Sender, 4.0.1487"
                    
#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.1487
                    
#: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.1487
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Email.Sender&version=4.0.1487
                    
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.1487 62 10/15/2026
4.0.1486 38 10/15/2026
4.0.1485 44 10/15/2026
4.0.1483 33 10/15/2026
4.0.1482 45 10/15/2026
4.0.1480 46 10/14/2026
4.0.1479 43 10/14/2026
4.0.1477 41 10/14/2026
4.0.1476 46 10/14/2026
4.0.1472 50 10/14/2026
4.0.1471 51 10/14/2026
4.0.1461 76 10/13/2026
4.0.1457 76 10/13/2026
4.0.1456 81 10/12/2026
4.0.1452 83 10/12/2026
4.0.1450 84 10/12/2026
4.0.1446 92 10/12/2026
4.0.1443 89 10/12/2026
4.0.1439 85 10/11/2026
4.0.1435 89 10/11/2026
Loading failed

Update dependency Soenneker.Utils.Template to 4.0.444 (#1982)

Automatically merged