Module Documentation — managesieve 0.8.1 0.8.1 documentation

# Module Documentation

## managesieve

ManageSieve (RFC 5804) client module for remotely managing Sieve Scripts.

All Sieve commands are supported by methods of the same name (in lower-case). All arguments to commands are converted to strings, except for `authenticate`.

class managesieve.MANAGESIEVE(host='', port=4190, use_tls=False, keyfile=None, certfile=None, tls_verify=True, timeout=None)

  Sieve client class.

  Instantiate with: MANAGESIEVE(host [, port])

  Parameters:

    - host – host’s name (default: localhost)

    - port – port number (default: standard Sieve port).

    - use_tls – switch to TLS automatically, fail if the server doesn’t support STARTTLS

    - keyfile – keyfile to use for TLS client authentication (optional)

    - certfile – certfile to use for TLS client authentication (optional)

    - timeout – If not None, socket timeout in seconds (refer to python’s socket.settimeout for details)

  exception abort

    Service errors - close and retry

  authenticate(mechanism, *authobjects)

    Authenticate to the server.

    Parameters:

      - mechanism (str) – authentication mechanism to use

      - authobjects – authentication data for this mechanism

    Returns:

      response (`OK`, `NO`, `BYE`)

  capability()

    Issue a CAPABILITY command and return the result.

    As a side-effect, on success these attributes are (re)set:

    - `capabilities` (list of strings)

    - `loginmechs` (list of strings)

    - `implementation` (string)

    - `supports_tls` (boolean)

    Returns:

      tuple(response, capabilities) – If response is `OK`, capabilities is a list of strings.

  deletescript(scriptname)

    Delete a scripts at the server.

    Parameters:

      scriptname (str) – name of script to be deleted

    Returns:

      response (`OK`, `NO`, `BYE`)

  exception error

    Logical errors - debug required

  getscript(scriptname)

    Get a script from the server.

    Parameters:

      scriptname (str) – name of script to be retrieved

    Returns:

      tuple(response, str) – if response is `OK`, str is the script content.

  havespace(scriptname, size)

    Query the server for available space.

    Parameters:

      - scriptname (str) – name of script to XXX

      - size (int) – XXX

    Returns:

      response (`OK`, `NO`, `BYE`)

  listscripts()

    Get a list of scripts on the server.

    Returns:

      tuple(response, [data]) – if response is `OK`, data is a list of (scriptname, active) tuples.

  login(auth, user, password)

    Authenticate to the Sieve server using the best mechanism available.

    Returns:

      response (`OK`, `NO`, `BYE`)

  logout()

    Terminate connection to server.

    Returns:

      response (`OK`, `NO`, `BYE`)

  putscript(scriptname, scriptdata)

    Put a script onto the server.

    Parameters:

      - scriptname (str) – name of script to be retrieved

      - scriptdata (str) – script content

    Returns:

      response (`OK`, `NO`, `BYE`)

  setactive(scriptname)

    Mark a script as the ‘active’ one.

    Parameters:

      scriptname (str) – name of script to be marked active

    Returns:

      response (`OK`, `NO`, `BYE`)

  starttls(keyfile=None, certfile=None, verify=True)

    Puts the connection to the SIEVE server into TLS mode.

    If the server supports TLS, this will encrypt the rest of the SIEVE session. If you provide the keyfile and certfile parameters, the identity of the SIEVE server and client can be checked. This, however, depends on whether the socket module really checks the certificates.

  unauthenticate()

    Leave the authenticated state.

    Returns:

      response (`OK`, `NO`, `BYE`)