Expand description
Core transport traits and per-send option types.
Transport models implementations that accept structured
email_message::Message values, while RawTransport models
implementations that send an explicit envelope plus RFC822 bytes.
Provider-specific options are carried through TransportOptions so the
core API stays transport-agnostic.
§Quick start
use email_transport::email_message::OutboundMessage;
use email_transport::{SendOptions, SendReport, Transport, TransportError};
async fn deliver<T: Transport>(
transport: &T,
message: &OutboundMessage,
) -> Result<SendReport, TransportError> {
transport.send(message, &SendOptions::default()).await
}Terminology:
- A transport is the Rust abstraction/implementation used to send mail.
- A provider is the external service or protocol identity behind a
transport, such as
"resend","postmark", or"smtp". - An instance is one configured use of a provider, such as
"transactional"or"marketing".
§Adapter helpers (public API)
Several utility functions are deliberately public so adapter crates can share kernel logic without re-implementing it. They are part of the 1.0 semver surface:
accepted_recipient_emails, derive theTo + Cc + Bccenvelope recipient list from aMessage.structured_accepted_for, populateSendReport::acceptedin a structured-Transportadapter, honoring aSendOptions::envelopeoverride only when the adapter advertisesCapabilities::custom_envelope.standard_message_headers, renderSender,Date, andMessage-IDas aVec<Header>for adapters whose provider API treats them as custom headers.
§Features
The default feature set enables serde.
serde: serialization for send metadata plus registry-driven deserialization of provider options.schemars: JSON Schema implementations for public wire types.tracing: the PII-consciousTracingTransportwrapper.
§Platform support
Native targets require transports and their returned futures to be
thread-safe. On wasm32, RuntimeBound and MaybeSend drop those
bounds so transports may hold browser or worker handles. The tracing
feature uses a web-compatible clock on wasm32-unknown-unknown.
Re-exports§
pub use string_newtype::STRING_NEWTYPE_MAX_BYTES;pub use string_newtype::StringNewtypeError;pub use tracing::TracingTransport;pub use email_message;pub use transport::*;
Modules§
- options
- Per-send options and provider-specific transport option storage.
- string_
newtype - Shared validation and macro support for string-backed newtypes.
- tracing
tracinginstrumentation for transport sends.- transport
- Structured and raw transport traits, capability metadata, and send reports.
Macros§
- string_
newtype - Generates a
String-backed validated newtype with the standard derives and conversion impls.