Send email from Rust with Lettr
Lettr works with Rust through the lettr crate.
Checked
What you can do
- Send email and templates
- Manage domains and webhooks
- Manage your audience and campaigns
How to set it up
cargo add lettr
cargo add tokio --features macros,rt-multi-threaduse lettr::{Lettr, CreateEmailOptions};
#[tokio::main]
async fn main() -> lettr::Result<()> {
let client = Lettr::new("your-api-key");
let email = CreateEmailOptions::new(
"sender@yourdomain.com",
["recipient@example.com"],
"Hello from Lettr",
)
.with_html("<h1>Hello!</h1><p>This is a test email.</p>");
client.emails.send(email).await?;
Ok(())
}Requirements
- Rust 1.85 or later
- Tokio as the async runtime