Email Sender module

Description

Email sender is an implementation of SMTP sender, it has a base IEmailSender interface that implement Microsoft.AspNetCore.Identity.UI.Services.IEmailSender It also extend ISender that allow to send messages without inject IEmailSender

Installation

For us this module, it must be registered in your Startup class

//----------------------------------------Email Module-------------------------------------
			config.GearServices.AddEmailModule<EmailSender>()
				.AddEmailRazorUIModule()
				.BindEmailSettings(Configuration);

In app settings is need to add the following settings:

  "EmailSettings": {
    "Enabled": true,
    "Host": "smtp.gmail.com",
    "Port": 587,
    "Timeout": 5000,
    "EnableSsl": true,
    "NetworkCredential": {
      "Email": "",
      "Password": ""
    }
  },

If register the Razor module, these settings can be edited from UI page , see in admin configurations of GEAR

Usage

This module ca be used in 2 ways:

  1. Inject ISender Example:
using GR.Core.Services;
...
private readonly AppSender _sender;
...
var result = await _sender.SendAsync("email", $"Invite to {GearApplication.ApplicationName}", message, model.Email);
  1. Inject IEmailSender Example:
using GR.Email.Abstractions;
...
private readonly IEmailSender _emailSender;

await _emailSender.SendEmailAsync("user@mail.com", "Subject", "text");