Skip to main content

Crate ryu_email_send

Crate ryu_email_send 

Source
Expand description

BYOK SMTP email sink for self-host — an extracted Core capability crate.

The delivery leg for self-host alerts (budget/firewall policy alerts, monitor notifications) and, later, agent-inbox send. Delivery is “what runs” (Core), not policy (Gateway): the Gateway decides an alert fires; the node opens the socket and sends.

Nothing hardcoded: the transport is a swappable BYO SMTP relay resolved from preferences (desktop Settings) first, then environment for headless setups. There is no default provider — with no relay configured the sink is a no-op (resolve_transport returns None) and callers simply skip email. SMTP is one swappable sink; the SES agent-inbox path (packages/mail) is another.

The public sink is a rich builder (OutboundEmail) — multi-recipient, cc/bcc/reply-to, text+html multipart, threading headers, and attachments — so the agent-inbox send path (which needs all of that to preserve mail-client threading) and the one-line alert path (send_email_alert) share one transport.

Secret custody stays kernel-side: the SMTP password is never held here. Core injects a resolver via set_password_resolver (backed by its smtp_auth BYO-key store), so this crate has ZERO dependency on apps/core.

Structs§

Attachment
A file attached to an outbound email.
EmailTransportConfig
Non-secret SMTP transport config. The password is resolved separately via [crate::smtp_auth] so the secret surface stays isolated.
OutboundEmail
A fully-specified outbound email. Built once; the alert path wraps it.
TransportPrefs
The non-secret transport fields persisted under SMTP_TRANSPORT_PREF_KEY and exchanged with the desktop SMTP card. The password never appears here.

Enums§

EmailError

Constants§

SMTP_TRANSPORT_PREF_KEY
Preferences key holding the non-secret transport JSON (host/port/username/ from/starttls). The password is stored separately via [crate::smtp_auth]. Core loads it on startup and on change so the desktop card takes effect with no restart.

Functions§

apply_transport_prefs_json
Apply a persisted TransportPrefs JSON value to the in-process cache. Called at startup and whenever the pref changes. A malformed value clears the cache.
current_transport_prefs
Read the currently-cached non-secret transport prefs, if any (for GET).
resolve_transport
Resolve the effective transport: cached prefs first, else RYU_SMTP_* env. Returns None when no host or no password is available (email disabled).
send_email
Send a fully-specified email over the given BYO SMTP transport. Returns the Message-ID on success (for threading / provider-id records). Bounded by [SEND_TIMEOUT].
send_email_alert
Thin single-recipient plain-text alert send over the given transport.
set_password_resolver
Wire the SMTP-password resolver. Core calls this once at startup with a closure over its smtp_auth store. Idempotent replace.
set_transport
Set (or clear, when host is empty) the in-process transport config from a preferences value. The password is set separately via [crate::smtp_auth::set_password].