Carneiro.Core.Emails 7.6.2

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

Carneiro.Core.Emails

A transport-agnostic email sending abstraction (IEmailSender), with an SMTP implementation (SmtpEmailSender) built on MailKit.

Registration

services.AddSmtpEmailSender(configuration);

Overloads also accept an IConfigurationSection, an Action<SmtpEmailSenderOptions>, or a SmtpEmailSenderOptions instance directly. The IConfiguration overload reads from a section named SmtpEmailSenderOptions (nameof(SmtpEmailSenderOptions)).

Registration wires up IEmailSender → SmtpEmailSender (scoped).

IEmailSender

Exposes a single method, SendAsync(EmailMessage message, CancellationToken cancellationToken = default).

Implementations are expected to:

  • Use EmailMessage.From when set, otherwise fall back to a sender configured on the implementation itself (e.g. SmtpEmailSenderOptions.DefaultFrom).
  • Throw an implementation-specific exception derived from EmailRzException when the message can't be delivered.

SmtpEmailSender

  • Connects to the configured SMTP server, optionally authenticates, sends the message, and always disconnects — even on failure.
  • Wraps any exception raised while connecting, authenticating, or sending into an EmailSendRzException, logging the failure beforehand.
  • Throws InvalidOperationException if the message has no From and no SmtpEmailSenderOptions.DefaultFrom is configured.

SmtpEmailSenderOptions

Settings below are listed by their configuration key, as read from the SmtpEmailSenderOptions section (e.g. an Octopus Deploy structured configuration variable):

  • SmtpEmailSenderOptions:Host (string) — the SMTP server host name.
  • SmtpEmailSenderOptions:Port (int) — the SMTP server port. Defaults to 587.
  • SmtpEmailSenderOptions:SecureSocketOptions (MailKit.Security.SecureSocketOptions) — how the connection is secured. Defaults to StartTlsWhenAvailable.
  • SmtpEmailSenderOptions:Username / SmtpEmailSenderOptions:Password (string?) — credentials used to authenticate. When Username is null or empty, no authentication is attempted.
  • SmtpEmailSenderOptions:DefaultFrom:Address / SmtpEmailSenderOptions:DefaultFrom:DisplayName (EmailAddress?) — the sender address used when a message doesn't set EmailMessage.From.
  • SmtpEmailSenderOptions:Timeout (TimeSpan) — connection and send timeout. Defaults to 30 seconds.

Models

  • EmailMessage — From, To, Cc, Bcc, ReplyTo (all EmailAddress), Subject, Body, IsBodyHtml (defaults to true), and Attachments.
  • EmailAddress — an Address with an optional DisplayName; implicitly convertible from a plain string, e.g. message.To.Add("jane.doe@example.com").
  • EmailAttachment — FileName, Content (byte[]), and ContentType (defaults to application/octet-stream).

Exceptions

  • EmailRzException — abstract base for all email-related exceptions.
  • EmailSendRzException — thrown by SmtpEmailSender when a message fails to send; wraps the underlying MailKit exception.

Example

var message = new EmailMessage
{
    To = { "jane.doe@example.com" },
    Subject = "Welcome!",
    Body = "<p>Thanks for signing up.</p>",
};

await emailSender.SendAsync(message);
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
7.6.2 91 9/28/2026
7.6.1 92 9/28/2026
7.6.0 98 9/16/2026
7.5.12 87 9/16/2026
7.5.11 96 9/15/2026
7.5.10 93 9/15/2026
7.5.9 99 9/14/2026
7.5.8 100 9/10/2026
7.5.7 115 9/6/2026
7.5.7-beta.130 71 9/6/2026