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)
Installation
To install sievelib from PyPI:
pip install sievelib
To install sievelib from git:
git clone git@github.com:tonioo/sievelib.git cd sievelib python ./setup.py install
Sieve tools
What is supported
Currently, the provided parser supports most of the functionalities described in the RFC. The only exception concerns section 2.4.2.4. Encoding Characters Using “encoded-character” which is not supported.
The following extensions are also supported:
Copying Without Side Effects (RFC 3894)
Body (RFC 5173)
Vacation (RFC 5230)
Seconds parameter for Vacation (RFC 6131)
Relational (RFC 5231)
Imap4flags (RFC 5232)
Regular expression (Draft)
Notifications (RFC 5435)
Environment (RFC 5183)
The following extensions are partially 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"],
"values": [":testtag"],
"extra_arg": {"type": "number",
"required": False},
"required": False},
{"name": "recipients",
"type": ["string", "stringlist"],
"required": True}
]
sievelib.commands.add_commands(MyCommand)
Basic usage
The parser can either be used from the command-line:
$ cd sievelib $ python parser.py 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"];')
True
>>> p.dump()
require (type: control)
["fileinto"]
>>>
>>> p.parse('require ["fileinto"]')
False
>>> 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", "toto@toto.com"),],
... [("fileinto", "Toto"),])
>>> fs.tosieve()
require ["fileinto"];
# Filter: rule1
if anyof (header :is "Sender" "toto@toto.com") {
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, LOGIN, OAUTHBEARER and XOAUTH2.
Both explicit TLS via STARTTLS and implicit TLS are supported.
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("server.example.com")
>>> c.connect("user", "password", starttls=False, authmech="DIGEST-MD5")
True
>>> c.listscripts()
("active_script", ["script1", "script2"])
>>> c.setactive("script1")
True
>>> c.havespace("script3", 45)
True
>>>
Additional documentation is available with source code.
Metadata
Release files for sievelib 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sievelib-1.5.0.tar.gz | 40.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sievelib-1.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 80.1 kB
Release files / sievelib-1.5.0.tar.gz
| Download URL | sievelib-1.5.0.tar.gz |
|---|---|
| Size | 40.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2afbaaf2503afe912de0881e4c577383e6f90f8762931fb4d32f2b54123ce450
|
|
BLAKE2b-256 checksum How to use checksums |
259e6b2d4ed35f06452fcd05226d381c07bf142215f58960020027ecf4347ba2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.
Transparency logRelease files / sievelib-1.5.0-py3-none-any.whl
| Download URL | sievelib-1.5.0-py3-none-any.whl |
|---|---|
| Size | 40.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4979c5de564eace76e132d4071caf4fe25cbb7e3c50187057e42b6eff53a255b
|
|
BLAKE2b-256 checksum How to use checksums |
d4dccfd57eb53662202f68889d93c3455d2af6ffef4efc3c2f3544277f90cd89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.
Transparency log