Myvas.AspNetCore.Email 8.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Myvas.AspNetCore.Email --version 8.0.2                
NuGet\Install-Package Myvas.AspNetCore.Email -Version 8.0.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="Myvas.AspNetCore.Email" Version="8.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Myvas.AspNetCore.Email --version 8.0.2                
#r "nuget: Myvas.AspNetCore.Email, 8.0.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.
// Install Myvas.AspNetCore.Email as a Cake Addin
#addin nuget:?package=Myvas.AspNetCore.Email&version=8.0.2

// Install Myvas.AspNetCore.Email as a Cake Tool
#tool nuget:?package=Myvas.AspNetCore.Email&version=8.0.2                

Myvas.AspNetCore.Email

NuGet GitHub (Pre-)Release Date GitHub Actions Status

An AspNetCore service to send Email via MailKit. (Windows and Linux works!)

Samples

EmailApi

  • EmailApi (WebApi, A consumer of this middleware): http://localhost:9002/swagger/index.html

    POST api/v1/Email

    {
        "recipients": "4848285@qq.com;noreply@test.com",
        "subject": "来自WebApi的测试邮件",  
        "body": "这是一封来自WebApi的测试邮件,您无须理会此邮件。"
    }
    
  • EmailApi Client (Console, HttpClient): dotnet run

  • EmailApi Client (JavascriptClient): http://localhost:9006

  • EmailApi Client (WebClient/Consumer WebApp): http://localhost:9008

WebApp

  • WebApp (Mvc, A consumer of this middleware): http://localhost:9009

    Settings: secrets.json or appsettings.xxx.json

      "Email:SmtpServerSsl": "true",
      "Email:SmtpServerPort": "465",
      "Email:SmtpServerAddress": "smtp.myvas.com",
      "Email:SenderPassword": "<your password>",
      "Email:SenderDisplayName": "DO-NOT-REPLY",
      "Email:SenderAccount": "noreply@myvas.com",
    

ConfigureServices:

1.AddEmail: IEmailSender, EmailSender

services.AddEmail(options =>
{
    options.SmtpServerAddress = Configuration["Email:SmtpServerAddress"];
    options.SenderAccount = Configuration["Email:SenderAccount"];
    options.SenderPassword = Configuration["Email:SenderPassword"];
    options.SenderDisplayName = Configuration["Email:SenderDisplayName"];
});

2.AddEmailTemplate: IEmailTemplate

services.AddEmailTemplate(options =>
{
    options.EmailTemplateRootPath = Path.Combine(_env.WebRootPath, "EmailTemplates");
});

Use Case 1: Use Myvas.AspNetCore.Email.IEmailSender (without 'Microsoft.AspNetCore.Identity.UI')

using Myvas.AspNetCore.Email;

public class EmailController : Controller
{
    private readonly IEmailSender _emailSender;

    public EmailController(
        IEmailSender emailSender)
    {
        _emailSender = emailSender ?? throw new ArgumentNullException(nameof(emailSender));
    }

Use Case 2: Implementation of Microsoft.AspNetCore.Identity.UI.Services.IEmailSender:

Use Case 2 (Step 1): EmailService

using Myvas.AspNetCore.Email;

public class EmailService : Microsoft.AspNetCore.Identity.UI.Services.IEmailSender
{
    private readonly EmailSender _emailSender;

    public EmailService(EmailSender emailSender)
    {
        _emailSender = emailSender;
    }

    public Task SendEmailAsync(string email, string subject, string htmlMessage)
    {
        return _emailSender.SendEmailAsync(email, subject, htmlMessage);
    }
}

Use Case 2 (Step 2): ConfigureServices

services.AddTransient<Microsoft.AspNetCore.Identity.UI.Services.IEmailSender, EmailService>();

Next...

  • Email templates
  • Razor Class Library for Configuration and Management
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
8.0.5 36 1/30/2025
8.0.2 28 1/28/2025
2.2.604 3,524 10/26/2019
2.1.603 602 4/13/2019
2.1.602 577 4/12/2019
2.1.600 699 12/13/2018