mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
fix: Show root SMTP connection failure in connectivity view (#6121)
Right now, when there is an SMTP connection error, the connectivity view will always show "Error: SMTP connection failure: SMTP failed to connect". Instead, I just used the same method that is used in imap connect() already.
This commit is contained in:
@@ -126,6 +126,7 @@ impl Smtp {
|
|||||||
|
|
||||||
let login_params =
|
let login_params =
|
||||||
prioritize_server_login_params(&context.sql, login_params, "smtp").await?;
|
prioritize_server_login_params(&context.sql, login_params, "smtp").await?;
|
||||||
|
let mut first_error = None;
|
||||||
for lp in login_params {
|
for lp in login_params {
|
||||||
info!(context, "SMTP trying to connect to {}.", &lp.connection);
|
info!(context, "SMTP trying to connect to {}.", &lp.connection);
|
||||||
let transport = match connect::connect_and_auth(
|
let transport = match connect::connect_and_auth(
|
||||||
@@ -143,6 +144,7 @@ impl Smtp {
|
|||||||
Ok(transport) => transport,
|
Ok(transport) => transport,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(context, "SMTP failed to connect and authenticate: {err:#}.");
|
warn!(context, "SMTP failed to connect and authenticate: {err:#}.");
|
||||||
|
first_error.get_or_insert(err);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -157,7 +159,7 @@ impl Smtp {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(format_err!("SMTP failed to connect"))
|
Err(first_error.unwrap_or_else(|| format_err!("No SMTP connection candidates provided")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user