actually try connecting, instead of just preparing the connect

This commit is contained in:
holger krekel
2019-10-21 22:26:12 +02:00
parent 4b24f32d6c
commit e17c69f89c
2 changed files with 24 additions and 16 deletions

View File

@@ -116,18 +116,27 @@ impl Smtp {
.credentials(creds)
.authentication_mechanism(mechanism)
.connection_reuse(lettre::smtp::ConnectionReuseParameters::ReuseUnlimited);
self.transport = Some(client.transport());
context.call_cb(Event::SmtpConnected(format!(
"SMTP-LOGIN as {} ok",
lp.send_user,
)));
true
let mut trans = client.transport();
match trans.connect() {
Ok(()) => {
self.transport = Some(trans);
self.transport_connected = true;
context.call_cb(Event::SmtpConnected(format!(
"SMTP-LOGIN as {} ok",
lp.send_user,
)));
return true;
}
Err(err) => {
warn!(context, "SMTP: failed to connect {:?}", err);
}
}
}
Err(err) => {
warn!(context, "SMTP: failed to establish connection {:?}", err);
false
warn!(context, "SMTP: failed to setup connection {:?}", err);
}
}
false
}
/// SMTP-Send a prepared mail to recipients.