Repository navigation
Conversation
A 5xx reply (e.g. "554 5.7.1 Client host rejected") was mapped to the generic SendFailed error, which the outbox worker treats as retryable, so the message sat in the Outbox for five attempts with exponential backoff before being marked failed. Map permanent SMTP errors (lettre's is_permanent) to a new SmtpError::Rejected and exclude it in is_retryable, so the entry is marked failed immediately with the server's reason. Transient (4xx) and connection errors are still retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
When the SMTP server permanently rejects a message (a 5xx reply), the outbox
worker treats it as a transient failure. The message stays in the Outbox for
5 attempts with exponential backoff (30 s … 4 min) before it is finally
marked failed, although every retry gets the same rejection.
Seen in practice with a Postfix submission policy rejecting the client:
lettre already classifies this reply as permanent, but
SmtpClientmapped itto the generic
SmtpError::SendFailed, whichis_retryabletreats asretryable.
Change
SmtpError::Rejected(String): new variant for permanent (5xx) replies,detected with lettre's
Error::is_permanent(). Authentication failures arestill classified first as
AuthenticationFailed.is_retryableexcludesRejected, so the outbox entry is markedfailedright away, with the server's reason as
fail_reason.Tests
is_retryable: transient errors are retryable; permanentrejections and auth failures are not.
SmtpErrordisplay test extended withRejected.cargo test: all pass.Note: CI clippy currently fails on
mainwith Rust 1.99 for unrelatedreasons; that's fixed separately in fix/clippy-rust-1.99.
🤖 Generated with Claude Code