diff options
-rw-r--r-- | readme.md | 9 | ||||
-rw-r--r-- | src/mail.rs | 11 | ||||
-rw-r--r-- | src/main.rs | 2 |
3 files changed, 14 insertions, 8 deletions
@@ -21,8 +21,8 @@ bind: 127.0.0.1:8000 interval: 60 # check interval in seconds mail: # the entire mail section is optional - from: status@example.org - to: [admin@example.org] + mail_from: status@example.org + mail_to: [admin@example.org] smtp_auth: !plain # can be !plain, !starttls or !tls smtp_server: 127.0.0.1 smtp_port: 8025 @@ -40,6 +40,11 @@ services: - !http { url: https://meet.metamuffin.org/ } # this checks that status code of a HTTP request for success - title: failing service + mail_to: [bob@example.org] # for this service, bob will be notified too checks: - !shell { title: "Do nothing unsuccessfully", command: "false" } # this runs a command and checks the exit code ``` + +## License + +AGPL-3.0-only; See `COPYING`. diff --git a/src/mail.rs b/src/mail.rs index 841b552..d6a22b1 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -12,8 +12,8 @@ use crate::Config; #[derive(Debug, Deserialize)] pub struct MailConfig { - from: String, - to: Vec<String>, + mail_from: String, + mail_to: Vec<String>, smtp_auth: SmtpAuth, smtp_port: u16, smtp_timeout: Option<f64>, @@ -59,11 +59,10 @@ pub async fn send_mail( } let transport = transport.build(); - for recipient in &mconfig.to { - let service = &config.services[service]; - + let service = &config.services[service]; + for recipient in mconfig.mail_to.iter().chain(service.mail_to.iter()) { let message = Message::builder() - .from(Mailbox::from_str(&mconfig.from)?) + .from(Mailbox::from_str(&mconfig.mail_from)?) .to(Mailbox::from_str(&recipient)?) .subject(format!("{} failed.", service.title)) .body(format!( diff --git a/src/main.rs b/src/main.rs index ff6357f..7f55089 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,8 @@ pub struct Service { title: String, url: Option<String>, checks: Vec<Check>, + #[serde(default)] + mail_to: Vec<String>, } #[derive(Debug, Clone)] |