https://github.com/aronium/mailgun-wrapper
Mailgun wrapper written in C#
https://github.com/aronium/mailgun-wrapper
csharp dotnet email mailgun wrapper
Last synced: 2 months ago
JSON representation
Mailgun wrapper written in C#
- Host: GitHub
- URL: https://github.com/aronium/mailgun-wrapper
- Owner: aronium
- Created: 2017-08-20T22:42:35.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-09T14:35:17.000Z (almost 3 years ago)
- Last Synced: 2025-01-16T06:58:22.288Z (over 1 year ago)
- Topics: csharp, dotnet, email, mailgun, wrapper
- Language: C#
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Aronium Mailgun Wrapper
Mailgun wrapper written in C#.
Wrapper is using [Builder pattern](https://en.wikipedia.org/wiki/Builder_pattern) for easy chaining and creating [Mailgun](https://www.mailgun.com/) requests.
## Getting Started
Before you start, make sure you read Mailgun documentation at [Mailgun API Reference](https://documentation.mailgun.com/en/latest/api_reference.html)
### Prerequisites
Project is using .NET Framework 4.5
The following dependencies are managed using NuGet packages:
* RestSharp
* Newtonsoft.Json
### Installing
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.
## Usage examples
Below is the list of commonly used operations.
### Sending email
```csharp
// Method will send a simple email to specified recipient
var request = MailgunResourceRequest.Builder
.ForSendMessage()
.From("Aronium ")
.To("mail@example.com")
.Subject("Hi")
.Text("It is I, Leclerc!")
.Build();
var response = new MailgunService().GetResponse(request);
```
### Read events
```csharp
// 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(request);
```
### List all unsubscriptions
```csharp
var request = MailgunResourceRequest.Builder
.ForUnsubscribes()
.Build();
var response = new MailgunService().GetResponse(request);
```
### Check unsubscribe emails
```csharp
var request = MailgunResourceRequest.Builder
.ForUnsubscribes("unsubsribed@example.com")
.Build();
var response = new MailgunService().GetResponse(request);
```
## Authors
See the list of [contributors](https://github.com/aronium/mailgun-wrapper/graphs/contributors) who participated in this project.
## License
This project is licensed under the MIT License