Myvas.AspNetCore.Email
8.0.2
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
<PackageReference Include="Myvas.AspNetCore.Email" Version="8.0.2" />
paket add Myvas.AspNetCore.Email --version 8.0.2
#r "nuget: Myvas.AspNetCore.Email, 8.0.2"
// 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
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 | Versions 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. |
-
.NETStandard 2.0
- MailKit (>= 4.10.0)
- Microsoft.Extensions.FileProviders.Physical (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
-
.NETStandard 2.1
- MailKit (>= 4.10.0)
- Microsoft.Extensions.FileProviders.Physical (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
-
net6.0
- MailKit (>= 4.10.0)
- Microsoft.Extensions.FileProviders.Physical (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
-
net7.0
- MailKit (>= 4.10.0)
- Microsoft.Extensions.FileProviders.Physical (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
-
net8.0
- MailKit (>= 4.10.0)
- Microsoft.Extensions.FileProviders.Physical (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.