lettr crate with Cargo, or browse its source on GitHub:
Using an AI coding agent? Give it this prompt to get started:
Why Use the Rust SDK?
Rather than making raw HTTP requests, the SDK provides:- Type-safe API — Full type safety with serde-powered serialization
- Async-first design — Built on Tokio for non-blocking operations
- Zero-copy — Efficient deserialization with minimal allocations
- Builder pattern — Fluent API for constructing complex emails
- Result types — Idiomatic error handling with Rust’s
Result<T, E>
Prerequisites
Before you begin, make sure you have:API Key
Create an API key in the Lettr dashboard
Verified Domain
Add and verify your sending domain
- Rust 1.85 or later installed (via rustup)
- A verified sending domain in your Lettr dashboard
Quick Setup
Get started in three quick steps: install, configure, and send.1
Install the SDK
macros feature provides #[tokio::main] and the rt-multi-thread feature enables the multi-threaded runtime.2
Create a client
3
Send your first email
request_id for tracking and the number of accepted recipients.Configuration
Environment Variables
Read your API key from an environment variable:Using dotenvy
Load environment variables from a.env file using the dotenvy crate:
.env file:
Client construction
The client builds and owns its ownreqwest client internally. There are three
constructors:
Requests time out after 30 seconds. Injecting your own
reqwest::Client — and
therefore changing that timeout, or setting proxies or connection-pool
settings — is not currently supported. If you need it, open an issue on
lettr-rust.Blocking usage
The crate is async by default. For synchronous code, enable theblocking
feature, which swaps the internal client for reqwest::blocking:
Sending Emails
Basic HTML Email
Send a simple HTML email:With Display Name
Add a friendly display name to the sender address:Plain Text Email
Send a plain text email without HTML:Multipart Emails (HTML + Text)
Send both HTML and plain text versions for maximum compatibility:Explore the SDK
Beyond sending, the SDK manages every Lettr resource:Templates
Manage Lettr templates and merge tags
Domains
Add, verify, and manage sending domains
Webhooks
Manage webhook endpoints for delivery and engagement events
Audience
Lists, contacts, topics, properties, and segments
Campaigns
List, send, and schedule campaigns
What’s Next
Advanced Features
Learn about attachments, templates, tracking, and more
API Reference
Complete API documentation
Best Practices
Email deliverability tips