lettre

Build and send emails in Rust via SMTP, sendmail, or file transport

Library
Cargo
v0.11.23
2,253stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
67/100Good
Development Activity60
Maintenance40
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture82
Code Quality84
Innovation74
Learning Curve78

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).

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search