wasm-smtp-component 0.15.1

WASM Component Model interface for wasm-smtp (wasm32-wasip2 target).
Documentation
//! Native-host type stubs.
//!
//! On `wasm32-wasip2` these types are generated by `wit-bindgen::generate!`.
//! On native hosts they are hand-written mirrors so that unit tests compile
//! and run without a WASM runtime.

/// How to establish TLS.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TlsMode {
    Implicit,
    Starttls,
}

/// SMTP server connection parameters.
#[derive(Debug, Clone)]
pub struct SmtpConfig {
    pub host: String,
    pub port: u16,
    pub ehlo_domain: String,
    pub tls_mode: TlsMode,
}

/// SMTP authentication credentials.
///
/// Intentionally does NOT implement `Debug` to prevent accidental logging.
#[derive(Clone)]
pub struct SmtpCredentials {
    pub username: String,
    pub password: String,
}

impl core::fmt::Debug for SmtpCredentials {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.debug_struct("SmtpCredentials")
            .field("username", &self.username)
            .field("password", &"[REDACTED]")
            .finish()
    }
}

/// A single SMTP message: envelope + body.
#[derive(Debug, Clone)]
pub struct SmtpMessage {
    pub from: String,
    pub to: Vec<String>,
    pub raw_message: String,
}

/// Successful send result.
#[derive(Debug, Clone)]
pub struct SendResult {
    pub reply_code: u16,
}

/// Error returned when the send operation fails.
#[derive(Debug, Clone)]
pub enum SendError {
    Io(String),
    Protocol(String),
    AuthRejected,
    InvalidInput(String),
    PolicyRejected(String),
}