jSieve is a Java implementation of the Sieve mail filtering language defined by RFC 3028. jSieve is implemented as a language processor that can be plugged into any internet mail application to add Sieve support.
jSieve is a subproject of Apache JAMES. All who are interested in developing jSieve and JAMES will be warmly welcomed on the mailing lists.
Sieve is an extensible mail filtering language. It's limited expressiveness (no loops or variables, no tests with side effects) allows user created scripts to be run safely on email servers. Sieve is targeted at the final delivery phase (where an incoming email is transfered to a user's mailbox).
Sieve scripts are composed of commands. Control commands manage the execution of the script. Test commands define side-effect free criteria. Action commands are mail operations to be performed.
jSieve is limited only by the platform on which it runs.
| Limits | |
|---|---|
| Maximum Number Of Actions | No intrinsic limit |
| Maximum Number Of Nested Blocks | No intrinsic limit |
| Maximum Number Of Nested Test Lists | No intrinsic limit |
jSieve supports the standard control commands specified in RFC 3028.
| Control Command | Specification | Supported |
|---|---|---|
| If | RFC 3028 (REQUIRED) | yes | Require | RFC 3028 (REQUIRED) | yes |
| Stop | RFC 3028 (REQUIRED) | yes |
jSieve supports all action commands (both required and optional) specified in RFC 3028.
Note that jSieve uses a pluggable
MailAdapter as an interface to the mail server.
Not all implementations may fully support all actions.
| Action Command | Specification | Supported |
|---|---|---|
| reject | RFC 3028 (OPTIONAL) | yes |
| fileinto | RFC 3028 (OPTIONAL) | yes |
| redirect | RFC 3028 (REQUIRED) | yes |
| keep | RFC 3028 (REQUIRED) | yes |
| discard | RFC 3028 (REQUIRED) | yes |
jSieve supports all tests commands specified in RFC 3028.
| Test Command | Specification | Supported |
|---|---|---|
| address | RFC 3028 (REQUIRED) | yes |
| allof | RFC 3028 (REQUIRED) | yes |
| anyof | RFC 3028 (REQUIRED) | yes |
| envelope | RFC 3028 (OPTIONAL) | yes |
| exists | RFC 3028 (REQUIRED) | yes |
| false | RFC 3028 (REQUIRED) | yes |
| header | RFC 3028 (REQUIRED) | yes |
| not | RFC 3028 (REQUIRED) | yes |
| size | RFC 3028 (REQUIRED) | yes |
| true | RFC 3028 (REQUIRED) | yes |
| body | SIEVE body extension | partial |
jSieve allows extension commands to be developed and plugged in at run time. The following extension commands ship with jSieve:
| Name | Function |
|---|---|
| Log | Logs messages |
Until these pages are fleshed out, the best way to understand jSieve is read the Javadocs and look at the source code. The jUnit tests illustrate many aspects of the implementation.
org.apache.jsieve.SieveFactory is the primary invocation
point for all Sieve operations. The API is clean and simple.
See the
javadocs for more details.
The SieveToMultiMailbox mailet is included in JAMES.
It is integrated with the message delivery spool and provides per-user
Sieve scripting using jSieve.
org.apache.jsieve.mail.MailAdapter is the interface API used
by jSieve to interact with a mail server.
The mail adapter wraps an email
and supplies information (required by the script) about the email. It is
responsible for accumulating Actions during the parsing of a
script and for executing them once the parsing is complete.
org.apache.jsieve.commands.extensions.Log is an example
of a custom extension command. It is recommended that custom commands
extend
AbstractCommand. See the
javadocs for more details.
Custom commands need to be registered with
ConfigurationManager before they can be used. This
may be done programmatically but the recommended method is by altering
the sieveConfig.xml configuration file.
jSieve uses Ant. ant -projecthelp
describes appropriate targets. ant runs the default target.
jSieve is a sub-project of Apache James. Please direct your comments and questions to the relevant James list.
To report issues, such as bugs, go to the jSieve Issue Tracker. As jSieve comes with a fairly extensive suite of jUnit Tests, it would be most helpful for bug reports to be accompanied by an illustrative jUnit test case.
SIEVE specifies that UTF-8 encoding is used for scripts. This format is an international standard and has wide support but not all platforms use this encoding by default.
By default, JSieve expects that scripts are encoding using UTF-8.
Either set the encoding programmatically or ensure that the script is encoded using
UTF-8.