SendWithMailgun 1.2.1
See the version list below for details.
dotnet add package SendWithMailgun --version 1.2.1
NuGet\Install-Package SendWithMailgun -Version 1.2.1
<PackageReference Include="SendWithMailgun" Version="1.2.1" />
<PackageVersion Include="SendWithMailgun" Version="1.2.1" />
<PackageReference Include="SendWithMailgun" />
paket add SendWithMailgun --version 1.2.1
#r "nuget: SendWithMailgun, 1.2.1"
#:package SendWithMailgun@1.2.1
#addin nuget:?package=SendWithMailgun&version=1.2.1
#tool nuget:?package=SendWithMailgun&version=1.2.1
SendWithMailgun
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_sendandcatch_allnow deserialize correctly; unrecognizedresultorriskvalues map toUnknowninstead of throwing
New in v1.2.x
- Built-in metrics and traces for every send and validation, emitted through the .NET
MeterandActivitySourceAPIs (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 | Versions 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. |
-
.NETFramework 4.6.2
- RestWrapper (>= 3.3.1)
- System.Diagnostics.DiagnosticSource (>= 10.0.12)
-
.NETFramework 4.8
- RestWrapper (>= 3.3.1)
- System.Diagnostics.DiagnosticSource (>= 10.0.12)
-
.NETStandard 2.1
- RestWrapper (>= 3.3.1)
- System.Diagnostics.DiagnosticSource (>= 10.0.12)
-
net10.0
- RestWrapper (>= 3.3.1)
-
net8.0
- RestWrapper (>= 3.3.1)
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.