JmpCoreMailer 1.1.8
dotnet add package JmpCoreMailer --version 1.1.8
NuGet\Install-Package JmpCoreMailer -Version 1.1.8
<PackageReference Include="JmpCoreMailer" Version="1.1.8" />
paket add JmpCoreMailer --version 1.1.8
#r "nuget: JmpCoreMailer, 1.1.8"
// Install JmpCoreMailer as a Cake Addin #addin nuget:?package=JmpCoreMailer&version=1.1.8 // Install JmpCoreMailer as a Cake Tool #tool nuget:?package=JmpCoreMailer&version=1.1.8
JmpCoreMailer
Send email from .NET Core 2.0 with razor template Check the example code for details 😃 happy coding
How to Use:
To Install
npm install JmpCoreMailer
In Startup.cs add
services.AddScoped<ITemplateRenderer, TemplateRenderer>();
services.AddScoped<ICoreMvcMailer, CoreMvcMailer>();
Create cshtml template under any views folder e.g.
Views/Emails/Registration.cshtml
The content of cshtml can be
@model UserInfo
Hello <strong>@Model.UserName</strong> you are <strong>Awxam</strong>
NOTE: For emails you have to use inline styling.
in the controller use following:
Constructor
private readonly ICoreMvcMailer _mailer;
public HomeController(ICoreMvcMailer mailer)
{
_mailer = mailer;
}
ActionMethod
public IActionResult About()
{
MailerModel mdl = new MailerModel("YourHostName",1234)
{
FromAddress = "Your Address",
IsHtml = true,
User = "YourUserName",
Key ="YourKey",
ViewFile = "Emails/Register",
Subject = "Registration",
Model = new // Your actual class model
{
}
};
}
// Enable SSL mail sending
_mailer.EnableSsl();
_mailer.Send(mdl);
return View();
   Â
UPDATE 2019-12-23
Added support to use local folder instead of using paid or free mail servers.
Added supporte to use SSL to send mails.
Method Mailer.SendAsync renamed - missing "c" at end of it.
HOW TO USE ?
It is really simple to use. Just create MVCMailer model with pickup directory location. When you send the email make sure you set sender and reciver email. Once done, you can see email in your provided pickup directory.
MailerModel mdl = new MailerModel(**"Your Directory Here"**)
{
FromAddress = "Your Address",
IsHtml = true,
User = "YourUserName",
Key ="YourKey",
ViewFile = "Emails/Register",
Subject = "Registration",
Model = new // Your actual class model
{
}
};
mdl.ToAddresses.Add("test@test.com");
_mailer.EnableSsl();
_mailer.Send(mdl);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. 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. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.0
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.0.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.0.0)
- Microsoft.AspNetCore.Mvc.Razor (>= 2.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.