• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

.NET Core EmailKit extensions

NETCore.MailKit

NuGet NETCore CLR MailKit license GitHub-Actions-Img

MailKit extension for asp.net core

Install with nuget

Install-Package NETCore.MailKit -Version 2.1.0

Install with .NET CLI

dotnet add package NETCore.MailKit --version 2.1.0

How to use

Add MailKit in startup like

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddMvc();

    //Add MailKit
    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
        });
    });
}

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("[email protected]", "ASP.NET Core mvc send email example", "Send from asp.net core mvc action");

        return View();
    }
}

LICENSE

MIT