Goffo.Email.Core 1.0.0

dotnet add package Goffo.Email.Core --version 1.0.0
                    
NuGet\Install-Package Goffo.Email.Core -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Goffo.Email.Core" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Goffo.Email.Core" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Goffo.Email.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Goffo.Email.Core --version 1.0.0
                    
#r "nuget: Goffo.Email.Core, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Goffo.Email.Core@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Goffo.Email.Core&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Goffo.Email.Core&version=1.0.0
                    
Install as a Cake Tool

Goffo.Email.Core

Core project for sending emails

Setup

  1. Using appsettings.json
{
  "EmailConfiguration": {
    "HostName": "your-host",
    "PortNumber": 25,
    "UseSSL": false,
    "DefaultFromAddress": "DoNotReply@mysite.com",
    "DefaultFromName": "DO NOT REPLY"
  }
}


public void SetupWithAppSettings()
{
    IServiceCollection services = new ServiceCollection();

    // Uses the default key name for appsettings.json - 'EmailConfiguration'
    services.RegisterGoffoEmail()
            .AddGoffoEmailSender<CustomEmailSender>();

    //// Provide your own name for the key name for appsettings.json
    //services.RegisterGoffoEmail(emailConfigurationKey: "MyEmailConfiguration")
    //        .AddGoffoEmailSender<CustomEmailSender>();
}

public class CustomEmailSender : AbstractSender, IEmailSender
{
    public CustomEmailSender(IOptionsFactory<EmailConfiguration> emailConfiguration, string emailConfigurationKey = "EmailConfiguration") : base(emailConfiguration, emailConfigurationKey)
    {
    }

    public EmailResponse SendEmail(EmailRequest request, CancellationToken cancellationToken = default)
    {
        // Your code to send out an email

        return new EmailResponse(IsSent: true, Message: "Email Sent");
    }

    public async Task<EmailResponse> SendEmailAsync(EmailRequest request, CancellationToken cancellationToken = default)
    {
        // Your code to send out an email async
        await Task.CompletedTask;
        return new EmailResponse(IsSent: true, Message: "Email Sent");
    }
}

  1. Set settings in code

public void SetupInCode()
{
    IServiceCollection services = new ServiceCollection();

    // Uses the default key name for appsettings.json - 'EmailConfiguration'
    services.RegisterGoffoEmail(config =>
    {
        config.HostName = "your-host";
        config.PortNumber = 25;
        config.DefaultFromAddress = "DoNotReplay@mysite.com";
        config.DefaultFromName = "DoNotReply";

    }).AddGoffoEmailSender<CustomEmailSender>();

    //// Provide your own name for the key name for appsettings.json
    services.RegisterGoffoEmail(config =>
    {
        config.HostName = "your-host";
        config.PortNumber = 25;
        config.DefaultFromAddress = "DoNotReplay@mysite.com";
        config.DefaultFromName = "DoNotReply";

    }, "MyEmailConfiguration").AddGoffoEmailSender<CustomEmailSender>();
}

  1. How to use

public async Task SendTestEmailAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken)
{
    ILogger logger = serviceProvider.GetService<ILogger>();

    try
    {
        Goffo.Email.Core.IEmailSender sender = serviceProvider.GetRequiredService<Goffo.Email.Core.IEmailSender>();

        string contentId = Guid.NewGuid().ToString();

        var request = new Goffo.Email.Core.EmailRequest()
        {
            Subject = "EMAIL TEST",
            TORecipients = new List<EmailAddress>()
                .AddEmailAddress("cgoffine@hach.com"),
            Body = $@"
            <html>
                <body>
                    <h1>THIS IS A TEST EMAIL!</h1>
                    <p>This is an inline image:</p>
                    <img src=""cid:{contentId}"" alt=""Logo"" />
                </body>
            </html>",
            IsHtmlBody = true,
            Attachments = new List<EmailAttachment>()
                .AddEmailAttachment(@"C:\MyFilePath\MyInlineImage.jpg", contentId)
                .AddEmailStreamAttachment(new FileStream(@"C:\MyFilePath\TEST_FOR_FILE_STREAM.txt", FileMode.Open), "FileStreamTest.txt")
                .AddEmailBinaryAttachment(File.ReadAllBytes(@"C:\MyFilePath\OneDrive - Veralto\Documents\TEST_FOR_BINARY.txt"), "BinaryTest.txt"),
            Priority = EmailPriority.High
        };

        Goffo.Email.Core.EmailResponse response = await sender.SendEmailAsync(request, cancellationToken);

        if (response.IsSent)
        {
            logger.LogInformation("Successfully sent email: {EmailResponse}", response.Message);
        }
        else
        {
            throw new Exception($"The emailed failed when trying send: {response.Message}");
        }
    }
    catch (Exception ex)
    {
        logger.LogError(ex, ex.Message);
    }
}

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Goffo.Email.Core:

Package Downloads
Goffo.Email.MailKit

Uses MailKit in Goffo.Email.Core.IEmailSender implementation

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 26 2/4/2026

Initial release