Skip to main content
Help us improve Python packaging – donate today!

Client-side SIEVE library

Project Description

travis codecov latest-version

Client-side Sieve and Managesieve library written in Python.

  • Sieve : An Email Filtering Language (RFC 5228)
  • ManageSieve : A Protocol for Remotely Managing Sieve Scripts (RFC 5804)


To install sievelib from PyPI:

pip install sievelib

To install sievelib from git:

git clone
cd sievelib
python ./ install

Sieve tools

What is supported

Currently, the provided parser supports most of the functionalities described in the RFC. The only exception concerns section Encoding Characters Using “encoded-character” which is not supported.

The following extensions are also supported:

Extending the parser

It is possible to extend the parser by adding new supported commands. For example:

import sievelib

class MyCommand(sievelib.commands.ActionCommand):
    args_definition = [
        {"name": "testtag",
            "type": ["tag"],
            "write_tag": True,
            "values": [":testtag"],
            "extra_arg": {"type": "number",
                          "required": False},
            "required": False},
        {"name": "recipients",
            "type": ["string", "stringlist"],
            "required": True}


Basic usage

The parser can either be used from the command-line:

$ cd sievelib
$ python test.sieve
Syntax OK

Or can be used from a python environment (or script/module):

>>> from sievelib.parser import Parser
>>> p = Parser()
>>> p.parse('require ["fileinto"];')
>>> p.dump()
require (type: control)
>>> p.parse('require ["fileinto"]')
>>> p.error
'line 1: parsing error: end of script reached while semicolon expected'

Simple filters creation

Some high-level classes are provided with the factory module, they make the generation of Sieve rules easier:

>>> from sievelib.factory import FiltersSet
>>> fs = FiltersSet("test")
>>> fs.addfilter("rule1",
...              [("Sender", ":is", ""),],
...              [("fileinto", "Toto"),])
>>> fs.tosieve()
require ["fileinto"];

# Filter: rule1
if anyof (header :is "Sender" "") {
    fileinto "Toto";

Additional documentation is available within source code.

ManageSieve tools

What is supported

All mandatory commands are supported. The RENAME extension is supported, with a simulated behaviour for server that do not support it.

For the AUTHENTICATE command, supported mechanisms are DIGEST-MD5, PLAIN and LOGIN.

Basic usage

The ManageSieve client is intended to be used from another python application (there isn’t any shell provided):

>>> from sievelib.managesieve import Client
>>> c = Client("")
>>> c.connect("user", "password", starttls=False, authmech="DIGEST-MD5")
>>> c.listscripts()
("active_script", ["script1", "script2"])
>>> c.setactive("script1")
>>> c.havespace("script3", 45)

Additional documentation is available with source code.

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
sievelib-1.1.1-py2.py3-none-any.whl (33.2 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Jan 25, 2018
sievelib-1.1.1-py3.6.egg (72.6 kB) Copy SHA256 hash SHA256 Egg 3.6 Jan 25, 2018
sievelib-1.1.1.tar.gz (29.6 kB) Copy SHA256 hash SHA256 Source None Jan 25, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page