Skip to main content

Crate email_transport

Crate email_transport 

Source
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:

§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-conscious TracingTransport wrapper.

§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
tracing instrumentation 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.