Skip to content

Email Sending

PSS®X provides various services, settings and integrations for sending emails:

  • Provides IEmailSender service that is used to send emails.
  • Defines settings to configure email sending.
  • Integrates to the background job system to send emails via background jobs.

Installation

If you want to install emailing services;

  • Add the GridLab.Abp.Emailing NuGet package to your project:

    Install-Package GridLab.Abp.Emailing

  • Add the AbpGridLabEmailingModule to the dependency list of your module:

    [DependsOn(
        //...other dependencies
        typeof(AbpGridLabEmailingModule) // <-- Add module dependency like that
    )]
    public class YourModule : AbpModule
    {
    }
    
    * Locate the appsettings.json file in your project.

  • Add a new section for email settings.

    {
     "Logging": {
       "LogLevel": {
         "Default": "Information",
         "Microsoft": "Warning",
         "Microsoft.Hosting.Lifetime": "Information"
       }
     },
     "Email": {
       "FromAddress": "info@gridlab.io",
       "UserName": "info"
     },
     "AllowedHosts": "*"
    }
    

Email Options

Default values can be configured with EmailOptions type.

Configure<EmailOptions>(options =>
{
    options.FromAddress = configuration["Email:FromAddress"];
    options.UserName = configuration["Email:UserName"];
});

The EmailOptions class provides configuration options for the email service. It includes properties for setting the SMTP server details, authentication credentials, and email sender information. These options can be configured to customize the behavior of the email service.

  • Host: The SMTP host name or IP address. Default is "smtp.gmail.com".

  • Port: The SMTP port. Default is "587".

  • UserName: The user name to login to the SMTP server. Default is an empty string.

  • Password: The password to login to the SMTP server. Default is an empty string.

  • Domain: The domain name to login to the SMTP server. Default is an empty string.

  • EnableSsl: Indicates whether SSL is enabled. Default is "true".

  • UseDefaultCredentials: Indicates whether to use default credentials. Default is "false".

  • FromAddress: The email address used in the "From" field of the email. Default is an empty string.

  • FromDisplayName: The display name used in the "From" field of the email. Default is "GridLab PSS©X".