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
                    
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="Sienar.Plugin.MailKit" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sienar.Plugin.MailKit" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Sienar.Plugin.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 Sienar.Plugin.MailKit --version 0.1.0
                    
#r "nuget: Sienar.Plugin.MailKit, 0.1.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 Sienar.Plugin.MailKit@0.1.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=Sienar.Plugin.MailKit&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Sienar.Plugin.MailKit&version=0.1.0
                    
Install as a Cake Tool

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 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. 
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
0.1.0 117 12/2/2024

Initial release