swadhinbiswas 📧 p4: mail EmailMessage + MailerState · 7/25/2026
549bf99
20 lines · 436 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::sync::Arc;

use super::{smtp::SmtpSender, SmtpConfig};

/// Global mailer state shared across requests.
pub struct MailerState {
    pub config: SmtpConfig,
    pub sender: SmtpSender,
}

impl MailerState {
    pub fn new(config: SmtpConfig) -> Self {
        let sender = SmtpSender::new(config.clone());
        Self { config, sender }
    }
}

/// Thread-safe handle to the mailer.
pub type SharedMailer = Arc<MailerState>;