25be5e2120
_send_imap_id() sent RFC 2971 ID unconditionally after login (a 163/NetEase requirement). Servers without the extension can react badly: Purelymail answers with an untagged '* BYE Unknown command.' and closes the connection, which imaplib cannot surface at the call site — the failure appears one command later as 'IMAP connection failed: command: SELECT => Unknown command.' and the adapter retries forever. Gate the ID send on the server's advertised capabilities (imap.capabilities, populated by imaplib at connect), keeping the existing exception handler for servers that advertise ID but reject it. Ports PR #39861 to the current plugin layout, as requested by the hermes-sweeper review there. Fixes #39856 Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>