Skip to content

fix(exterrors): Keep 4.x.x enhanced code for temporary errors in SMTPEnchCode - #903

Open
kabeer7121 wants to merge 1 commit into
foxcpp:masterfrom
kabeer7121:fix/smtp-ench-code-temporary
Open

kabeer7121 wants to merge 1 commit into
foxcpp:masterfrom
kabeer7121:fix/smtp-ench-code-temporary

Conversation

@kabeer7121

Copy link
Copy Markdown
Contributor

SMTPEnchCode sets the first digit to 4 for temporary errors but then always overwrites it with 5:

if IsTemporary(err) {
    code[0] = 4
}
code[0] = 5

So every caller gets a 5.x.x enhanced code, even when SMTPCode picked a 4xx basic code for the same error. In target/remote that shows up as 451 5.4.0 No usable MXs, last err: ... for connection refused / no route to host, which is one of the cases reported in #893. The other callers (MX lookup, DNS errors in smtpconn, etc.) have the same mismatch.

This only sets 5 when the error is not temporary, and adds a small test for SMTPEnchCode. It doesn't change which errors are treated as temporary, so it's only part of #893.

Tested with go test ./framework/exterrors/ ./internal/target/remote/ ./internal/smtpconn/ (the new test fails without the fix).

…EnchCode

SMTPEnchCode set the class digit to 4 for temporary errors and then
unconditionally overwrote it with 5, so every caller got a 5.x.x
enhanced code. For remote delivery this produced replies like
"451 5.4.0 No usable MXs" where the basic code says retry and the
enhanced code says permanent failure.

Only set 5 when the error is not temporary.

Refs foxcpp#893

Signed-off-by: Kabeer Ahmed <kabeerahmed7121@gmail.com>
@foxcpp

foxcpp commented Nov 13, 2026

Copy link
Copy Markdown
Owner

FYI Contributions written by LLMs must have Signed-Off-By trailer in commit description to indicate your agreement to the Developer Certificate of Origin.
https://github.com/foxcpp/maddy/blob/master/.github/CONTRIBUTING.md#llm-policy

@foxcpp foxcpp moved this from First Feedback Needed to Changes Needed in Maddy Mail Server PR Review Nov 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Changes Needed

Development

Successfully merging this pull request may close these issues.

2 participants