Sienar.Plugin.MailKit
0.1.0
dotnet add package Sienar.Plugin.MailKit --version 0.1.0
NuGet\Install-Package Sienar.Plugin.MailKit -Version 0.1.0
<PackageReference Include="Sienar.Plugin.MailKit" Version="0.1.0" />
<PackageVersion Include="Sienar.Plugin.MailKit" Version="0.1.0" />
<PackageReference Include="Sienar.Plugin.MailKit" />
paket add Sienar.Plugin.MailKit --version 0.1.0
#r "nuget: Sienar.Plugin.MailKit, 0.1.0"
#:package Sienar.Plugin.MailKit@0.1.0
#addin nuget:?package=Sienar.Plugin.MailKit&version=0.1.0
#tool nuget:?package=Sienar.Plugin.MailKit&version=0.1.0
Sienar.MailKit plugin
This plugin configures your Sienar application to send email via SMTP through the MailKit library for .NET.
Configuration
You need to configure the MailKit plugin with your SMTP information in order to send mail. You can do this in one of two ways: via appsettings.json
or directly on the IServiceCollection
like normal. If you apply your own configuration, Sienar will detect an existing configuration and skip adding its own. All configuration is stored on the SmtpOptions class.
appsettings.json
configuration
If you want to configure your SMTP info via appsettings.json
, you need to add the following section to your appsettings.json
file, maintaining the nested structure shown here:
{
"Sienar": {
"Email": {
"Smtp": {
"Host": "your-smtp-host.dev",
"Port": 587,
"SecureSocketOptions": 3,
"Username": "your-smtp-username",
"Password": "your-smtp-password"
}
}
}
}
Replace these values with the appropriate values for your SMTP host. We recommend you supply sensitive information using other means such as environment variables or Azure secrets.
NOTE: The SecureSocketOptions
value is an int
between 0 and 4, and it represents a member of the MailKit.Security.SecureSocketOptions enum.
Standard configuration
If you want to configure your SMTP info directly on IServiceCollection
yourself, you must do so before adding the MailKitPlugin
to the Sienar app because if MailKitPlugin
doesn't detect an existing configuration, it will apply its own. You can access the IServicecollection
directly from Program.cs
by calling SienarWebAppBuilder.SetupDependencies(WebApplicationBuilder)
and accessing the Services
property:
// Program.cs
using MailKit.Security;
using Microsoft.Extensions.DependencyInjection;
using Sienar.Email;
using Sienar.Extensions;
using Sienar.Infrastructure;
await SienarWebAppBuilder
.Create(args)
.SetupDependencies(builder =>
{
// configure SmtpOptions with an IConfiguration...
builder.Services.Configure<SmtpOptions>(
builder.Configuration.GetSection("Your:Custom:Config"));
// ...or use an Action<SmtpOptions>
builder.Services.Configure<SmtpOptions>(o =>
{
o.Host = "your-smtp-host.dev";
o.Port = 587;
o.SecureSocketOptions = SecureSocketOptions.StartTls;
o.Username = "your-smtp-username";
o.Password = "your-smtp-password";
});
})
.AddPlugin<MailKitPlugin>()
.Build()
.RunAsync();
Replace these values with the appropriate values for your SMTP host. We recommend you supply sensitive information using other means such as Azure secrets. You can also feel free to supply your configuration via a custom plugin if your app's custom functionality is wrapped in a plugin.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- MailKit (>= 4.1.0)
- Sienar.Architecture.Web (>= 0.1.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 |
---|---|---|
0.1.0 | 117 | 12/2/2024 |
Initial release