fix(smtp): handle failed smtp connections

This commit is contained in:
dignifiedquire
2019-05-14 22:42:45 +02:00
parent 1f562357e2
commit ed79e5256f

View File

@@ -133,15 +133,24 @@ impl Smtp {
lettre::smtp::ClientSecurity::Wrapper(tls_parameters) lettre::smtp::ClientSecurity::Wrapper(tls_parameters)
}; };
let client = lettre::smtp::SmtpClient::new((domain, port), security) match lettre::smtp::SmtpClient::new((domain, port), security) {
.expect("failed to construct stmp client") Ok(client) => {
.smtp_utf8(true) let client = client
.credentials(creds) .smtp_utf8(true)
.connection_reuse(lettre::smtp::ConnectionReuseParameters::ReuseUnlimited); .credentials(creds)
.connection_reuse(lettre::smtp::ConnectionReuseParameters::ReuseUnlimited);
self.transport = Some(client.transport()); self.transport = Some(client.transport());
1
1 }
Err(err) => {
warn!(
context,
0,
format!("SMTP: failed to establish connection {:?}", err)
);
0
}
}
} }
pub fn send<'a>( pub fn send<'a>(