DdotM.EmailClient.Mailgun
2.0.0
dotnet add package DdotM.EmailClient.Mailgun --version 2.0.0
NuGet\Install-Package DdotM.EmailClient.Mailgun -Version 2.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="DdotM.EmailClient.Mailgun" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DdotM.EmailClient.Mailgun" Version="2.0.0" />
<PackageReference Include="DdotM.EmailClient.Mailgun" />
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 DdotM.EmailClient.Mailgun --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DdotM.EmailClient.Mailgun, 2.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 DdotM.EmailClient.Mailgun@2.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=DdotM.EmailClient.Mailgun&version=2.0.0
#tool nuget:?package=DdotM.EmailClient.Mailgun&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DdotM.EmailClient.Mailgun
A simple .NET 8.0 client for sending email via Mailgun�s HTTP API.
Table of Contents
Features
- .NET 8.0 / C# latest
- No dependencies: .NET only, no external library dependencies
- Built-in config validation (
MailgunClientConfig
) - Supports:
To
,Cc
,Bcc
,From
,Subject
,Text
&HTML
bodies, tags, tracking, scheduled delivery
Prerequisites
- Mailgun account & API key
- Verified sending domain in Mailgun (Mailgun provides DNS record instructions when you set up a Sending Domain)
Installation
dotnet add package DdotM.EmailClient.Mailgun
Or via Package Manager:
Install-Package DdotM.EmailClient.Mailgun
Getting Started
Obtain Mailgun Credentials
- Sign in to Mailgun and go to the Sending section in your dashboard.
- Add or verify your sending domain (e.g.
mg.yourdomain.com
). - Navigate to the API Keys or Security tab and create a new API key.
- Save your API key in a secure location (environment variable, secrets store, etc.)�you�ll need it in your application.
Configure Your DNS
After adding your sending domain in the Mailgun dashboard, Mailgun will display a set of DNS records (SPF, DKIM, DMARC, tracking CNAME, etc.).
- Log in to your DNS provider (where you registered your domain).
- Create or update the records exactly as Mailgun specifies for your sending domain (e.g.
mg.yourdomain.com
). - Save your changes and wait for propagation (usually < 60 minutes).
- Verify using a DNS lookup tool (
dig
,nslookup
, or MXToolbox) that each record resolves correctly.
Basic Usage
using DdotM.EmailClient.Mailgun;
// 1. Configure
var config = new MailgunClientConfig
{
ApiKey = "YOUR_MAILGUN_API_KEY",
SendingDomain = "mg.yourdomain.com"
};
// 2. Create client
var mailer = new MailgunClient(config);
// 3. Build message
var msg = new MailgunMessage
{
From = new Recipient { Name = "Alice", Address = "alice@yourdomain.com" },
Subject = "Hello from Mailgun!",
TextBody = "This is a plain-text body.",
HtmlBody = "<p>This is an HTML body.</p>",
Tracking = true,
DeliveryTime = DateTime.UtcNow.AddMinutes(10)
};
// 4. Add recipients & tags
msg.ToEmails.Add(new Recipient { Name = "Bob", Address = "bob@example.com" });
msg.CcEmails.Add(new Recipient { Name = "Eve", Address = "eve@example.org" });
msg.Tags.Add("welcome-email");
// 5. Send
MailgunMessage result = await mailer.SendAsync(msg);
Console.WriteLine($"Status: {result.Response.StatusCode}");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.