Rust wrapper for Mailjet's API
Mailjet is a service provider for sending emails and SMS, visit https://www.mailjet.com/ for more information.
WARNING: This wrapper is not official, Mailjet won't provide any support for it.
```rust use mailjetapiwrapper::{ data::{EmailAddress, Message}, requests::SendRequest, Mailjet, };
// Create mailjet client let mailjet = Mailjet::fromapikeys("yourkey", "yoursecret");
// Create recipients let to = EmailAddress::fromemail("passenger1@mailjet.com"); let from = EmailAddress::fromemailandname("pilot@mailjet.com", "Mailjet Pilot");
// Create message
let mut message = Message::default();
message.to.push(to);
message.from = from;
message.htmlpart = "Dear passenger 1, welcome to Mailjet!
May the delivery force be with you!".tostring();
message.textpart = "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!".tostring();
message.subject = "Your email flight plan!".to_string();
// Create send request let mut sendrequest = SendRequest::default(); sendrequest.sandboxmode = Some(true); // You can remove this when sending for real sendrequest.messages.push(message);
// Send emails let response = mailjet.send(&send_request).unwrap(); ```
The request and response structures are the same as mailjet's JSONs with PascalCase field names converted into snakecase format as asked by rust. Everything is serializable/deserializable with serde, so you can easily go back to original JSON formats with serdejson.
For more information on JSON structures, go read https://dev.mailjet.com/email/guides/send-api-v31/