SendWithMailgun 1.2.2

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

alt tag

SendWithMailgun

NuGet Version NuGet

SendWithMailgun is a really small class library with only one goal in mind: sending an email with Mailgun. That's it. Need other features? Not here, sorry 😦

New in v1.1.x

  • Dependency updates
  • Remove Newtonsoft.Json
  • Add support for email validation
  • v1.1.8: validation results of do_not_send and catch_all now deserialize correctly; unrecognized result or risk values map to Unknown instead of throwing

New in v1.2.x

  • Built-in metrics and traces for every send and validation, emitted through the .NET Meter and ActivitySource APIs (no exporter dependency). See TELEMETRY.md
  • v1.2.1: dependency updates (RestWrapper 3.3.1)

Help or feedback

First things first - do you need help or have feedback? File an issue! Happy to help.

Simple Email Example

using SendWithMailgun;

MailgunSender sender = new MailgunSender("[mydomain.com]", "[apikey]");
sender.Logger = Console.WriteLine; // if you want log messages

string id = null;
id = sender.Send("to", "from", "subject", "body");       // text
id = sender.Send("to", "from", "subject", "html", true); // html
Console.WriteLine("Message ID: " + id);

Simple Validation Example

using SendWithMailgun;

MailgunValidator validator = new MailgunValidator("[apikey]");
MailgunValidationResult result = validator.Validate("[emailaddress]");
Console.WriteLine("Result: " + result.Result.ToString() + " risk level: " + result.Risk.ToString());

Validate and ValidateAsync return null when Mailgun responds with a non-200 status code or an empty body. Result and Risk map Mailgun's wire values (deliverable, undeliverable, do_not_send, catch_all, unknown and high, medium, low, unknown) to ResultEnum and RiskEnum. Any value not recognized by this version of the library is mapped to Unknown.

Regional Endpoints

Both classes accept a base URL, for example to use Mailgun's EU region:

MailgunSender sender = new MailgunSender("[mydomain.com]", "[apikey]", "https://api.eu.mailgun.net/v3/");
MailgunValidator validator = new MailgunValidator("[apikey]", "https://api.eu.mailgun.net/v4/");

Telemetry

SendWithMailgun emits OpenTelemetry-shaped metrics and traces through a Meter and an ActivitySource, both named SendWithMailgun. It never opens a connection to a backend; your host subscribes and exports. If nothing subscribes, the cost is negligible.

// Radiant
RadiantSettings settings = new RadiantSettings("my-service");
settings.Sources.AddMeter(MailgunTelemetry.MeterName);
settings.Sources.AddActivitySource(MailgunTelemetry.ActivitySourceName);

// or the OpenTelemetry SDK
builder.Services.AddOpenTelemetry()
    .WithMetrics(m => m.AddMeter(MailgunTelemetry.MeterName))
    .WithTracing(t => t.AddSource(MailgunTelemetry.ActivitySourceName));

Every call produces a mailgun send or mailgun validate client span (with stage:request and stage:deserialize children) and records sendwithmailgun.client.operations / sendwithmailgun.client.operation.duration labeled with the outcome (success, http_error, empty_response, malformed_response, no_response, timeout, cancelled, error). No addresses, subjects, bodies, or API keys are recorded. See TELEMETRY.md for the full metric and span catalog, PromQL alerts, and dashboard suggestions.

Running the Tests

Tests are written once in src/Test.Shared using Touchstone and run through three runners. They use an in-process mock Mailgun server bound to 127.0.0.1, so no Mailgun account or API key is required.

dotnet run --project src/Test.Automated -f net10.0                      # console runner
dotnet run --project src/Test.Automated -f net10.0 -- --results out.json # console runner with JSON results
dotnet test src/Test.Xunit                                              # xUnit
dotnet test src/Test.Nunit                                              # NUnit

src/Test is an interactive console application for sending and validating against the real Mailgun API with your own domain and keys.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.2.2 373 11/18/2026
1.2.1 592 10/3/2026
1.2.0 183 10/3/2026
1.1.8 128 10/3/2026
1.1.7 625 7/9/2026
1.1.6 1,370 10/30/2024
1.1.5 815 10/3/2023
1.1.2 519 9/10/2023
1.1.1 2,229 7/23/2023
1.1.0 419 7/22/2023
1.0.0.5 6,974 11/12/2021
1.0.0.4 3,002 9/16/2021
1.0.0.3 1,474 8/14/2021
1.0.0.2 822 7/28/2021
1.0.0.1 1,632 5/23/2021
1.0.0 648 5/23/2021

Dependency update: RestWrapper 3.3.1.