#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Config {
pub pub_keys: Vec<String>,
+ pub smtp_relay_address: String,
pub smtp_login: String,
pub smtp_password: String,
}
pub fn default() -> Self {
Config {
pub_keys: vec![],
+ smtp_relay_address: "mail.something.com".to_string(),
smtp_login: "login".to_string(),
smtp_password: "password".to_string(),
}
match send_email(
"Watchdog: Staking error",
&format!("Error: {}", error),
+ &config.smtp_relay_address,
&config.smtp_login,
&config.smtp_password,
) {
Ok(())
}
-fn send_email(title: &str, body: &str, login: &str, pass: &str) -> Result<()> {
+fn send_email(
+ title: &str,
+ body: &str,
+ smtp_relay_address: &str,
+ login: &str,
+ pass: &str,
+) -> Result<()> {
let email = Message::builder()
.message_id(None)
.from("Staking Watchdog <redmine@d-lan.net>".parse()?)
let creds = Credentials::new(login.to_string(), pass.to_string());
// Open a remote connection to gmail
- let mailer = SmtpTransport::relay("mail.infomaniak.com")?
+ let mailer = SmtpTransport::relay(smtp_relay_address)?
.credentials(creds)
.build();