mailgun-rs
MailGun API client written in Rust.
This crate helps facilitate interacting with the MailGun API. You will need to supply both an API Key and Domain.
Usage
Send a Message
use ;
let client = new;
let params = default
.add
.add
.add
.add;
if let Err = client.send_message
This crate does not enforce rules on sending messages. However, you should almost always set the following when sending a message:
- Subject
- To
- From
- Html and/or Text
Caution: Not all send message request parameters have been tested. If you notice any that do not work, please feel free to create a ticket, or create a pull a request.
Pagination
For API calls that return a list of results, MailGun returns a paging
structure. The paging fields are all URLs. Instead of having to parse these,
you may use the call
method to fetch these pages.
let mut response = client.get_bounces.unwrap;
let mut bounces = response.items;
if bounces.len > 0
Further Examples
let client = new;
// Get all events.
let events = client.get_events.unwrap;
// Get all bounces.
let bounces = client.get_bounces.unwrap;
// Get account stats.
let stats = client.get_stats.unwrap;
Testing
Before you start testing, you will need to create a .test.env
file in the project's root directory.
The file should contain the following settings:
MAILGUN_API_KEY=''
MAILGUN_DOMAIN=''