email/sendmail/
config.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Module dedicated to the sendmail sender configuration.
//!
//! This module contains the configuration specific to the sendmail
//! sender.

use once_cell::sync::Lazy;
use process::Command;

pub static SENDMAIL_DEFAULT_COMMAND: Lazy<Command> =
    Lazy::new(|| Command::new("/usr/bin/sendmail"));

/// The sendmail sender configuration.
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[cfg_attr(
    feature = "derive",
    derive(serde::Serialize, serde::Deserialize),
    serde(rename_all = "kebab-case")
)]
pub struct SendmailConfig {
    /// The sendmail command.
    pub cmd: Option<Command>,
}

impl SendmailConfig {
    pub fn cmd(&self) -> &Command {
        self.cmd.as_ref().unwrap_or(&*SENDMAIL_DEFAULT_COMMAND)
    }
}