auth: prefer AUTH LOGIN over PLAIN when the server advertises both - #242
Open
LeoneNee wants to merge 1 commit into
Open
auth: prefer AUTH LOGIN over PLAIN when the server advertises both#242LeoneNee wants to merge 1 commit into
LeoneNee wants to merge 1 commit into
Conversation
Servers that list PLAIN but reject it on use (observed with QQ Mail, which answers PLAIN with 502/535 yet completes LOGIN) made sign-in email delivery fail even with valid credentials. Try LOGIN first and fall back to PLAIN only when LOGIN is not advertised. The fake SMTP server in the tests now speaks the LOGIN challenge-response and a PLAIN-only case keeps the fallback covered.
LeoneNee
force-pushed
the
smtp-login-preferred
branch
from
August 6, 2026 07:23
952f753 to
4258819
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.
Problem
authStepsprefers AUTH PLAIN whenever the server advertises it. Some servers list PLAIN in their EHLO capabilities but reject it in practice — observed with QQ Mail (smtp.qq.com), which answers anAUTH PLAINattempt with502 Invalid input/535 Login failyet completesAUTH LOGINwith the same credentials. Sign-in email delivery fails with valid credentials and no recourse, because PLAIN is always picked when advertised.Change
Try AUTH LOGIN first; fall back to PLAIN only when LOGIN is not advertised. LOGIN is a single extra round trip and is accepted everywhere PLAIN is, so preferring it strictly widens server compatibility.
Tests
smtp.test.tsnow speaks the LOGIN challenge-response (334base64 prompts) instead of treating everyAUTHline as one-shot.AUTH LOGIN, base64 username, base64 password).All 8 tests in
plugins/auth/test/smtp.test.tspass. The fix was also verified against a live QQ Mail account:AUTH LOGINcompletes (235 Authentication successful) whereAUTH PLAINis rejected.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.