Mailgun wrapper written in C#.
Wrapper is using Builder pattern for easy chaining and creating Mailgun requests.
Before you start, make sure you read Mailgun documentation at Mailgun API Reference
Project is using .NET Framework 4.5
The following dependencies are managed using NuGet packages:
- RestSharp
- Newtonsoft.Json
Clone repo or download a ZIP file with source files and open MailgunWrapper.sln in Visual Studio.
First project build will update NuGet dependencies automatically.
Below is the list of commonly used operations.
// Method will send a simple email to specified recipient
var request = MailgunResourceRequest.Builder
.ForSendMessage()
.From("Aronium <me@aronium.com>")
.To("mail@example.com")
.Subject("Hi")
.Text("It is I, Leclerc!")
.Build();
var response = new MailgunService().GetResponse<MailgunSendEmailResponse>(request);
// Method will get all Unsubscribed and Failed (e.g. Bounced) events from day ago
var request = MailgunResourceRequest.Builder
.ForEvents(MailGunEventType.Unsubscribed | MailGunEventType.Failed)
.Begin(DateTime.Now.AddDays(-1))
.Limit(10)
.Build();
var response = new MailgunService().GetResponse<MailgunEventCollection>(request);
var request = MailgunResourceRequest.Builder
.ForUnsubscribes()
.Build();
var response = new MailgunService().GetResponse<MailgunEmailAddressCollection>(request);
var request = MailgunResourceRequest.Builder
.ForUnsubscribes("unsubsribed@example.com")
.Build();
var response = new MailgunService().GetResponse<MailgunEmailAddress>(request);
See the list of contributors who participated in this project.
This project is licensed under the MIT License