Skip to content

auth: prefer AUTH LOGIN over PLAIN when the server advertises both - #242

Open
LeoneNee wants to merge 1 commit into
yc-software:mainfrom
LeoneNee:smtp-login-preferred
Open

auth: prefer AUTH LOGIN over PLAIN when the server advertises both#242
LeoneNee wants to merge 1 commit into
yc-software:mainfrom
LeoneNee:smtp-login-preferred

Conversation

@LeoneNee

@LeoneNee LeoneNee commented Aug 6, 2026

Copy link
Copy Markdown

Problem

authSteps prefers 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 an AUTH PLAIN attempt with 502 Invalid input / 535 Login fail yet completes AUTH LOGIN with 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

  • The fake SMTP server in smtp.test.ts now speaks the LOGIN challenge-response (334 base64 prompts) instead of treating every AUTH line as one-shot.
  • The delivery and verification tests assert the LOGIN transcript (AUTH LOGIN, base64 username, base64 password).
  • A new case covers a server advertising only PLAIN, keeping the fallback path covered.

All 8 tests in plugins/auth/test/smtp.test.ts pass. The fix was also verified against a live QQ Mail account: AUTH LOGIN completes (235 Authentication successful) where AUTH PLAIN is rejected.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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
LeoneNee force-pushed the smtp-login-preferred branch from 952f753 to 4258819 Compare August 6, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant