Expand description
§wasm-smtp-cloudflare
Cloudflare Workers socket adapter for wasm-smtp.
This crate is a thin bridge between the Cloudflare Workers runtime’s
TCP socket API (worker::Socket) and the
wasm-smtp::Transport / wasm-smtp::StartTlsCapable
contracts. It does not implement SMTP itself; everything
protocol-shaped lives in wasm-smtp.
§Scope
- Open a TCP connection from a Worker using
worker::connect(). - Configure either Implicit TLS (
SecureTransport::On, port 465) or STARTTLS (SecureTransport::StartTls, port 587). - Wrap the resulting
worker::Socketso it implements bothwasm-smtp::Transportand (for STARTTLS)wasm-smtp::StartTlsCapable. - Translate Workers-side I/O failures into
wasm-smtp::IoErrorstrings.
§Out of scope
- SMTP state, command formatting, response parsing, dot-stuffing —
these belong in
wasm-smtp. - MIME composition or attachment building — supply a fully-formed RFC 5322 message as the body.
§Quick start (Implicit TLS, port 465)
ⓘ
use wasm_smtp_cloudflare::connect_smtps;
let mut client = connect_smtps("smtp.example.com", 465, "client.example.com").await?;
client.login("user@example.com", "secret").await?;
client.send_mail(
"user@example.com",
&["recipient@example.org"],
"From: user@example.com\r\n\
To: recipient@example.org\r\n\
Subject: Hello\r\n\
\r\n\
Body text.\r\n",
).await?;
client.quit().await?;§Quick start (STARTTLS, port 587)
ⓘ
use wasm_smtp_cloudflare::connect_smtp_starttls;
let mut client =
connect_smtp_starttls("smtp.example.com", 587, "client.example.com").await?;
client.login("user@example.com", "secret").await?;
// ... same as above§Targets
Production code only runs on wasm32-unknown-unknown inside the
Cloudflare Workers runtime. The crate compiles on host targets so
that cargo check can validate types and so that the conversion
helpers in adapter can be unit-tested against tokio-test mocks
— but at runtime, worker::Socket requires the Workers runtime.
Re-exports§
pub use adapter::CloudflareTransport;pub use integration::connect_smtp_starttls;pub use integration::connect_smtps;pub use socket::connect_implicit_tls;pub use socket::connect_starttls;
Modules§
- adapter
CloudflareTransport— theTransportimplementation that wraps a Cloudflare Workersworker::Socket.- integration
- High-level integration helpers that compose the Cloudflare
transport with
wasm-smtp. - socket
- Cloudflare Workers socket factory.
Structs§
- Smtp
Client - Re-export of
SmtpClientfor convenience:connect_smtpsreturnsSmtpClient<CloudflareTransport>. SMTP client driving a single connection.
Enums§
- Smtp
Error - Re-export of
SmtpErrorfor convenience. Top-level error type for all SMTP operations.
Traits§
- Start
TlsCapable - Re-export of
StartTlsCapablefor callers that want to callupgrade_to_tlsdirectly. Marker for aTransportthat can be upgraded to TLS in-place after connection. - Transport
- Re-export of the core
Transporttrait so that callers depending on this crate do not need a direct dependency onwasm-smtpfor the most common use. Async byte-oriented transport contract used bycrate::SmtpClient.