pymap.config

class pymap.config.ConfigT

Type variable with an upper bound of IMAPConfig.

alias of TypeVar(‘ConfigT’, bound=IMAPConfig)

class pymap.config.ConfigT_contra

Contravariant type variable with an upper bound of IMAPConfig.

alias of TypeVar(‘ConfigT_contra’, bound=IMAPConfig, contravariant=True)

class pymap.config.BackendCapability(*, idle, object_id, multi_append, custom=None)[source]

Declares the IMAP capabilities that the backend supports.

Parameters:
  • idle (bool) – The IDLE extension is supported.

  • object_id (bool) – The OBJECTID extension is supported.

  • multi_append (bool) – The MULTIAPPEND extension is supported.

  • custom (Sequence[bytes] | None) – Optional list of custom capability strings to declare.

class pymap.config.IMAPConfig(args, *, host, port, debug=False, subsystem=None, ssl_context=None, tls_enabled=True, secure_auth=True, preauth_credentials=None, invalid_user_sleep=0.3, proxy_protocol=None, reject_dnsbl=True, admin_key=None, hash_context=None, cpu_subsystem=None, max_append_len=1000000000, bad_command_limit=5, disable_search_keys=None, disable_idle=False, **extra)[source]

Configurable settings that control how the IMAP server operates and what extensions it supports.

Parameters:
  • args (Namespace) – The command-line arguments.

  • host (str | None) – The IMAP server host.

  • port (str | int) – The IMAP server port or service name.

  • debug (bool) – If true, prints all socket activity to stdout.

  • subsystem (Subsystem | None) – The concurrency subsystem in use by the backend.

  • ssl_context (SSLContext | None) – SSL context that will be used for opportunistic TLS. Alternatively, you can pass extra arguments cert_file and key_file and an SSL context will be created.

  • tls_enabled (bool) – True if opportunistic TLS should be supported.

  • admin_key (bytes | None) – The private admin key for unrestricted access by token.

  • hash_context (HashInterface | None) – The hash to use for passwords.

  • cpu_subsystem (Subsystem | None) – The subsystem to use for CPU-heavy operations, defaulting to a small thread pool.

  • preauth_credentials (ServerCredentials | None) – If given, clients will pre-authenticate on connection using these credentials.

  • invalid_user_sleep (float) – Seconds to delay before failing authentication for an unrecognized user.

  • proxy_protocol (ProxyProtocol | None) – The PROXY protocol implementation to use.

  • reject_dnsbl (bool) – Reject connections with a non-empty DNSBL result.

  • max_append_len (int | None) – The maximum allowed length of the message body to an APPEND command.

  • bad_command_limit (int | None) – The number of consecutive commands received from the client with parsing errors before the client is disconnected.

  • disable_idle (bool) – Disable the IDLE capability.

  • extra (Any) – Additional keywords used for special circumstances.

  • secure_auth (bool)

  • disable_search_keys (Iterable[bytes] | None)

args

The command-line arguments.

classmethod parse_args(args)[source]

Given command-line arguments, return a dictionary of keywords that should be passed in to the IMAPConfig (or sub-class) constructor. Sub-classes should override this method as needed.

Parameters:

args (Namespace) – The arguments parsed from the command-line.

Return type:

Mapping[str, Any]

classmethod from_args(args, **overrides)[source]

Build and return a new IMAPConfig using command-line arguments.

Parameters:
  • args (Namespace) – The arguments parsed from the command-line.

  • overrides (Any) – Override keyword arguments to the config constructor.

Return type:

ConfigT

apply_context()[source]

Apply the configured settings to any context variables.

Return type:

None

abstract property backend_capability: BackendCapability

Allows backends to declare support for IMAP extensions and other capabilities.