WeChooz.Aspire.MailKit 1.0.0

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

WeChooz Aspire Integration MailKit

CI

This .NET Aspire Integration registers MailKit in your project with health checks, logging and telemetry.

Get started

To get started, install the install the 📦 WeChooz.Aspire.MailKit NuGet package in your application project.

.NET CLI

dotnet add package WeChooz.Aspire.MailKit

Usage

In the Program.cs file of your project, call the AddMailKit extension method on the application builder to register a ISmtpClientFactory for use via the dependency injection container. This interface defines a async method GetSmtpClientAsync to retrieve a ready to use ISmtpClient:

builder.AddMailKit(builder.Configuration.GetConnectionString("mail"));

The integration expect a connection string with the format smtp://<host>:<port> or Endpoint=smtp://<host>:<port>. The latter format also allows optional Username and Password properties to setup authentication to the SMTP server.

More options

You can specify the settings for the SMTP client integration with the optional configureSettings parameter of the AddMailKit method. The parameter is action that take the current MailKitClientSettings.

Following options are available, in addition of the Endpoint and Credentials properties:

Name Default value Description
DisableHealthChecks false Disables the registration of the health checks for this SMTP client.
DisableTracing false Disables the tracing (logging) for ALL MailKit's SMTP client.
DisableMetrics false Disables the telemetry for ALL MailKit's SMTP client.
builder.AddMailKit(builder.Configuration.GetConnectionString("mail"), settings => { ...});

If you need to register multiple SMTP client (to split the load or implement a fallback mechanism), you can register the SMTP client by specifying a name for the registration before the connection string:

You can also specify a username and a password to secure the connection to the SMTP (local) server (learn how to work with parameter in .NET Aspire):

builder.AddMailKit("fallback", builder.Configuration.GetConnectionString("mail"));

Lovingly inspired by .NET Aspire documentation

This project is lovingly inspired by the integration samples in the .NET Aspire documentation.

It has been improved to meet our internal needs.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.0.0 625 8/10/2025