https://github.com/lettermint/lettermint-rust
https://github.com/lettermint/lettermint-rust
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/lettermint/lettermint-rust
- Owner: lettermint
- License: mit
- Created: 2026-05-11T19:48:42.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-11T19:52:27.000Z (about 2 months ago)
- Last Synced: 2026-05-11T21:37:33.387Z (about 2 months ago)
- Language: Rust
- Size: 58.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Lettermint Rust SDK
[](https://crates.io/crates/lettermint)
[](https://crates.io/crates/lettermint)
[](https://docs.rs/lettermint)
[](https://github.com/lettermint/lettermint-rust/actions?query=workflow%3ACI+branch%3Amain)
[](https://deps.rs/crate/lettermint)
[](https://github.com/lettermint/lettermint-rust/blob/main/LICENSE)
[](https://lettermint.co/r/discord)
Official Rust SDK for the Lettermint sending and team APIs.
## Requirements
- Current stable Rust. The crate's `rust-version` tracks the current supported stable minor release.
- Tokio or another async runtime compatible with `reqwest`
## Installation
```toml
[dependencies]
lettermint = "0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```
## Send Email
```rust
use lettermint::Lettermint;
#[tokio::main]
async fn main() -> lettermint::Result<()> {
let email = Lettermint::email(std::env::var("LETTERMINT_TOKEN").unwrap())?;
let response = email
.email()
.from("sender@example.com")
.to("recipient@example.com")
.subject("Hello from Rust")
.html("
Hello from Lettermint.
")
.idempotency_key("welcome-123")
.send()
.await?;
println!("{}", response.message_id);
Ok(())
}
```
The fluent email builder owns its payload. Each call to `email.email()` starts with a fresh payload, so attachments, headers, metadata, and recipients do not leak between sends.
## Direct API Payloads
```rust
use lettermint::{types, Lettermint};
#[tokio::main]
async fn main() -> lettermint::Result<()> {
let email = Lettermint::email(std::env::var("LETTERMINT_TOKEN").unwrap())?;
let payload = types::SendMailRequest {
from: "sender@example.com".into(),
to: vec!["recipient@example.com".into()],
subject: "Typed payload".into(),
text: Some("Hello from Lettermint.".into()),
..Default::default()
};
email.send(&payload).await?;
Ok(())
}
```
## Team API
```rust
use lettermint::Lettermint;
#[tokio::main]
async fn main() -> lettermint::Result<()> {
let api = Lettermint::api(std::env::var("LETTERMINT_TEAM_TOKEN").unwrap())?;
let domains = api.domains().list(&[("page[size]", "10")]).await?;
for domain in domains.data {
println!("{}", domain.domain);
}
Ok(())
}
```
`Lettermint::email(...)` authenticates with `X-Lettermint-Token` for sending endpoints. `Lettermint::api(...)` authenticates with `Authorization: Bearer ...` for team endpoints.
## Webhooks
```rust
use lettermint::Webhook;
fn handle(payload: &str, signature: &str, delivery: i64) -> lettermint::Result {
Webhook::new(std::env::var("LETTERMINT_WEBHOOK_SECRET").unwrap())
.verify(payload, signature, Some(delivery))
}
```
Webhook verification checks the `t=...` timestamp, validates the `v1=...` HMAC-SHA256 signature in constant time, cross-checks the optional delivery timestamp, and enforces a 5 minute tolerance by default.
## Development
```bash
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features --locked
```
Generated DTOs live in `src/types.rs`. Regenerate them from the repository root with:
```bash
python3 sdk-generator/rust/generate-types.py
```