TPJ.Email 3.0.0

TPJ E-mail library - Easily send e-mails, light weight, easy to setup!

Install-Package TPJ.Email -Version 3.0.0
dotnet add package TPJ.Email --version 3.0.0
<PackageReference Include="TPJ.Email" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TPJ.Email --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Release Notes

V3.0.0+ only supports .netstandard2.0, which works in .net4.6.1 + / .netcore2.0 +. If you are using .net4.5.2 / .net 4.6 you can use TPJ.Email V2.X.X.

ASP.Net Core Website / WebAPI Set up

Within  appsettings.json and add the following

{
 "TPJ": {
   "Email":{
     "From": "",
     "SmtpClient": "",
     "SmtpUser": "",
     "SmtpPassword": "",
     "Port": "",
     "EnableSSL": ""
   }
 }
}

From - (Required) E-mails are sent from this account

SmtpClient – (Required) SMTP server which e-mails will be sent from

SmtpUser - (Not required) send e-mail using the given user name and password

SmtpPassword - (Not required) send e-mail using the given user name and password

Port - (Not required) port to send from

EnableSSL - (Not required) enable SSL when sending the e-mail

Example appsettings.json setup using Gmail to send error e-mails –
{
 "TPJ": {
   "Email":{
     "From": "test@gmail.com",
     "SmtpClient": "smtp.gmail.com",
     "SmtpUser": "test@gmail.com",
     "SmtpPassword": "testPassword",
     "Port": "587",
     "EnableSSL": "true"
   }
 }
}

Once appsettings.json is done open StartUp.cs file, add the following using -

using TPJ.Email;

then go to ConfigureServices

services.AddTPJEmail();

Then using DI within asp.net core you can call IEmailer like so

private readonly TPJ.Email.IEmailer _email;

public HomeController(TPJ.Email.IEmailer email)
{
 _email= email;
}

Then within an IActionResult you might have this

public IActionResult SendSuperEpicEmail()
{
 _email.Send("epicPerson@gmail.com", "Super Epic Email", "This is a super epic email message", false);
 return View();
 
}

This will then send an e-mail to epicPerson@gmail.com using the SMTP details you set up sending as the person you set in the config

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.0.0 473 8/20/2017
2.5.0 453 5/4/2017
2.3.0 630 10/6/2016
2.2.1 530 8/30/2016
1.0.0 814 4/19/2016