Official Rust SDK for the Lettr Email API. An async, typed client for emails, templates, domains, webhooks, audience, and campaigns.
Add lettr to your Cargo.toml:
[dependencies]
lettr = "1.3"Or with the Cargo CLI:
cargo add lettruse lettr::{Lettr, CreateEmailOptions};
#[tokio::main]
async fn main() -> lettr::Result<()> {
let client = Lettr::new("your-api-key");
let email = CreateEmailOptions::new(
"[email protected]",
["[email protected]"],
"Hello from Lettr!",
)
.with_html("<h1>Welcome!</h1>");
let response = client.emails.send(email).await?;
println!("Email sent! Request ID: {}", response.request_id);
Ok(())
}Lettr::from_env() reads the key from LETTR_API_KEY instead.
Methods return lettr::Result<T> with a unified Error you can match on:
# use lettr::{Lettr, CreateEmailOptions, Error};
# async fn run() {
# let client = Lettr::new("key");
# let email = CreateEmailOptions::new("[email protected]", ["[email protected]"], "Hi");
match client.emails.send(email).await {
Ok(response) => println!("Sent! ID: {}", response.request_id),
Err(Error::Validation(e)) => eprintln!("Validation: {} {:?}", e.message, e.errors),
Err(Error::Api(e)) => eprintln!("API error: {} ({:?})", e.message, e.error_code),
Err(e) => eprintln!("Error: {e}"),
}
# }See Error Handling for the full set of variants.
| Feature | Default | Description |
|---|---|---|
native-tls |
Yes | Use the system's native TLS stack |
rustls-tls |
No | Use rustls for TLS |
blocking |
No | Enable the synchronous (blocking) API |
With blocking, drop the .await — methods return Result directly.
Full guides for every service, with complete request/response details, live in the docs:
📚 docs.lettr.com/quickstart/rust
| Topic | Guide |
|---|---|
| Install, client, sending | Quickstart |
| Async patterns, batch sending, error handling | Advanced |
| Manage Lettr templates & merge tags | Templates |
| Add, verify, and manage sending domains | Domains |
| Webhook endpoints for delivery & engagement events | Webhooks |
| Lists, contacts, topics, properties, segments | Audience |
| List, send, and schedule campaigns | Campaigns |
| Endpoint reference (params & schemas) | API Reference |
MIT