Skip to content

imaplib problem with the "Enable" capability #103451

Description

@yerazy

Bug report

When connecting to gmail via imaplib, you can't use mail.enable("UTF8=ACCEPT"), it always returns the error "imaplib.IMAP4.error: Server does not support ENABLE". But the server returns both "Enable" and "UTF8=ACCEPT" in capabilities. I commented out the line in imaplib, which causes this error, and everything works correctly. For some reason these parameters are not passed to capabilities.

Your environment

Python 3.11.3, Win 10 21H2 19044.1288

#Code

import imaplib

mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.debug = 4
mail.login("login@gmail.com","password")
print(mail.capabilities)
mail.enable("UTF8=ACCEPT")
mail.select("inbox")
Console output
  01:49.56 > b'PIGH1 LOGIN login@gmail.com "password"'
  01:50.64 < b'* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584'
  01:50.64 < b'PIGH1 OK login@gmail.com authenticated (Success)'
('IMAP4REV1', 'UNSELECT', 'IDLE', 'NAMESPACE', 'QUOTA', 'ID', 'XLIST', 'CHILDREN', 'X-GM-EXT-1', 'XYZZY', 'SASL-IR', 'AUTH=XOAUTH2', 'AUTH=PLAIN', 'AUTH=PLAIN-CLIENTTOKEN', 'AUTH=OAUTHBEARER', 'AUTH=XOAUTH')
Traceback (most recent call last):
  File "path\pyd.py", line 11, in <module>
    mail.enable("UTF8=ACCEPT")
  File "path\AppData\Local\Programs\Python\Python311\Lib\imaplib.py", line 517, in enable
    raise IMAP4.error("Server does not support ENABLE")
imaplib.IMAP4.error: Server does not support ENABLE

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    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