Soenneker.Email.Sender 4.0.1306

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Email.Sender --version 4.0.1306
                    
NuGet\Install-Package Soenneker.Email.Sender -Version 4.0.1306
                    
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.1306" />
                    
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.1306" />
                    
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.1306
                    
#r "nuget: Soenneker.Email.Sender, 4.0.1306"
                    
#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.1306
                    
#: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.1306
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Email.Sender&version=4.0.1306
                    
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.1342 43 9/9/2026
4.0.1341 44 9/9/2026
4.0.1340 45 9/9/2026
4.0.1338 43 9/9/2026
4.0.1337 39 9/9/2026
4.0.1336 43 9/9/2026
4.0.1334 63 9/8/2026
4.0.1333 55 9/8/2026
4.0.1332 71 9/8/2026
4.0.1331 75 9/8/2026
4.0.1330 80 9/8/2026
4.0.1328 79 9/8/2026
4.0.1327 86 9/8/2026
4.0.1326 82 9/8/2026
4.0.1325 84 9/8/2026
4.0.1323 95 9/7/2026
4.0.1322 92 9/7/2026
4.0.1321 91 9/7/2026
4.0.1320 88 9/7/2026
4.0.1306 85 9/4/2026
Loading failed

Update dependency Soenneker.Email.Mime to 4.0.516 (#1813)