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
<PackageReference Include="WeChooz.Aspire.MailKit" Version="1.0.0" />
<PackageVersion Include="WeChooz.Aspire.MailKit" Version="1.0.0" />
<PackageReference Include="WeChooz.Aspire.MailKit" />
paket add WeChooz.Aspire.MailKit --version 1.0.0
#r "nuget: WeChooz.Aspire.MailKit, 1.0.0"
#:package WeChooz.Aspire.MailKit@1.0.0
#addin nuget:?package=WeChooz.Aspire.MailKit&version=1.0.0
#tool nuget:?package=WeChooz.Aspire.MailKit&version=1.0.0
WeChooz Aspire Integration MailKit
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 | Versions 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. |
-
net9.0
- MailKit (>= 4.7.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
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 |