lettre
Build and send emails in Rust via SMTP, sendmail, or file transport
Repository Health
Technical Analysis
lettre is a full-featured mailer library for Rust that covers everything from constructing a MIME-compliant email message to delivering it over SMTP, sendmail, or the local filesystem. It provides an ergonomic message builder, Unicode-aware headers and addresses, and multiple pluggable transports selected via Cargo features.
Both blocking and async APIs are supported, with async runtime integration for Tokio and async-std, plus TLS via native-tls or rustls, making it a common choice for Rust web services and CLI tools that need to send transactional or notification email.
What You Get
- An ergonomic
Message::builder()API for composing MIME emails with headers, HTML/plaintext bodies, and attachments - Multiple delivery transports: SMTP (with STARTTLS/TLS and authentication),
sendmail, local-file, and a no-op stub for tests - Both blocking and async (Tokio, async-std) sending APIs behind Cargo feature flags
- Unicode support for email content and addresses, including internationalized domain names via
idna - Pluggable TLS backends (native-tls or rustls) for encrypted SMTP connections
Common Use Cases
- Sending transactional emails (password resets, confirmations, receipts) from a Rust web backend
- Delivering notification or alert emails from a background job or CLI tool via SMTP relay
- Writing emails to disk (
FileTransport) for local development and debugging without a real mail server - Building async email-sending pipelines integrated into a Tokio-based service
Under The Hood
Architecture — The crate separates message construction from delivery: the message module builds MIME-compliant Message values (headers, multipart bodies, attachments, addresses), while src/transport/ holds independent transport backends — smtp/ (272-line mod.rs, 493-line transport.rs, 588-line response.rs for parsing SMTP replies), plus file/, sendmail/, and stub/ for local and test delivery. An executor.rs module abstracts over async runtimes (Tokio vs async-std) so the same transport code can run under either.
Tech Stack — Rust 2024 edition (MSRV 1.85), roughly 15,700 lines across src/. Core dependencies include nom (SMTP response parsing), idna and email_address for address validation, with a long list of optional dependencies gated behind Cargo features: tracing for instrumentation, base64/quoted_printable/email-encoding for MIME encoding, uuid/serde/serde_json for the file transport, and TLS via native-tls or rustls (also optional/feature-gated).
Code Quality — The crate ships benches/ for performance-sensitive paths, a tests/ directory with 5 integration test files, and 10+ runnable examples/ covering SMTP with STARTTLS, TLS, self-signed certs, and both async-std and default async paths. A maintained CHANGELOG.md (using clog) and 30 tagged releases from 2020 through 2026 show sustained, disciplined maintenance; the badge in the README explicitly marks the project “actively-developed.”
API Design — The builder pattern (Message::builder().from(...).to(...).subject(...).body(...)) mirrors idiomatic Rust builder conventions and keeps the common case — building and sending a simple email — to a handful of chained calls, as shown directly in the README’s runnable example. Feature-gated transports and TLS backends let consumers opt into only the code paths they need, keeping compile times and binary size down for minimal use cases (e.g., sendmail-only or file-only transport with no network/TLS dependencies at all).
Used by 5 apps in this directory
Hook0
Devops
Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.
Lemmy
Community · Social Media
Federated, self-hosted Reddit alternative with full community ownership and no corporate control.
Tabby
AI Code Assistants
Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.
Trieve
AI Development · Search · Developer Tools
All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.
Vaultwarden
Password Manager · Security
Unofficial Bitwarden-compatible server in Rust — run the full Bitwarden ecosystem on a Raspberry Pi using every official client you already have, without the multi-container overhead.