From 6a03a75674c4f11b56f46161dfb44a5ce8e51341 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 3 Jan 2021 19:49:00 +0100 Subject: Fuse sendmail_path and mock mail config keys --- src/mail.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/mail.rs') diff --git a/src/mail.rs b/src/mail.rs index d86cff3..52b5789 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -14,7 +14,17 @@ pub fn send( ) -> bool { match prepare_email(to.clone(), subject.clone(), message.clone()) { Ok(email) => { - if config.mock_mails { + if let Some(sendmail_path) = &config.sendmail_path { + let mut sender = + SendmailTransport::new_with_command(sendmail_path); + match sender.send(email) { + Ok(_) => true, + Err(err) => { + error!("Error sending email: {:?}", err); + false + } + } + } else { let formatted_to = to .into_iter() .map(|t| t.0) @@ -25,16 +35,6 @@ pub fn send( formatted_to, subject, message ); true - } else { - let mut sender = - SendmailTransport::new_with_command(&config.sendmail_path); - match sender.send(email) { - Ok(_) => true, - Err(err) => { - error!("Error sending email: {:?}", err); - false - } - } } } Err(err) => { -- cgit v1.2.3