fix(email): send IMAP ID extension to support 163/NetEase mailbox (salvage #22528)#22796
Merged
Conversation
163/NetEase IMAP servers reject every UID SEARCH/FETCH with `BYE Unsafe Login` unless the client first identifies itself via the RFC 2971 ID command after LOGIN. Without this, the email gateway logs in OK but then fails on the very first poll and the connection is torn down. Send the ID payload best-effort after both `imap.login()` sites (`EmailAdapter.connect` and `_fetch_new_messages`). Failures are swallowed at debug level so non-supporting IMAP servers (Gmail, Outlook, Fastmail, Yahoo, etc.) keep working unchanged. Closes #22271
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
gateway/platforms/email.py:80: [invalid-assignment] invalid-assignment: Object of type `Literal["0"]` is not assignable to `Literal["0.13.0"]`
✅ Fixed issues: none
Unchanged: 4180 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
19 tasks
19 tasks
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.
Summary
Salvage of #22528 — Hermes' email gateway sends an RFC 2971 IMAP ID command after LOGIN, unblocking 163.com / NetEase IMAP polling that requires client identification before any UID SEARCH/FETCH.
Root cause
163's IMAP server enforces RFC 2971 ID identification after LOGIN. Without it, the next operation returns
BYE Unsafe Login. Please contact kefu@188.comand disconnects. Hermes' email gateway calledimap.login()directly intoimap.select("INBOX")+imap.uid("search", ...)with no ID handshake → polling failed on every cycle.Changes (contributor commits)
gateway/platforms/email.py: new module-level_send_imap_id(imap)helper issuesimap.xatom("ID", '("name" "hermes-agent" "version" "<v>" "vendor" "NousResearch" "support-email" "noreply@nousresearch.com")')after LOGIN. Best-effort try/except so non-supporting servers (Gmail, Outlook, etc.) keep working with debug logging on failure. Called at both login sites:EmailAdapter.connect()and the polling pathEmailAdapter._fetch_new_messages().hermes_cli.__version__(fallback"0"if import fails).tests/gateway/test_email.py: 3 regression tests (post-login ordering check, polling-path coverage, error-tolerance for non-supporting servers).Validation
tests/gateway/test_email.pypass overall.Closes #22271 via salvage.