Expand description
Lettre is an email library that allows creating and sending messages. It provides:
- An easy to use email builder
- Pluggable email transports
- Unicode support
- Secure defaults
- Async support
Lettre requires Rust 1.56.0 or newer.
Features
This section lists each lettre feature and briefly explains it. More info about each module can be found in the corresponding module page.
Features with 📫
near them are enabled by default.
Typed message builder
Strongly typed message
builder
- builder 📫: Enable the
Message
builder - hostname 📫: Try to use the actual system hostname in the
Message-ID
header
SMTP transport
Send emails using SMTP
- smtp-transport 📫: Enable the SMTP transport
- pool 📫: Connection pool for SMTP transport
- hostname 📫: Try to use the actual system hostname for the SMTP
CLIENTID
SMTP over TLS via the native-tls crate
Secure SMTP connections using TLS from the native-tls
crate
Uses schannel on Windows, Security-Framework on macOS, and OpenSSL on Linux.
- native-tls 📫: TLS support for the synchronous version of the API
- tokio1-native-tls: TLS support for the
tokio1
async version of the API
NOTE: native-tls isn’t supported with async-std
SMTP over TLS via the rustls crate
Secure SMTP connections using TLS from the rustls-tls
crate
Rustls uses ring as the cryptography implementation. As a result, not all Rust’s targets are supported.
- rustls-tls: TLS support for the synchronous version of the API
- tokio1-rustls-tls: TLS support for the
tokio1
async version of the API - async-std1-rustls-tls: TLS support for the
async-std1
async version of the API
Sendmail transport
Send emails using the sendmail
command
- sendmail-transport: Enable the
sendmail
transport
File transport
Save emails as an .eml
file
- file-transport: Enable the file transport (saves emails into an
.eml
file) - file-transport-envelope: Allow writing the envelope into a JSON file (additionally saves envelopes into a
.json
file)
Async execution runtimes
Use tokio or async-std as an async execution runtime for sending emails
The correct runtime version must be chosen in order for lettre to work correctly.
For example, when sending emails from a Tokio 1.x context, the Tokio 1.x executor
(Tokio1Executor
) must be used. Using a different version (for example Tokio 0.2.x),
or async-std, would result in a runtime panic.
- tokio1: Allow to asynchronously send emails using Tokio 1.x
- async-std1: Allow to asynchronously send emails using async-std 1.x
NOTE: native-tls isn’t supported with async-std
Misc features
Additional features
- serde: Serialization/Deserialization of entities
- tracing: Logging using the
tracing
crate - mime03: Allow creating a
ContentType
from an existing mime 0.3Mime
struct - dkim: Add support for signing email with DKIM
Modules
Email addresses
Error type for email messages
builder
Provides a strongly typed way to build emails
Transports for sending emails
Structs
Represents an email address with a user and a domain name.
tokio1
or async-std1
Asynchronously writes the content and the envelope information to a file
tokio1
or async-std1
Asynchronously sends emails using the sendmail
command
tokio1
or async-std1
Asynchronously sends emails using the SMTP protocol
async-std1
Async Executor
using async-std
1.x
file-transport
Writes the content and the envelope information to a file
builder
Email message which can be formatted
sendmail-transport
Sends emails using the sendmail
command
smtp-transport
Sends emails using the SMTP protocol
tokio1
Async Executor
using tokio
1.x
Traits
tokio1
or async-std1
Async Transport method for emails
tokio1
or async-std1
Async executor abstraction trait
Blocking Transport method for emails