Skip to content

163 mailbox IMAP connection fails - Missing IMAP ID extension support #22271

@Atayal580127

Description

@Atayal580127

Bug Description

When connecting to 163 mailbox (NetEase) via IMAP, the connection fails with error:

Unsafe Login. Please contact kefu@188.com for help

Root Cause

163 mailbox requires IMAP ID extension (RFC 2971) to be sent after login. The client must identify itself with name, version, vendor, support-email fields.

Without sending the ID command after store.connect(), 163 treats the client as "unsafe" and blocks the connection.

Official Requirement (from 163 help center)

When using IMAP protocol, the system requires your client to provide identity information before allowing connection.

163 provides Java example:

HashMap IAM = new HashMap();
IAM.put("name","myname");
IAM.put("version","1.0.0");
IAM.put("vendor","myclient");
IAM.put("support-email","testmail@test.com");

store.connect("test@163.com", "auth_code");
store.id(IAM);  // ← Must be called after connect()

Reference: https://www.ietf.org/rfc/rfc2971.txt

Expected Behavior

Hermes Agent's email platform should:

  1. Detect if the IMAP server supports ID extension (CAPABILITY ID)
  2. After successful login, automatically send ID command with client identity
  3. Allow users to configure identity fields in config.yaml or .env

Current Behavior

IMAP login succeeds, but 163 immediately blocks subsequent operations with "Unsafe Login" error. SMTP works fine (using auth code).

Environment

  • Hermes Agent version: v0.13.0 (2026.5.7)
  • Email provider: 163.com (NetEase)
  • IMAP server: imap.163.com:993 (SSL)
  • Auth method: Authorization code (not password)

Suggested Fix

In hermes_agent/platforms/email/imap_client.py (or equivalent):

import imaplib

# Add ID command support
imaplib.Commands["ID"] = "AUTH"

# After login
conn = imaplib.IMAP4_SSL("imap.163.com", 993)
conn.login(user, password)

# Send ID (required by 163)
conn._simple_command("ID", '("name" "hermes-agent" "version" "0.13.0" "vendor" "NousResearch" "support-email" "contact@nousresearch.com")')

Additional Context

Feature Request

Add a configuration option in config.yaml:

email:
  imap_id:
    enabled: true
    name: "hermes-agent"
    version: "0.13.0"
    vendor: "NousResearch"
    support-email: "contact@nousresearch.com"

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/gatewayGateway runner, session dispatch, deliveryduplicateThis issue or pull request already existsplatform/emailEmail (IMAP/SMTP) adaptertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions