capy-mail 0.10.0

Conventional SMTP mail, typed templates, and mail notifications for Capy.
Documentation
/// Safe error categories. Raw SMTP responses/credentials/content are never retained.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MailError {
    /// Invalid or unsafe configuration.
    Configuration,
    /// Invalid mailbox syntax.
    Address,
    /// Invalid header or control characters.
    Header,
    /// Invalid message structure.
    Message,
    /// Invalid attachment metadata or size.
    Attachment,
    /// Message exceeds configured bounds.
    Size,
    /// Template rendering failed.
    Template,
    /// Connection or protocol failure, conservatively retryable.
    Connection,
    /// Authentication rejected; operator action required.
    Authentication,
    /// TLS negotiation or certificate validation failed.
    Tls,
    /// SMTP temporary failure.
    Temporary,
    /// SMTP permanent failure.
    Permanent,
    /// Total send deadline expired; delivery may already have happened.
    Timeout,
    /// Test capture reached its explicit limit.
    CaptureFull,
    /// Private development inbox I/O, permissions or serialization failed.
    CaptureStorage,
    /// Queue persistence failed; commit status can be ambiguous.
    Queue,
}
impl MailError {
    /// Stable category for safe observability.
    pub fn category(self) -> &'static str {
        match self {
            Self::Configuration => "configuration",
            Self::Address => "address",
            Self::Header => "header",
            Self::Message => "message",
            Self::Attachment => "attachment",
            Self::Size => "size",
            Self::Template => "template",
            Self::Connection => "connection",
            Self::Authentication => "authentication",
            Self::Tls => "tls",
            Self::Temporary => "temporary",
            Self::Permanent => "permanent",
            Self::Timeout => "timeout",
            Self::CaptureFull => "capture_full",
            Self::CaptureStorage => "capture_storage",
            Self::Queue => "queue",
        }
    }
    /// Only temporary/connection/deadline errors are automatically retryable by Jobs.
    pub fn retryable(self) -> bool {
        matches!(self, Self::Temporary | Self::Connection | Self::Timeout)
    }
}
impl std::fmt::Display for MailError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "Mail operation failed ({})", self.category())
    }
}
impl std::error::Error for MailError {}
impl From<askama::Error> for MailError {
    fn from(_: askama::Error) -> Self {
        Self::Template
    }
}
impl From<MailError> for capy_core::AppError {
    fn from(error: MailError) -> Self {
        Self::Internal(error.into())
    }
}

impl From<MailError> for capy_core::EventError {
    fn from(error: MailError) -> Self {
        Self::Failure(capy_core::AppError::from(error))
    }
}