Mailgun API
Send emails through mailgun in rust asynchronously
How install it
- Add the next dependencies in the Cargo.toml file of the project:
= "0.2"
= { = "0.10", = ["json"]}
= { = "1.0", = ["derive"]}
= "1.0"
= "1.0"
= { = "0.2", = ["macros"]}
Example
use MailgunApi;
use EmailParams;
use dotenv;
use env;
// Inside of you tokio implementation
dotenv.ok;
let mailgun_secret = var.expect;
let mailgun_domain = var.expect;
let mailgun_endpoint = var.expect;
let sender = var.expect;
let receiver = var.expect;
let params = EmailParams ;
let mut mailgun = new;
let response = mailgun..await;
assert_eq!
How test it
- Create a .env file and add the next parameters:
MAILGUN_DOMAIN=[YOUR DOMAIN]
MAILGUN_SECRET=[YOUR MAILGUN API SECRET]
MAILGUN_ENDPOINT=[MAILGUN ENDPOINT] // There is two endpoint currently: api.mailgun.net and api.eu.mailgun.net
EMAIL_RECEIVER_TEST=[EMAIL RECEIVER TEST]
EMAIL_FROM=[SENDER TEST]
- Execute the tests
cargo test
Warning: when you are running the tests you are sending a email to the receiver that you set
About Dtos
The dtos are structures used to transform the json retrieved from Mailung API in data accesible by the rust aplication.
It wasn't possible to see any Mailgun documentation which specify which parameters are nullable then maybe is possible
to get an error in the response because the Dto property is not typed as Option
(please open an issue if that happens),
for this reason the methods accept Generics which you need to pass the Dtos provided or yours
Do you like Mailgun API?
If you like Mailgun API, help us supporting the project:
Roadmap
- Send email
- Retrieve Store Message
- Domains
- IPs
- Events
- Stats
- Tags
- Suppressions
- Routes
- Webhooks
- Mailing List
- Templates
- Email validation
- Inbox Placement
License
Mailgun API is MIT licensed