Curiosus.EMail.Mailgun 3.0.0

dotnet add package Curiosus.EMail.Mailgun --version 3.0.0
                    
NuGet\Install-Package Curiosus.EMail.Mailgun -Version 3.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="Curiosus.EMail.Mailgun" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Curiosus.EMail.Mailgun" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Curiosus.EMail.Mailgun" />
                    
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 Curiosus.EMail.Mailgun --version 3.0.0
                    
#r "nuget: Curiosus.EMail.Mailgun, 3.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 Curiosus.EMail.Mailgun@3.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=Curiosus.EMail.Mailgun&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Curiosus.EMail.Mailgun&version=3.0.0
                    
Install as a Cake Tool

Curiosus.EMail.Mailgun

NuGet Downloads Coverage

Mailgun implementation of IEMailSender from Curiosus.EMail. Sends messages through the Mailgun HTTP API (US or EU region).

Known issue: in the current version MailgunEmailOptions.AssertValid() throws NotImplementedException, so registering or constructing the sender fails. Use another IEMailSender provider until it is fixed.

Installation

dotnet add package Curiosus.EMail.Mailgun

Usage

Options (MailgunEmailOptions, validated on registration):

Mailgun:
  MailgunRegion: US                # US (default) or EU
  MailgunUser: api                 # required, basic auth user
  MailgunApiKey: <secret>          # required
  MailgunDomain: mg.example.com    # required
  EmailFrom: noreply@mg.example.com # required
  ReplyTo: support@example.com     # optional
  IgnoreIncorrectExtraParamsType: false
using Curiosus.EMail;
using Curiosus.EMail.Mailgun;

var mailgunOptions = builder.Configuration.GetSection("Mailgun").Get<MailgunEmailOptions>()!;
builder.Services.AddMailgunEmailSender(mailgunOptions); // IMailgunEmailSender and, by default, IEMailSender

// in a service that receives IEMailSender sender
var response = await sender.SendAsync("user@example.com", "Welcome", "<p>Hello!</p>", isBodyHtml: true, ct);

// use another domain/key for one message
await sender.SendAsync("user@example.com", "Report", "See attachment", false,
    new MailgunEmailExtraParams(mailgunDomain: "reports.example.com", emailFrom: "reports@reports.example.com"), ct);

HTTP 420 from Mailgun is returned as EmailError.RateLimit; other unsuccessful responses as EmailError.Auth. Pass useAsDefaultSender: false to register only IMailgunEmailSender.

HTTP requests go through the HttpClient named MailgunEmailSender.HttpClientName from IHttpClientFactory, which AddMailgunEmailSender registers. Configure it for timeouts, a proxy or resilience handlers:

services.AddHttpClient(MailgunEmailSender.HttpClientName, client => client.Timeout = TimeSpan.FromSeconds(30));

See also

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 75 10/3/2026
2.0.0 89 9/28/2026