pub fn fetch_unseen(
cfg: &ImapConfig,
mailbox: &str,
) -> Result<Vec<InboundMessage>, String>Expand description
Fetch the unseen messages from mailbox on the IMAP server described by cfg (implicit TLS).
Connects over implicit TLS to cfg.host:cfg.port, logs in, selects mailbox, searches for
UNSEEN messages, and for each fetches RFC822.SIZE ENVELOPE. Each fetched message is turned
into an InboundMessage via build_inbound using the
envelope’s from (first sender address, reconstructed as local@host) and subject, its
reported size, and mailbox as the recipient. Because IMAP does not itself attest sender
identity, sender_verified is false and sender_did is None; verification is a higher-layer
concern. The session is logged out before returning. This is written defensively — a message with
no envelope or no size is skipped rather than failing the whole fetch — and all underlying errors
are flattened to String.