plunk-rs
An async Rust client for Plunk transactional email.
Send HTML, templates, and template variables (the data object) with validation, typed errors, and a small dependency footprint (reqwest + rustls).
Why this crate
| Focused | Covers POST /v1/send—HTML and template sends, with optional from, reply, headers, and data for template variables. |
| Validates early | Email and EmailAddress are built with checks so bad requests fail before the wire. |
| Clean boundary | Wire DTOs stay internal; your code uses Email, SendResponse, and Error. |
| TLS | reqwest with rustls—no OpenSSL at build time. |
Installation
Add to Cargo.toml:
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Or:
cargo add plunk-rs
cargo add tokio --features rt-multi-thread,macros
Quick start
use ;
async
Template send (with data for the template):
use ;
use json;
async
Self-hosted or custom base URL
let client = builder
.base_url?
.build?;
base_url is normalized: if the path does not end with /, one is added so v1/send joins correctly.
API surface
Client/ClientBuilder— Bearer API key, optionalreqwest::Clientinjection.Email,EmailAddress,Recipients— Construction helpers for HTML vs template, headers, and JSONdata(must serialize to a JSON object for templates).SendResponse,Delivery,Contact— Parsed success payload from the send response.Error,ApiError,Result<T>— Transport, validation, and Plunk error bodies (with status and raw body preserved).
Requirements
Rust 2024 edition (use a current stable toolchain that supports it). Async code assumes a runtime such as Tokio.
Docs
License
Made for sending mail through Plunk without the ceremony.