FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Implementation of RFC 2971 for imaplib · Issue #98092 · python/cpython · GitHub

Repository navigation

Implementation of RFC 2971 for imaplib #98092

Closed

Description

Feature or enhancement

imaplib currently does not support RFC 2971

Pitch

This extension is easy to implement, and enables better debugging on the server side and statistics collection.

Previous discussion

None.

Linked PRs

Activity

  1. noudin-ledger commented on Oct 8, 2022

    Author

    I propose myself to implement this.

  2. ericvsmith commented on Oct 8, 2022

    Member

    Please give a brief description of the RFC.

  3. noudin-ledger commented on Oct 10, 2022

    Author

    Sure:

    RFC defines a new command ID.
    The sole purpose of the ID extension is to enable clients and servers to exchange information on their implementations for the purposes of statistical analysis and problem determination.
    ID command can be used by client to send an ID (hex information such as:

    • name: Name of the program
    • version: Version number of the program
    • os: Name of the operating system
    • os-version: Version of the operating system
    • vendor: Vendor of the client/server
    • support-url: URL to contact for support
    • address: Postal address of contact/vendor
    • date: Date program was released, specified as a date-time in IMAP4rev1
    • command: Command used to start the program
    • arguments: Arguments supplied on the command line, if any if any
    • environment: Description of environment, i.e., UNIX environment variables or Windows registry settings

    Client can also ask Server for its parameters.

    Implementations MUST NOT use contact information to submit automatic bug reports. Implementations may include information from an ID response in a report automatically prepared, but are prohibited from sending the report without user authorization.

    Basically by example:

    C: a023 ID ("name" "sodr" "version" "19.34"
                "vendor" "Pink Floyd Music Limited")
    S: * ID NIL
    S: a023 OK ID completed
    

    And

    C: a042 ID NIL
    S: * ID ("name" "Cyrus" "version" "1.5" "os" "sunos"
             "os-version" "5.5" 
             "support-url" "mailto:cyrus-bugs+@andrew.cmu.edu")
    S: a042 OK ID command completed
    

    Adding this RFC implementation (which already exists in customs versions of imaplib would allow all IMAP clients using it (such as https://github.com/OfflineIMAP/offlineimap3) to benefit from it and better support and bug leveraging.

  4. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 28, 2023
  5. nuffin commented on May 19, 2024

    I just copy the code from imaplib2, and monkey patched imaplib at runtime 🤣 the code is simple, as blow:

    ###
    # Monkey-patch imaplib to support the ID command ([RFC 2971](https://www.rfc-editor.org/rfc/rfc2971)) - begin
    ###
    imaplib.Commands['ID'] = ('AUTH', 'SELECTED')
    
    def imap_id_rfc2971(self, *kv_pairs, **kw):
        """(typ, [data]) = <instance>.id(kv_pairs)
        'kv_pairs' is a possibly empty list of keys and values.
        'data' is a list of ID key value pairs or NIL.
        NB: a single argument is assumed to be correctly formatted and is passed through unchanged
        (for backward compatibility with earlier version).
        Exchange information for problem analysis and determination.
        The ID extension is defined in RFC 2971. """
    
        name = 'ID'
    
        if not kv_pairs:
            data = 'NIL'
        elif len(kv_pairs) == 1:
            data = kv_pairs[0]     # Assume invoker passing correctly formatted string (back-compat)
        else:
            data = '(%s)' % ' '.join([(arg and self._quote(arg) or 'NIL') for arg in kv_pairs])
    
        return self._simple_command(name, data, **kw)
    
    imaplib.IMAP4.id = imap_id_rfc2971
    ###
    # Monkey-patch imaplib to support the ID command (RFC 2971) - end
    ###
    

    This code should be used as a temporary fix to work with the servers that require ID command, and it have not processed the response from server yet.

  6. added a commit that references this issue on Jul 5, 2026
  7. serhiy-storchaka commented on Jul 5, 2026

    Member

    Added imaplib.IMAP4.id() in GH-153136, a wrapper for the ID command (RFC 2971).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-emailtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL