Search K
Appearance
Appearance
WARNING
This tool is still experimental. Read this manual carefully, and backup any important mail before using this tool. Also note that some of the features documented here are not actually implemented yet; this is clearly indicated where applicable.
sieve-filter [options] script-file source-mailbox [discard-action]
The sieve-filter command is part of Pigeonhole (pigeonhole(7)
), which adds Sieve (RFC 5228) and ManageSieve (RFC 5804) support to Dovecot (dovecot(1)
).
The Sieve language was originally meant for filtering messages upon delivery. However, there are occasions when it is desirable to filter messages that are already stored in a mailbox, for instance when a bug in a Sieve script caused many messages to be delivered incorrectly. Using the sieve-filter tool it is possible to apply a Sieve script on all messages in a particular source-mailbox, making it possible to delete messages, to store them in a different mailbox, to change their content, and to change the assigned IMAP flags and keywords. Attempts to send messages to the outside world are ignored by default for obvious reasons, but, using the proper command line options, it is possible to capture and handle outgoing mail as well.
If no options are specified, the sieve-filter command runs in a simulation mode in which it only prints what would be performed, without actually doing anything. Use the -e option to activate true script execution. Also, the source-mailbox is opened read-only by default, meaning that it normally always remains unchanged. Use the -W option to allow changes in the source-mailbox.
Even with the -W option enabled, messages in the source-mailbox are only potentially modified or moved to a different folder. Messages are never lost unless a discard-action argument other than keep (the default) is specified. If the Sieve filter decides to store the message in the source-mailbox, where it obviously already exists, it is never duplicated there. In that case, the IMAP flags of the original message can be modified by the Sieve interpreter using the imap4flags extension, provided that -W is specified. If the message itself is modified by the Sieve interpreter (e.g. using the editheader extension), a new message is stored and the old one is expunged. However, if -W is omitted, the original message is left untouched and the modifications are discarded.
Although this is a very useful tool, it can also be very destructive when used improperly. A small bug in your Sieve script in combination with the wrong command line options could cause it to discard the wrong e-mails. And, even if the source-mailbox is opened in read-only mode to prevent such mishaps, it can still litter other mailboxes with spurious copies of your e-mails if your Sieve script decides to do so. Therefore, users are advised to read this manual carefully and to use the simulation mode first to check what the script will do. And, of course:
MAKING A BACKUP IS IMPERATIVE FOR ANY IMPORTANT MAIL!
sievec(1)
for more information about Sieve compilation.Specifies the Sieve script to (compile and) execute.
Note that this tool looks for a pre-compiled binary file with a .svbin extension and with basename and path identical to the specified script. Use the -C option to disable this behavior by forcing the script to be compiled into a new binary.
Specifies the source mailbox containing the messages that the Sieve filter will act upon.
This is the name of a mailbox, as visible to IMAP clients, except in UTF-8 format. The hierarchy separator between a parent and child mailbox is commonly '/' or '.', but this depends on your selected mailbox storage format and namespace configuration. The mailbox names may also require a namespace prefix.
This mailbox is not modified unless the -W option is specified.
Specifies what is done with messages in the source-mailbox that where not kept or otherwise stored by the Sieve script; i.e. those messages that would normally be discarded if the Sieve script were executed at delivery. The discard-action parameter accepts one of the following values:
Keep discarded messages in source mailbox.
When the -W option is not specified, the source-mailbox is immutable and the specified discard-action has no effect. This means that messages are at most copied to a new location. In contrast, when the -W is specified, messages that are successfully stored somewhere else by the Sieve script are always expunged from the source-mailbox, with the effect that these are thus moved to the new location. This happens irrespective of the specified discard-action. Remember: only discarded messages are affected by the specified discard-action.
sieve-filter will exit with one of the following values:
dovecot(1)
, dovecot-lda(1)
, sieve-dump(1)
, sieve-test(1)
, sievec(1)
, pigeonhole(7)