Bsixmail.netcore 1.0.1

dotnet add package Bsixmail.netcore --version 1.0.1
NuGet\Install-Package Bsixmail.netcore -Version 1.0.1
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="Bsixmail.netcore" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bsixmail.netcore --version 1.0.1
#r "nuget: Bsixmail.netcore, 1.0.1"
#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 Bsixmail.netcore as a Cake Addin
#addin nuget:?package=Bsixmail.netcore&version=1.0.1

// Install Bsixmail.netcore as a Cake Tool
#tool nuget:?package=Bsixmail.netcore&version=1.0.1

Mailer template and helper for asp.netcore 2.0 above

First step you need to add and edit this in your appsettings.json

  "BsixMail": {
    "UserName": "yourmail@domain.com",
    "Password": "yourpassword",
    "Server": "smtp.yourservermail.com",
    "Port": "587",
    "UrlBase": "https://www.yourdomain.com" // your website domain (optional you can leave it empty)
  }

Lets call the bsixmail inside your contoller or method

var mailer = new BsixMailer();

Now you can use it, see the examples below :

This is for send on the fly. Variable _Base just optional if you want to configure approval, you need to configure your domain, so public can access your public url not your localhost

var _Base = _config.GetSection("BsixMail").GetSection("UrlBase").Value;           
mailer.BuildBody(new
{
  Message = "hello from bsix aproval",
  UrlApprove = string.Format("{0}/{1}/{2}", _Base, "Approve", "yes"),
  UrlReject = string.Format("{0}/{1}/{2}", _Base, "Approve", "no") 
}, "default.txt") // Your template mail located inside BsixMail folder
.EmailTo("mailto@example.com")
.EmailSubject("This is subject")
.Send();

Sending mail in background task

mailer.BuildBody(new
{
  Message = "hello from bsix" // You can bind this with your model, its just example
}, "default.txt")  // Your template mail located inside BsixMail folder
.EmailTo("mailto@example.com")
.EmailSubject("This is subject")
.SendBackground();

You can add or edit default.txt with your own template, and bind it to your model, example

public class Mymodel 
{
  public string Name {get; set;}
}

Then your defaul.txt or mytemplate.html which is you just created with your own inside BsixMail Folder example template

Hi {{Name}} i`m from Bsixmail

And see how to use it

var myModel =  new Mymodel() { Name = "Ihsan" };

mailer.BuildBody(myModel, "mytemplate.txt")  // Your template mail located inside BsixMail folder
.EmailTo("mailto@example.com")
.EmailSubject("This is subject")
.SendBackground();

You also can trace if email not sent in BsixMail folder

If you want to take a look the source https://github.com/ihsanbsix/Bsix-MailSender

Thats it

Need help? just go to github repo and create issue

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.0.1 511 12/10/2019
1.0.0 412 12/10/2019

Update document