Repository navigation
refactor(smtp): introduce smtp::Connection structure - #8803
Merged
Merged
Conversation
link2xt
force-pushed
the
link2xt/smtp-connection-single-option
branch
from
October 6, 2026 20:53
5d46f4c to
1ae87aa
Compare
link2xt
added this pull request to stack #8807
October 7, 2026 02:46
link2xt
force-pushed
the
link2xt/smtp-connection-single-option
branch
2 times, most recently
from
October 7, 2026 12:47
18e098e to
368bfac
Compare
link2xt
marked this pull request as ready for review
October 7, 2026 12:48
link2xt
force-pushed
the
link2xt/smtp-connection-single-option
branch
5 times, most recently
from
October 9, 2026 21:18
be16966 to
6158cee
Compare
Hocuri
approved these changes
Oct 12, 2026
Hocuri
left a comment
Collaborator
There was a problem hiding this comment.
Nice refactoring, good to clean up some old code
Comment on lines
+355
to
+361
| let transport_id = connection.transport_id; | ||
| if let Err(err) = record_success(context, transport_id).await { | ||
| warn!( | ||
| context, | ||
| "Failed to record successful use of transport {transport_id} in smtp_success table: {err:#}." | ||
| ); | ||
| } |
Collaborator
There was a problem hiding this comment.
Nit: I find log_err easier to read than if let Err … warn!, since if let Err … warn! 'hides' the most important thing, namely the call to record_success.
Suggested change
| let transport_id = connection.transport_id; | |
| if let Err(err) = record_success(context, transport_id).await { | |
| warn!( | |
| context, | |
| "Failed to record successful use of transport {transport_id} in smtp_success table: {err:#}." | |
| ); | |
| } | |
| record_success(context, connection.transport_id) | |
| .await | |
| .with_context(|| { | |
| format!("Failed to record successful use of transport {transport_id}") | |
| }) | |
| .log_err(context) | |
| .ok(); |
| let send_result = connection | ||
| .send(context, recipients, message.as_bytes()) | ||
| .await; | ||
| smtp.last_send_error = send_result.as_ref().err().map(|e| e.to_string()); |
Collaborator
There was a problem hiding this comment.
This needs to use the alternate formatting now, otherwise the .context("Envelope error")? will swallow the inner error
Suggested change
| smtp.last_send_error = send_result.as_ref().err().map(|e| e.to_string()); | |
| smtp.last_send_error = send_result.as_ref().err().map(|e| format!("{e:#}")); |
Comment on lines
14
to
19
| pub enum Error { | ||
| #[error("Envelope error: {}", _0)] | ||
| Envelope(anyhow::Error), | ||
| #[error("Send error: {}", _0)] | ||
| SmtpSend(async_smtp::error::Error), | ||
| #[error("SMTP has no transport")] | ||
| NoTransport, | ||
| #[error("{}", _0)] | ||
| Other(#[from] anyhow::Error), | ||
| } |
Collaborator
There was a problem hiding this comment.
...or maybe this is where we need to use the alternate formatting? Anyways, can't hurt to use it in both places.
pub enum Error {
#[error("Send error: {:#}", _0)]
SmtpSend(async_smtp::error::Error),
#[error("{:#}", _0)]
Other(#[from] anyhow::Error),
}(Github doesn't support to post this as a suggestion, since there are deleted lines in the diff)
It is now impossible for SMTP client to be connected without having a From address and transport_id available. Follow-up to 7073049
link2xt
force-pushed
the
link2xt/smtp-connection-single-option
branch
from
October 12, 2026 22:22
6158cee to
cb6a92a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It is now impossible for SMTP client to be connected without having a From address and transport_id available.
Follow-up to 7073049