Unoficial wrapper for Mailjet API
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.
Getting Started
The first step is to instantiate a Mailjet structure with your API keys:
use Mailjet;
let mailjet = from_api_keys;
Now, each route in the API correspond to a function in your mailjet object, for example with message route:
use Mailjet;
use MessageRequest;
let mailjet = from_api_keys;
let res = mailjet.message.unwrap_or_default;
Those functions have an explicit name, you'll find them easily in the complete documentation or directly in your IDE.
Simple routes
Those routes only have a few variables in the url and have no parameters, they appear in the API reference like /message/{message_ID}
. In this case, the function name will be suffixed by _from_id
.
use Mailjet;
use MessageRequest;
let mailjet = from_api_keys;
let res = mailjet.message_from_id.unwrap_or_default;
Complex routes
Those routes have parameters to append at the end of the URL like /message
or /send
. In this case, you need to build a request object before passing it to the function. You can find them in the requests
module.
use Mailjet;
use MessageInformationRequest;
let mailjet = from_api_keys;
let request = MessageInformationRequest ;
let res = mailjet.message_information.unwrap_or_default;
Response
Every route returning a JSON will build a response object. You can find them in the responses
module.
use Mailjet;
use MessageRequest;
let mailjet = from_api_keys;
let res = mailjet.message.unwrap_or_default;
let count = res.count; // Corresponds to Count response field
let data = res.data; // Corresponds to Data response field
The data structures
The request and response structures are the same as mailjet's JSONs and parameters' names with PascalCase field names converted into snake_case format as asked by rust. Every JSON request and response is serializable/deserializable with serde, so you can easily build objects with JSON formats with serde_json.
For complete information on JSON structures and parameters, go read https://dev.mailjet.com/email/reference/
Example: send a basic email
use ;
// Create mailjet client
let mailjet = from_api_keys;
// Create recipients
let to = from_email;
let from = from_email_and_name;
// Create message
let mut message = default;
message.to.push;
message.from = from;
message.html_part = "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!".to_string;
message.text_part = "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!".to_string;
message.subject = "Your email flight plan!".to_string;
// Create send request
let mut send_request = default;
send_request.sandbox_mode = Some; // You can remove this when sending for real
send_request.messages.push;
// Send emails
let response = mailjet.send.unwrap_or_default;
Features
Categories | Features | Actions |
---|---|---|
Send Emails | - | ✅ Send an email message via Send API v3.1 ❌ Send an email message via Send API v3 |
Messages | - | ✅ Get detailed information on all processed messages ✅ Get detailed information on a specific processed message ✅ Get the event history for a specific message ✅ Retrieve sending / size / spam information about all messages ✅ Retrieve sending / size / spam information about a specific message ID |
Contact | Contact | ❌ Create a new contact ❌ Get a list of all contacts ❌ Get a specific contact ❌ Update a specific contact |
Contact | Contact List | ❌ Create a new contact list ❌ Retrieve general details for all contact lists ❌ Retrieve information on a specific contact list ❌ Update a specific contact list ❌ Delete a contact list |
Contact | Bulk Contact Management | ❌ Add, remove or unsubscribe a list of contacts to/from a selection of contact lists ❌ Add, unsubscribe or remove the contacts present in a list to / from another list ❌ Add, remove or unsubscribe a list of contacts to/from a specific contact list ❌ Use an uploaded CSV list of contacts to manage their presence and subscription status in a contact list ❌ Monitor a submitted upload / update request for multiple contacts ❌ Monitor a submitted upload / update request for contacts from one list to another ❌ Monitor a submitted upload / update request for multiple contacts into a specific contact list ❌ View the status of a CSV import job ❌ Update or abort a contact CSV import job in progress |
Contact | Contact Properties | ❌ Create a new contact property ❌ Get information on all contacts and the property values associated with them ❌ Get the contact property values relating to a specific contact ❌ Get information on all contact properties ❌ Get information on a specific contact property ❌ Update the contact property values relating to a specific contact ❌ Update the settings of an existing contact property ❌ Delete all contact property values relating to a specific contact ❌ Delete an existing contact property |
Contact | Subscriptions | ❌ Add, remove or unsubscribe a contact to/from a selection of contact lists ❌ Manage a single contact subscription to a specific contact list ❌ Create a new list recipient ❌ Get all contact lists for a specific contact ❌ Get info on all signup requests via a subscription widget ❌ Get info on a specific signup request via a subscription widget ❌ Get details on all list recipients ❌ Get details for a specific list recipient ❌ Update the subscription status of a list recipient ❌ Delete a list recipient |
Contact | Verifications | ❌ Start a contact list verification ❌ Retrieves the current state of the contact list verification job |
Campaigns | Drafts | ❌ Create a new campaign draft ❌ Manage the content of your campaign draft email ❌ Get all campaign drafts and their configuration ❌ Get a specific campaign draft and its configuration details ❌ Retrieve the content of your campaign draft email ❌ Update an existing campaign draft ❌ Retrieve the sending schedule of a campaign draft ❌ Schedule the sending of a campaign draft ❌ Update the sending schedule of a campaign draft ❌ Cancel the scheduled sending of a campaign draft ❌ Send a campaign draft immediately ❌ View the sending status of a campaign draft ❌ Send a test email for a specified campaign draft |
Campaigns | Sent Campaigns | ❌ Get detailed information about all campaigns ❌ Get detailed information about a specific campaign ❌ Delete a campaign or mark it as starred |
Segmentation | - | ❌ Create a new contact segmentation formula ❌ Get a list of all existing segments ❌ Get an existing contact segmentation formula ❌ Update an existing contact segmentation formula ❌ Delete an existing contact segmentation formula |
Templates | - | ❌ Create an email template ❌ Create the contents of an email template ❌ Get all email templates ❌ Retrieve the configuration settings for a specific template ❌ Get the contents of an email template ❌ Update the configuration settings of an email template ❌ Update the contents of an email template ❌ Delete an email template |
Statistics | - | ❌ Get general details and stats for all drafts, AB Testing objects and/or sent campaigns ❌ Get information about a specific draft, AB Testing object or sent campaign ❌ Get aggregated statistics, grouped by contact ❌ Get aggregated statistics for a specific contact ❌ Retrieve aggregated open and click statistics, grouped by recipient country ❌ Get aggregated statistics, grouped by list recipient ❌ Get aggregated statistics for a specific list recipient ❌ Get message-based or event-based aggregated statistics for a specific campaign, contact list, API Key or sender email address ❌ Get aggregated statistics for all clicked links in a campaign ❌ Retrieve statistics, aggregated by recipient's Email Service Provider (ESP) ❌ Get aggregated statistics for all clicked links ❌ Get open or click counts, grouped by web browser / email client |
Message Events | - | ❌ Get a list of all bounce events ❌ Get details for a specific bounce event ❌ Get a list of all click events ❌ Get a list of all open events ❌ Retrieve open event details for a specific message |
Webhook | - | ❌ Add a new callback URL ❌ Get a list of all callback URLs ❌ Get the configuration of a specific callback URL ❌ Update the configuration of an existing callback URL ❌ Delete an existing callback URL |
Parse | - | ❌ Create a new parseroute instance ❌ Get a list of all parseroute instances ❌ Get the configuration details for a specific parseroute resource ❌ Update an existing parseroute instance ❌ Delete an existing parseroute instance |
Sender Addresses and Domains | Sender | ❌ Create a new sender email address or domain ❌ Get a list of all existing sender email addresses and domains ❌ Retrieve details on a specific sender email address or domain ❌ Update an existing sender email address or domain ❌ Delete an existing sender email address or domain ❌ Validate a sender email address or domain |
Sender Addresses and Domains | Metasender | ❌ Create a new metasender ❌ Get a list of all metasenders ❌ Get a specific metasender ❌ Update and existing metasender |
Sender Addresses and Domains | DNS | ❌ Get the SPF and DKIM settings for all sender domains ❌ Get the SPF and DKIM settings for a specific sender domain ❌ Perform a DNS validation of a sender domain |
Settings | API Key Configuration | ❌ Create a new sub-account API Key ❌ Get all API Keys and their configuration settings ❌ Get the configuration settings of a specific API Key ❌ Update an existing API Key |
Settings | Account Settings | ❌ Retrieve your profile information ❌ Get general information on your user settings and activity ❌ Update your profile information ❌ Update the settings of your User ID |
Send SMS | - | ❌ Send an SMS Message |
SMS Messages | - | ❌ Request an export of SMS messages ❌ Retrieve a list of SMS messages ❌ Retrieve SMS messages count ❌ Retrieve an export request result ❌ Retrieve a single SMS message |