- // match request_builder
- // .header("Authorization", format!("Apikey {}", api_key))
- // .send()
- // {
- // Ok(resp) => {
- // if resp.status().is_success() {
- // let content = resp.text().unwrap();
- // Ok(serde_json::from_str(&content).unwrap())
- // } else {
- // Err(Box::new(Error {
- // message: format!("Request unsuccessful to {}: {:#?}", &url, resp),
- // }))
- // }
- // }
- // Err(error) => Err(Box::new(Error {
- // message: format!("Error during request to {}: {:?}", &url, error),
- // })),
- // }
-
- // 1) Check health.
-
- // 2) Check each validators.
+ Ok(())
+}
+
+fn send_email(title: &str, body: &str, login: &str, pass: &str) -> Result<()> {
+ let email = Message::builder()
+ .message_id(None)
+ .from("Staking Watchdog <redmine@d-lan.net>".parse()?)
+ .to("Greg Burri <greg.burri@gmail.com>".parse()?)
+ .subject(title)
+ .header(ContentType::TEXT_PLAIN)
+ .body(body.to_string())?;
+
+ let creds = Credentials::new(login.to_string(), pass.to_string());
+
+ // Open a remote connection to gmail
+ let mailer = SmtpTransport::relay("mail.gandi.net")?
+ .credentials(creds)
+ .build();
+
+ // Send the email
+ let response = mailer.send(&email)?;
+
+ println!("{:?}", response);