diff --git a/src/mail.rs b/src/mail.rs index 77eb2ac..7a3c660 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -18,21 +18,21 @@ use chrono::NaiveDateTime; fn mailer() -> SmtpTransport { let host = CONFIG.smtp_host().unwrap(); + let tls = TlsConnector::builder() + .min_protocol_version(Some(Protocol::Tlsv11)) + .build() + .unwrap(); + + let tls_params = ClientTlsParameters::new(host.clone(), tls); + let client_security = if CONFIG.smtp_ssl() { - let tls = TlsConnector::builder() - .min_protocol_version(Some(Protocol::Tlsv11)) - .build() - .unwrap(); - - let params = ClientTlsParameters::new(host.clone(), tls); - if CONFIG.smtp_explicit_tls() { - ClientSecurity::Wrapper(params) + ClientSecurity::Wrapper(tls_params) } else { - ClientSecurity::Required(params) + ClientSecurity::Required(tls_params) } } else { - ClientSecurity::None + ClientSecurity::Opportunistic(tls_params) }; use std::time::Duration;