Devity.NETCore.MailKit 2.2.2

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

NETCore.MailKit

NuGet MailKit license GitHub-Actions-Img

MailKit extension to use with ASP.NET Core projects.

Original and why fork

The original version of this library has been created by myloveCc and can be accessed here.

I have been a user of this library for a few years. However, over the time as the library was not maintained, I managed to come across some bugs and I had to re-release the fixes myself for use on my own projects. Furthermore, the last push happened to be a vulnerability in the underyling MailKit library, so I decided to fork the project and continue maintaining it as it's still being used by thousands of projects.

Install with NuGet

Install-Package Devity.NETCore.MailKit

Install with .NET CLI

dotnet add package Devity.NETCore.MailKit

Usage

Add MailKit at start-up

builder.Services.AddMailKit(optionBuilder =>
{
    optionBuilder.UseMailKit(new MailKitOptions()
    {
        // get options from sercets.json
        Server = Configuration["Server"],
        Port = Convert.ToInt32(Configuration["Port"]),
        SenderName = Configuration["SenderName"],
        SenderEmail = Configuration["SenderEmail"],

        // can be optional with no authentication
        Account = Configuration["Account"],
        Password = Configuration["Password"],

        // enable ssl or tls
        Security = true
    });
});

Or

Program.cs

var mailKitOptions = builder.Configuration.GetSection("Email").Get<MailKitOptions>();
builder.Services.AddMailKit(config => config.UseMailKit(mailKitOptions));

secrets.json/appsettings.json:

{
  "Email": {
    "Server": "localhost",
    "Port": 25,
    "SenderName": "Test Name",
    "SenderEmail": "test@test.com"
    "Account": "username",
    "Password": "password",
    "Security": true
  }
}

Use EmailService like

public class HomeController : Controller
{
    private readonly IEmailService _emailService;

    public HomeController(IEmailService emailService)
    {
        _emailService = emailService;
    }

    public IActionResult Email()
    {
        ViewData["Message"] = "ASP.NET Core mvc send email example";

        _emailService.Send("xxxx@gmail.com", "ASP.NET Core mvc send email example", "Send from asp.net core mvc action");

        return View();
    }
}

LICENSE

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Devity.NETCore.MailKit:

Package Downloads
Devity.Mailing

A package with Mailing solution using MailKit.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.2 541 4/3/2025