mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 08:16:32 +03:00
smtp: add more logging
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- add more SMTP logging #3093
|
||||||
|
|
||||||
|
|
||||||
## 1.76.0
|
## 1.76.0
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|||||||
25
src/smtp.rs
25
src/smtp.rs
@@ -225,7 +225,7 @@ pub(crate) async fn smtp_send(
|
|||||||
let status = match send_result {
|
let status = match send_result {
|
||||||
Err(crate::smtp::send::Error::SmtpSend(err)) => {
|
Err(crate::smtp::send::Error::SmtpSend(err)) => {
|
||||||
// Remote error, retry later.
|
// Remote error, retry later.
|
||||||
warn!(context, "SMTP failed to send: {:?}", &err);
|
info!(context, "SMTP failed to send: {:?}", &err);
|
||||||
|
|
||||||
let res = match err {
|
let res = match err {
|
||||||
async_smtp::smtp::error::Error::Permanent(ref response) => {
|
async_smtp::smtp::error::Error::Permanent(ref response) => {
|
||||||
@@ -252,8 +252,10 @@ pub(crate) async fn smtp_send(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if maybe_transient {
|
if maybe_transient {
|
||||||
|
info!(context, "Permanent error that is likely to actually be transient, postponing retry for later");
|
||||||
Status::RetryLater
|
Status::RetryLater
|
||||||
} else {
|
} else {
|
||||||
|
info!(context, "Permanent error, message sending failed");
|
||||||
// If we do not retry, add an info message to the chat.
|
// If we do not retry, add an info message to the chat.
|
||||||
// Yandex error "554 5.7.1 [2] Message rejected under suspicion of SPAM; https://ya.cc/..."
|
// Yandex error "554 5.7.1 [2] Message rejected under suspicion of SPAM; https://ya.cc/..."
|
||||||
// should definitely go here, because user has to open the link to
|
// should definitely go here, because user has to open the link to
|
||||||
@@ -277,23 +279,38 @@ pub(crate) async fn smtp_send(
|
|||||||
info!(context, "Received extended status code {} for a transient error. This looks like a misconfigured smtp server, let's fail immediatly", first_word);
|
info!(context, "Received extended status code {} for a transient error. This looks like a misconfigured smtp server, let's fail immediatly", first_word);
|
||||||
Status::Finished(Err(format_err!("Permanent SMTP error: {}", err)))
|
Status::Finished(Err(format_err!("Permanent SMTP error: {}", err)))
|
||||||
} else {
|
} else {
|
||||||
|
info!(
|
||||||
|
context,
|
||||||
|
"Transient error with status code {}, postponing retry for later",
|
||||||
|
first_word
|
||||||
|
);
|
||||||
Status::RetryLater
|
Status::RetryLater
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
info!(
|
||||||
|
context,
|
||||||
|
"Transient error without status code, postponing retry for later"
|
||||||
|
);
|
||||||
Status::RetryLater
|
Status::RetryLater
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
info!(
|
||||||
|
context,
|
||||||
|
"Message sending failed without error returned by the server"
|
||||||
|
);
|
||||||
if smtp.has_maybe_stale_connection().await {
|
if smtp.has_maybe_stale_connection().await {
|
||||||
info!(context, "stale connection? immediately reconnecting");
|
info!(context, "Connection is probably stale, retry immediately");
|
||||||
Status::RetryNow
|
Status::RetryNow
|
||||||
} else {
|
} else {
|
||||||
|
info!(context, "Connection is not stale, retry later");
|
||||||
Status::RetryLater
|
Status::RetryLater
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// this clears last_success info
|
// this clears last_success info
|
||||||
|
info!(context, "Failed to send message over SMTP, disconnecting");
|
||||||
smtp.disconnect().await;
|
smtp.disconnect().await;
|
||||||
|
|
||||||
res
|
res
|
||||||
@@ -384,6 +401,10 @@ pub(crate) async fn send_msg_to_smtp(
|
|||||||
.context("failed to remove message with exceeded retry limit from smtp table")?;
|
.context("failed to remove message with exceeded retry limit from smtp table")?;
|
||||||
bail!("Number of retries exceeded the limit");
|
bail!("Number of retries exceeded the limit");
|
||||||
}
|
}
|
||||||
|
info!(
|
||||||
|
context,
|
||||||
|
"Retry number {} to send message {} over SMTP", retries, msg_id
|
||||||
|
);
|
||||||
|
|
||||||
let recipients_list = recipients
|
let recipients_list = recipients
|
||||||
.split(' ')
|
.split(' ')
|
||||||
|
|||||||
Reference in New Issue
Block a user