feat: improve SMTP logging

This commit is contained in:
link2xt
2023-05-10 14:41:58 +00:00
parent c7a250da31
commit 991089d98e
2 changed files with 9 additions and 5 deletions

View File

@@ -552,7 +552,7 @@ pub(crate) async fn send_msg_to_smtp(
} }
info!( info!(
context, context,
"Try number {} to send message {} over SMTP", retries, msg_id "Try number {retries} to send message {msg_id} (entry {rowid}) over SMTP"
); );
let recipients_list = recipients let recipients_list = recipients
@@ -576,7 +576,7 @@ pub(crate) async fn send_msg_to_smtp(
{ {
info!( info!(
context, context,
"Sending of message {} was cancelled by the user.", msg_id "Sending of message {msg_id} (entry {rowid}) was cancelled by the user."
); );
return Ok(()); return Ok(());
} }
@@ -649,6 +649,8 @@ pub(crate) async fn send_smtp_messages(context: &Context, connection: &mut Smtp)
}, },
) )
.await?; .await?;
info!(context, "Selected rows from SMTP queue: {rowids:?}.");
for rowid in rowids { for rowid in rowids {
send_msg_to_smtp(context, connection, rowid) send_msg_to_smtp(context, connection, rowid)
.await .await

View File

@@ -64,9 +64,11 @@ impl Smtp {
if let Some(ref mut transport) = self.transport { if let Some(ref mut transport) = self.transport {
transport.send(mail).await.map_err(Error::SmtpSend)?; transport.send(mail).await.map_err(Error::SmtpSend)?;
context.emit_event(EventType::SmtpMessageSent(format!( let info_msg = format!(
"Message len={message_len_bytes} was smtp-sent to {recipients_display}" "Message len={message_len_bytes} was SMTP-sent to {recipients_display}"
))); );
info!(context, "{info_msg}.");
context.emit_event(EventType::SmtpMessageSent(info_msg));
self.last_success = Some(std::time::SystemTime::now()); self.last_success = Some(std::time::SystemTime::now());
} else { } else {
warn!( warn!(