Skip to main content

Module mail_transport

Module mail_transport 

Source
Expand description

SMTP send + IMAP fetch transport for the semantic mail client.

This module is the network edge for mail: it puts bytes on the wire (SMTP over STARTTLS) and pulls unseen messages off it (IMAP over implicit TLS). It deliberately does not make delivery decisions — those belong to the pure rules layer in crate::mail_rules. The bridge between the two is build_inbound, a pure function that constructs the crate::mail_rules::InboundMessage envelope the rules engine consumes; the IMAP path uses it to turn each fetched message into something crate::mail_rules::evaluate can rule on.

Network functions are gated #[cfg(not(target_arch = "wasm32"))] — there is no raw-socket SMTP/IMAP on the wasm32 target, so only the pure surface (SmtpConfig, ImapConfig, OutgoingMail, build_inbound) compiles there.

All fallible network functions map their underlying errors to String so callers get a flat, transport-agnostic error surface.

Structs§

ImapConfig
Connection + credentials for an inbound IMAP server (implicit TLS on the IMAPS port).
OutgoingMail
A message to be sent via send.
Pop3Config
Connection + credentials for a legacy POP3S service. POP3 is retrieval only; SMTP remains the outbound transport. Implicit TLS is required so the account password is never sent on a plaintext POP3 connection.
Pop3FetchedMessage
A message fetched through POP3S before semantic delivery rules decide its final local mailbox and quarantine state.
SmtpConfig
Connection + credentials for an outbound SMTP submission server (STARTTLS on the submission port).

Functions§

build_inbound
Construct an InboundMessage envelope for the rules engine.
fetch_pop3
Retrieve messages from a traditional POP3S mailbox. POP3 has no portable UNSEEN flag, so this returns the mailbox contents; the caller is expected to persist accepted UIDLs before the next poll. Only implicit TLS is supported—plaintext POP3 would expose the account password.
fetch_unseen
Fetch the unseen messages from mailbox on the IMAP server described by cfg (implicit TLS).
send
Send mail through the SMTP submission server described by cfg (STARTTLS).