hermes - ✅(Solved) Fix [Bug]: 163.com email address doesn't work for gateway email platform [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#13558Fetched 2026-04-22 08:05:50
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1

Error Message

Configuring a 163.com email in hermes setup gateway, then starting the gateway, the email platform failed IMAP connection, error log:

Additional Logs / Traceback (optional)

Root Cause

The root cause was that 163.com requires sending a IMAP ID, though that's optional by standard. See ref

Fix Action

Fixed

PR fix notes

PR #13564: fix(gateway): add IMAP ID extension and SMTP port 465 support

Description (problem / solution / changelog)

What does this PR do?

  • Add RFC 2971 IMAP ID extension support for providers that require client identification (notably 163.com)
  • Fix SMTP connection to properly handle implicit TLS on port 465 per RFC 8314

Platforms Tested

  • macOS (local development)
  • Raspberry Pi 4B (Docker container)

Notes

  • The IMAP ID command is sent after every login to ensure compatibility
  • ID command failures are logged but don't fail the connection (it's optional per RFC)

Related Issue

https://github.com/NousResearch/hermes-agent/issues/13558

Fixes #

Type of Change

<!-- Check the one that applies. -->
  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

<!-- List the specific changes. Include file paths for code changes. -->

IMAP ID Extension (RFC 2971)

Some mail servers (notably 163.com) reject connections as "Unsafe Login" if the client doesn't identify itself via the IMAP ID command after login. This PR adds _send_imap_id() which:

  • Checks if the server advertises ID capability
  • Sends a minimal client identity
  • Gracefully skips if ID is not supported (per RFC, it's optional)

SMTP Connection Fix (RFC 8314)

Previously, the code always used STARTTLS regardless of port. Per RFC 8314:

  • Port 465 should use implicit TLS (SMTP_SSL)
  • Port 587 should use STARTTLS

This fixes connection issues with providers like 163.com that use port 465 for SMTP.

How to Test

<!-- Steps to verify this change works. For bugs: reproduction steps + proof that the fix works. -->
  1. Setup 163.com email in hermes setup gateway
  2. Add EMAIL_SMTP_PORT=465 to ~/.hermes/.env
  3. IMAP login now succeeds (previously failed with "Unsafe Login"); SMTP send works correctly on port 465
  4. All existing email tests pass in tests/gateway/test_email.py

Checklist

<!-- Complete these before requesting review. -->

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
    • Some (82) tests failed, all unrelated to this change
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: <!-- e.g. Ubuntu 24.04, macOS 15.2, Windows 11 -->

Documentation & Housekeeping

<!-- Check all that apply. It's OK to check "N/A" if a category doesn't apply to your change. -->
  • [N/A] I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • [N/A] I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • [N/A] I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • [N/A] I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

<!-- Only fill this out if you're adding a skill. Delete this section otherwise. -->
  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

<!-- If applicable, add screenshots or log output showing the fix/feature in action. -->

Changed files

  • gateway/platforms/email.py (modified, +77/-7)
  • tests/gateway/test_email.py (modified, +72/-0)

Code Example

IMAP connection failed: command SEARCH illegal in state AUTH, only allowed in states SELECTED

---

N/A

---
RAW_BUFFERClick to expand / collapse

Bug Description

Configuring a 163.com email in hermes setup gateway, then starting the gateway, the email platform failed IMAP connection, error log:

IMAP connection failed: command SEARCH illegal in state AUTH, only allowed in states SELECTED

The root cause was that 163.com requires sending a IMAP ID, though that's optional by standard. See ref

Also, 163.com's SMTP server uses port 465, requiring implicit TLS. The current implementation always use STARTTLS.

Steps to Reproduce

  1. Configure a 163.com email in hermes setup gateway
  2. Start gateway hermes gateway run

Expected Behavior

Email is connected normally

Actual Behavior

Email connection failed: IMAP connection failed: command SEARCH illegal in state AUTH, only allowed in states SELECTED

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

No response

Debug Report

N/A

Operating System

Raspberry Pi OS

Python Version

3.11.2

Hermes Version

Hermes Agent v0.10.0 (2026.4.16)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

Modify the IMAP connection to send an IMAP ID and use implicit TLS on port 465 for 163.com email configuration.

Guidance

  • Update the hermes setup gateway configuration to include the IMAP ID as required by 163.com.
  • Change the SMTP server configuration to use implicit TLS on port 465 instead of STARTTLS.
  • Verify the IMAP connection by checking the email platform logs for successful connections after applying the changes.
  • Test the gateway with the updated configuration to ensure email connections are established correctly.

Example

No code snippet is provided as the issue does not specify the exact configuration files or code that needs to be modified.

Notes

The fix may require updates to the Hermes Agent code to accommodate the specific requirements of 163.com's email servers. The provided information only mentions the need for an IMAP ID and implicit TLS, but the actual implementation details are not specified.

Recommendation

Apply workaround: Modify the IMAP connection settings to meet 163.com's requirements, as the current implementation does not support the necessary configuration options. This will allow for a temporary fix until a more permanent solution can be implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: 163.com email address doesn't work for gateway email platform [1 pull requests, 1 participants]