Skip to content

jldearmas/NETCore.MailKit

 
 

Repository files navigation

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("xxxx@gmail.com", "ASP.NET Core mvc send email example", "Send from asp.net core mvc action");

        return View();
    }
}

LICENSE

MIT

About

Fork of .NETCoreMailKit to fix bugs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 78.4%
  • HTML 20.3%
  • CSS 1.2%
  • JavaScript 0.1%