Skip to content

A collection of utility functions making email delivery more accessible for projects. By default supporting Dependency Injection.

License

Notifications You must be signed in to change notification settings

IowaComputerGurus/netcore.utilities.email.smtp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ICG.NetCore.Utilities.Email.Smtp

Build Status

This library provides an easy to use implementation of SMTP based email delivery using the MailKit library internally. This abstraction with proper interfaces allows email implementation inside of your project with little effort and easy to manage integration.

This package depends on the ICG.NetCore.Utilities.Email project for template implementation, as well as the IEmailService interface for Dependency Injection

SonarCloud Analysis

Quality Gate Status Coverage Security Rating Technical Debt

NuGet

Dependencies

The following additional NuGet packages are installed with this extension.

Breaking Changes with 4.x

In an effort to standardize our Email libraries a common IEmailService interface was introduced, at this time the existing ISmtpService was removed.

Usage

Installation

Standard installation via HuGet Package Manager

Install-Package ICG.NetCore.Utilities.Email.Smtp

Setup & Configuration Options

To setup the needed dependency injection items for this library, add the following line in your DI setup.

services.UseIcgNetCoreUtilitiesEmailSmtp(configuration);

Additionally you must specify the needed configuration elements within your AppSettings.json file

  "SmtpServiceOptions": {
    "AdminEmail": "test@test.com",
    "AdminName" : "John Smith",
    "Server": "test.smtp.com",
    "Port": 527,
    "UseSsl": true,
    "SenderUsername": "MySender",
    "SenderPassword": "Password",
    "AlwaysTemplateEmails": true,
    "AddEnvironmentSuffix": true
  },
  "EmailTemplateSettings": {
    "DefaultTemplatePath": "Template.html",
    "AdditionalTemplates": { "SpecialTemplate": "File.html" }
  }
Setting Description
AdminEmail This is the email address used as the "from" address and also for any usage of the "SendToAdministrator" option
AdminName This is the optional name for the sender for all outbound messages
Server The SMTP Server address to use
Port The Port to use for outbound emails
UseSsl Should SSL be used for emails
SenderUsername The username that should be used to connect to SMTP
SenderPassword The password that should be used to connect to SMTP
AlwaysTemplateEmails If selected ALL emails sent will be templated, by default using the "DefaultTemplate" as configured
AddEnvironmentSuffix If selected, all outbound emails sent from non-production addresses will have the environment name added to the end of the subject
DefaultTemplatePath The path, relative to the application root, where the default HTML template can be found for emails
AdditionalTemplates These are name/value pairs of additional templates and totally optional

Usage

Usage is primarly completed by injecting the IEmailService interface to your respective project, one injected emails can be sent with a single line of code.

_service.SendEmail("recipient@me.com", "My Subject", "<p>Hello!</p>");

Inline documentation exists for all API methods. We will continue to add more to this documentation in the future (PR's Welcome)

Related Projects

ICG has a number of other related projects as well

About

A collection of utility functions making email delivery more accessible for projects. By default supporting Dependency Injection.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages