Mailgun API

Send emails through mailgun in rust

How install it

  1. add the dependency in the Cargo.toml file of the project:

toml mailgun_api = "0.1"

Example

```rust

[tokio::test]

async fn shoulsendemailwithtext() { use std::collections::HashMap; use dotenv::dotenv; use std::env; dotenv().ok(); let mailgunsecret = env::var("MAILGUNSECRET").expect("MAILGUNSECRET must be set"); let mailgundomain = env::var("MAILGUNDOMAIN").expect("MAILGUNDOMAIN must be set"); let mailgunendpoint = env::var("MAILGUNENDPOINT").expect("MAILGUNENDPOINT must be set"); let sender = env::var("EMAILFROM").expect("MAILFROM must be set"); let receiver = env::var("EMAILRECEIVERTEST").expect("EMAILRECEIVERTEST must be set"); let params = EmailParams { from: sender, to: receiver, subject: "test mailgung api".tostring(), text: Some("hello this is a test".tostring()), html: None, }; let mut mailgun = MailungApi::new(&mailgunsecret, &mailgunendpoint, &mailgundomain); let response = mailgun.sendemail::>(params).await; asserteq!(response.is_ok(), true) } ```

How test it

  1. 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]

  1. Execute the test cargo test

Warning: when you are running the tests you are sending a email to the receiver that you set

Do you like Mailgun API?

Roadmap

License

Mailgun API is MIT licensed