aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2021-01-03 19:49:00 +0100
committerJoris2021-01-03 19:49:00 +0100
commit6a03a75674c4f11b56f46161dfb44a5ce8e51341 (patch)
treeadc716e5dc3002e2f25bfd15567025535f35e74b
parent406767e9eed613b5a1513ada772e4bfb78e46290 (diff)
downloadbudget-6a03a75674c4f11b56f46161dfb44a5ce8e51341.tar.gz
budget-6a03a75674c4f11b56f46161dfb44a5ce8e51341.tar.bz2
budget-6a03a75674c4f11b56f46161dfb44a5ce8e51341.zip
Fuse sendmail_path and mock mail config keys
-rw-r--r--config.json3
-rw-r--r--src/mail.rs22
-rw-r--r--src/model/config.rs3
3 files changed, 13 insertions, 15 deletions
diff --git a/config.json b/config.json
index 488b2f9..86a19b5 100644
--- a/config.json
+++ b/config.json
@@ -1,4 +1,3 @@
{
- "secure_cookies": false,
- "mock_mails": true
+ "secure_cookies": false
}
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) => {
diff --git a/src/model/config.rs b/src/model/config.rs
index 8d304e5..2c5455e 100644
--- a/src/model/config.rs
+++ b/src/model/config.rs
@@ -3,6 +3,5 @@ use serde::Deserialize;
#[derive(Clone, Deserialize)]
pub struct Config {
pub secure_cookies: bool,
- pub mock_mails: bool,
- pub sendmail_path: String,
+ pub sendmail_path: Option<String>,
}