X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2Fmain.rs;h=08039fb26eb442810a7783296bae277554d5cf70;hb=8ff916896124ea900ea2c6b66c87e6cc72ffe1eb;hp=43ecb4affcc874719394d0602d89d976375cface;hpb=19671d1006f19d4a9fbdb1800ffb9e992fd3976d;p=stakingWatchdog.git diff --git a/src/main.rs b/src/main.rs index 43ecb4a..08039fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,6 +62,7 @@ fn main() -> Result<()> { match send_email( "Watchdog: Staking error", &format!("Error: {}", error), + &config.smtp_relay_address, &config.smtp_login, &config.smtp_password, ) { @@ -245,7 +246,13 @@ fn check_validators(pub_keys: &[String]) -> std::result::Result<(), CheckError> 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 ".parse()?) @@ -256,12 +263,10 @@ fn send_email(title: &str, body: &str, login: &str, pass: &str) -> Result<()> { 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(); - // Send the email let response = mailer.send(&email)?; println!("{:?}", response);