JmpCoreMailer 1.1.8

dotnet add package JmpCoreMailer --version 1.1.8                
NuGet\Install-Package JmpCoreMailer -Version 1.1.8                
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="JmpCoreMailer" Version="1.1.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JmpCoreMailer --version 1.1.8                
#r "nuget: JmpCoreMailer, 1.1.8"                
#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 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 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. 
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
1.1.8 2,341 12/23/2019
1.1.7 445 12/23/2019
1.1.6 445 12/23/2019
1.1.5 447 12/23/2019
1.1.4 438 12/23/2019