Substantive.Polycloud.EmailSender 9.3.0-build20251223r2

Library for sending an email with an SMTP server or email service providers such as SendGrid, MailGun, AWS SES.

Installation

1. Add configuration to the appsettings.json

Add the below configuration for SMTP Server :

  • SmtpClientOptions is for config SMTP server provider like Outlook, Gmail, Yahoo
{
  "EmailSenderOptions": {
      "EmailServiceProvider": "Smtp",
      "LimitFileUploadSize": 1048576,
      "LimitBCC": 100,
      "DefaultSender": {
        "Name": "Test Sender Name",
        "EmailAddress": "testsendemail@gmail.com"
      },
      "SmtpClientOptions": {
        "Server": "smtp.gmail.com",
        "Port": 465,
        "User": "test@gmail.com",
        "Password": "apppassword",
        "UseSsl": true,
        "RequiresAuthentication": true,
        "PreferredEncoding": "",
        "UsePickupDirectory": false,
        "MailPickupDirectory": ""
      },
  }
}

Add the below configuration for MailGun service provider :

{
  "EmailSenderOptions": {
      "EmailServiceProvider": "MailGun",
      "LimitFileUploadSize": 1048576,
      "LimitBCC": 100,
      "DefaultSender": {
        "Name": "Test Sender Name",
        "EmailAddress": "testsendemail@gmail.com"
      },
      "MailGunOptions": {
        "DomainName": "sandboxcf5f41bbf2f84f15a386c60e253b5fe9.mailgun.org",
        "APIKey": "key-8d32c046d7f14ada8d5ba8253e3e30de",
        "Region": "USA"
      }
  }
}

Add the below configuration for SendGrid service provider :

{
  "EmailSenderOptions": {
      "EmailServiceProvider": "Smtp",
      "LimitFileUploadSize": 1048576,
      "LimitBCC": 100,
      "DefaultSender": {
        "Name": "Test Sender Name",
        "EmailAddress": "testsendemail@gmail.com"
      },
      "SendGridOptions": {
        "APIKey": "xxxxx",
        "SandBoxMode": false,
      }
  }
}

2. Load configuration and add dependencies to the program.cs

EmailSenderOptions emailSenderOptions = new();
builder.Configuration.GetSection(nameof(EmailSenderOptions)).Bind(emailSenderOptions);
builder.Services.AddEmailSender(options => options.SmtpClientOptions = emailSenderOptions.SmtpClientOptions);

Usage

  1. Inject IEmailSender into class.
private readonly IEmailSender emailSender;
public EmailSenderController(IEmailSender emailSender)
 {
     this.emailSender = emailSender;
 }
  1. Call method to send an email.
emailSender.SendEmailAsync(recieveEmailAddress, subject, body, HttpContext.RequestAborted);

FAQs and Troubleshoots

SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required

Make sure the username and password are correct.

  • If using Gmail SMTP you need to enable 2FA and generate another password for application-specific password (a different password from your main email). For more information, check out this link.

RazorLight.RazorLightException: 'Can't load metadata reference from the entry assembly.

Make sure PreserveCompilationContext is set to true in the entry .csproj file.

<PreserveCompilationContext>true</PreserveCompilationContext>

AWS SES Configuration

To create a credential to use SMTP AWS need to use an verify email address or email domain and an SMTP account.

  1. Create SMTP credential

    1. Go to Amazon SES and click SMTP settings menu.
    2. Click Create SMTP credentials button.
    3. Input IAM username.
    4. Click Show User SMTP Security Credentials to expand the username and password for using SMTP credential.
  2. Create verify email.

    1. Go to Amazon SES and click Configuration > Verified identities menu.
    2. Click Create Identity button.
    3. Choose Email address to verify this email sender email can using send email service.
    4. Go to email and open verify email.

Note: If in AWS SES Dashboard page display Your Amazon SES account is in the sandbox in Asia Pacific (Singapore).

It mean you can only send from verified domains and email addressed, and only send to verified domains and email addresses.

Showing the top 20 packages that depend on Substantive.Polycloud.EmailSender.

Packages Downloads
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
3
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
4
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
6
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
7
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
8
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
9
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
11
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
14
Substantive.Foundation.Backends
A metapackage contains all Substantive backend building blocks.
16
Substantive.Metapackage.Backends
A metapackage contains all Substantive backend building blocks.
3

Version Downloads Last updated
9.17.21-build20260204R1 0 02/04/2026
9.17.20-build20260203R1 2 02/03/2026
9.17.19-build20260130R1 3 01/30/2026
9.17.18-build20260129R1 1 01/29/2026
9.17.17-build20260129R1 5 01/29/2026
9.17.17-build20260128R1 3 01/28/2026
9.17.16-build20260127R2 4 01/27/2026
9.17.16-build20260123R1 3 01/23/2026
9.17.15-build20260122R1 5 01/22/2026
9.17.14-build20260122R2 6 01/22/2026
9.17.14-build20260122R1 2 01/22/2026
9.17.14-build20260121R1 2 01/21/2026
9.17.13-build20260121R1 4 01/21/2026
9.17.12-build20260120R1 4 01/20/2026
9.17.11-build20260120R1 3 01/20/2026
9.17.10-build20260120R1 2 01/20/2026
9.17.9-build20260119R1 3 01/19/2026
9.17.8-build20260119R1 2 01/19/2026
9.17.7-build20260115R1 1 01/15/2026
9.17.6-build20260115R1 1 01/15/2026
9.17.5-build20260119R1 2 01/19/2026
9.17.5-build20260115R1 1 01/15/2026
9.17.4-build20260115R1 4 01/15/2026
9.17.3-build20260115R1 1 01/15/2026
9.17.2-build20260115R1 1 01/15/2026
9.17.2-build20260113R1 4 01/13/2026
9.17.1-build20251231R2 1 12/31/2025
9.17.1-build20251230R2 7 12/30/2025
9.17.1-build20251230R1 1 12/30/2025
9.17.0-build20251229R2 4 12/29/2025
9.17.0-build20251229R1 1 12/29/2025
9.17.0-build20251226R1 5 12/26/2025
9.17.0-build20251225R1 2 12/25/2025
9.16.0-build20251224R1 4 12/24/2025
9.15.3-build20251224R1 1 12/24/2025
9.15.2-build20251224R1 1 12/24/2025
9.15.1-build20251224R1 1 12/24/2025
9.14.0-build20251223R1 3 12/23/2025
9.3.0-build20251223R4 1 12/23/2025
9.3.0-build20251223R3 3 12/23/2025
9.3.0-build20251223R2 1 12/23/2025
9.3.0-build20251222R2 3 12/22/2025
9.3.0-build20251222R1 2 12/22/2025
9.2.0-build20251222R2 2 12/22/2025
9.2.0-build20251222R1 4 12/22/2025
9.1.0-build20251218R1 2 12/18/2025
9.1.0-build20251217R2 3 12/17/2025
9.1.0-build20251217R1 6 12/17/2025
9.1.0-build20251216R2 5 12/16/2025
9.1.0-build20251216R1 3 12/16/2025
9.1.0-build20251215R1 5 12/15/2025
9.1.0-build20251212R1 7 12/12/2025
9.1.0-build20251211R1 1 12/11/2025
9.1.0-build20251210R1 4 12/10/2025
9.1.0-build20251202R2 8 12/02/2025
9.1.0-build20251202R1 6 12/02/2025
9.0.5-build20251117R1 1 11/17/2025
9.0.5-build20251110R1 36 11/10/2025
9.0.5-build20251103R1 5 11/03/2025
9.0.5-build20251030R1 5 10/30/2025
9.0.5-build20251028R1 3 10/28/2025
9.0.5-build20251016R1 1 10/16/2025
9.0.5-build20250925R2 5 09/25/2025
9.0.5-build20250925R1 1 09/25/2025
9.0.5-build20250924R1 1 09/24/2025
9.0.5-build20250908R1 26 09/08/2025
9.0.5-build20250905R2 4 09/05/2025
9.0.5-build20250905R1 3 09/05/2025
9.0.5-build20250827R1 1 08/27/2025
9.0.5-build20250825R1 23 08/25/2025
9.0.5-build20250821R1 2 08/21/2025
9.0.4-build20250821R1 2 08/21/2025
9.0.3-build20250821R1 2 08/21/2025
9.0.2-build20250821R1 2 08/21/2025
9.0.1-build20250821R1 2 08/21/2025
9.0.0 12 08/16/2025
9.0.0-build20250821R3 2 08/21/2025
9.0.0-build20250821R2 2 08/21/2025
9.0.0-build20250821R1 3 08/21/2025
9.0.0-build20250818R2 6 08/18/2025
9.0.0-build20250818R1 3 08/18/2025
9.0.0-build20250815R1 2 08/15/2025
9.0.0-build20250722R3 62 07/22/2025
9.0.0-build20250714R3 31 07/14/2025
9.0.0-build20250714R2 4 07/14/2025
9.0.0-build20250714R1 3 07/14/2025
9.0.0-build20250710R1 8 07/10/2025
9.0.0-build20250707R2 12 07/07/2025
9.0.0-build20250707R1 4 07/07/2025
9.0.0-build20250629R1 9 06/29/2025
9.0.0-build20250626R2 6 06/26/2025
9.0.0-build20250626R1 3 06/26/2025
9.0.0-build20250623R1 7 06/23/2025
9.0.0-build20250621R1 12 06/21/2025