diff --git a/proxmox-notify/src/context.rs b/proxmox-notify/src/context.rs index c31a243b..4643f987 100644 --- a/proxmox-notify/src/context.rs +++ b/proxmox-notify/src/context.rs @@ -3,6 +3,8 @@ use std::fmt::Debug; pub trait Context: Send + Sync + Debug { fn lookup_email_for_user(&self, user: &str) -> Option; + fn default_sendmail_author(&self) -> String; + fn default_sendmail_from(&self) -> String; } static CONTEXT: OnceCell<&'static dyn Context> = OnceCell::new(); diff --git a/proxmox-notify/src/endpoints/sendmail.rs b/proxmox-notify/src/endpoints/sendmail.rs index 4e412a43..aba7150c 100644 --- a/proxmox-notify/src/endpoints/sendmail.rs +++ b/proxmox-notify/src/endpoints/sendmail.rs @@ -112,9 +112,17 @@ impl Endpoint for SendmailEndpoint { let text_part = renderer::render_template(TemplateRenderer::Plaintext, ¬ification.body, properties)?; - // proxmox_sys::email::sendmail will set the author to - // "Proxmox Backup Server" if it is not set. - let author = self.config.author.as_deref().or(Some("")); + let author = self + .config + .author + .clone() + .unwrap_or_else(|| context().default_sendmail_author()); + + let mailfrom = self + .config + .from_address + .clone() + .unwrap_or_else(|| context().default_sendmail_from()); let recipients_str: Vec<&str> = recipients.iter().map(String::as_str).collect(); @@ -123,8 +131,8 @@ impl Endpoint for SendmailEndpoint { &subject, Some(&text_part), Some(&html_part), - self.config.from_address.as_deref(), - author, + Some(&mailfrom), + Some(&author), ) .map_err(|err| Error::NotifyFailed(self.config.name.clone(), err.into())) }