39
52
mail store. The intention of the language is to make it impossible for users to
40
53
do anything more complex (and dangerous) than write simple mail filters.
42
This wiki page explains how to use the Sieve language with Dovecot. It is
43
implemented as a plug-in to the deliver [http://wiki.dovecot.org/LDA] LDA.
44
Currently, two concurrent implementations of the Sieve plug-in are available.
45
The original plug-in called *CMUSieve* uses the Sieve interpreter from the
46
Cyrus project and has been available for Dovecot versions ranging from v1.0 to
47
the latest v1.2. Recently, a fully rewritten implementation was released for
48
Dovecot v1.2. This new plug-in is simply called *Sieve*. The main reason for
49
rewriting the Sieve engine is to provide more reliable script execution and to
50
provide better error messages to users and system administrators.
55
Both implementations of the Sieve plug-in are distributed in a separate
58
* You can get the CMUSieve plug-in from Dovecot's download page
59
[http://www.dovecot.org/download.html].
60
* You can get the new Sieve plug-in at this web page
61
[http://www.rename-it.nl/dovecot/1.2/]. The tarballs for the Sieve releases
62
are called dovecot-1.2-sieve-x.y.z.tar.gz in which the x.y.z represents the
65
Alternatively, you can obtain the latest versions from Mercurial repositories:
67
* The CMUSieve plug-in has different repositories for the available Dovecot
69
* For v1.0: 'http://hg.dovecot.org/dovecot-sieve-1.0'
70
* For v1.1 and v1.2: 'http://hg.dovecot.org/dovecot-sieve-1.1'
71
* The repository of the new Sieve plugin is:
72
'http://hg.rename-it.nl/dovecot-libsieve'
74
In Ubuntu, starting from version 7.10 Gutsy, the CMUSieve plug-in already comes
75
with Dovecot regular install. In this case you do not have to download
76
additional packages. Simply skip "Compiling" section and proceed to
77
"Configuring". This is also true for Debian Etch.
82
Compilation is identical among the CMUSieve and the new Sieve plug-in. Use
83
'--with-dovecot=<path>' to point to 'dovecot-config' file's directory. There
84
are two possibilities where this could exist:
86
1. If you configured Dovecot with '--enable-header-install', you'll have
87
'dovecot-config' installed in '$prefix/lib/dovecot/' directory.
88
2. Compiled Dovecot sources' root directory.
92
---%<-------------------------------------------------------------------------
93
./configure --with-dovecot=/usr/local/lib/dovecot
96
---%<-------------------------------------------------------------------------
98
If you downloaded the sources using Mercurial, you will need to execute
99
'./autogen.sh' first to build the automake structure in your source tree. This
100
process requires autotools and libtool to be installed.
102
Binaries for command line tools like 'sievec' and 'sieved' are built only if
103
you use method 2, because they need to link with Dovecot's libraries. These two
104
tools can be used to compile and decompile Sieve scripts. You probably do not
105
need these, except when using the Python<ManageSieve.txt> server (it uses
106
'sievec' to verify uploaded scripts). The new Sieve implementation has a few
107
additional tools that can be used to verify and debug scripts from the command
108
line (refer to the README file for more information).
113
First, you'll need to make sure you're using Dovecot's <deliver> [LDA.txt] to
114
deliver incoming mail to users' mailboxes. Then you need to enable the Sieve
115
plugin in your 'dovecot.conf'. The CMUSieve plugin is called 'cmusieve' and the
116
new Sieve plugin is called 'sieve'. The CMUSieve plugin is for example enabled
119
---%<-------------------------------------------------------------------------
122
# If there is no user-specific Sieve-script, global Sieve script is
123
# executed if set. (v1.0.1 and older used "global_script_path")
124
# (e.g. /etc/dovecot/default.sieve)
126
# Support for dynamically loadable plugins. mail_plugins is a space separated
127
# list of plugins to load.
128
mail_plugins = cmusieve # ... other plugins like quota
130
---%<-------------------------------------------------------------------------
132
In this context /sieve_global_path/ refers to a *filename*, and not a
135
Per-user Sieve script location
55
The bottom of this page provides a few specific Sieve script examples. See
56
Sieve wiki [http://sieve.info/] for more comprehensive information about the
57
Sieve language itself.
59
Installation and configuration
136
60
------------------------------
138
By default Dovecot looks for user's Sieve script from '.dovecot.sieve' file in
139
user's home directory. This requires that the<home directory>
140
[VirtualUsers.txt] is set for the user.
142
If you want to store the script elsewhere, you can override the default by
143
returning 'sieve' setting containing path to the file. This can be done in two
146
1. Define 'sieve' setting in plugin section of 'dovecot.conf'.
147
2. Return 'sieve' extra field from <userdb extra fields>
148
[UserDatabase.ExtraFields.txt].
150
For example to create a Sieve script file named '<username>.sieve' in
151
'/var/sieve-scripts', use:
153
---%<-------------------------------------------------------------------------
155
# NOTE: %variable expansion works only with Dovecot v1.0.2+
156
sieve = /var/sieve-scripts/%u.sieve
158
---%<-------------------------------------------------------------------------
160
You may use templates like %u in the example. See all <variables>
163
A relative path (or just a filename) will be interpreted to point under the
164
user's home directory.
166
Script compiling and errors
167
---------------------------
169
When the Sieve script is executed for the first time (or after it has been
170
changed), it's compiled into into a binary form. This is where the CMUSieve
171
plug-in and the new Sieve plug-in differ:
173
* For CMUSieve, the binary is stored by appending "c" letter after the script
174
name (e.g. ".dovecot.sievec"). If there are errors in the script, the error
175
messages are stored into a ".err" file (e.g. ".dovecot.sieve.err"). This
176
means that deliver must have write access to the directory where the script
177
is stored. Global scripts have the same problem. Either allow deliver to
178
write to the global script's directory, or compile the script before deliver
179
sees it. Scripts can be compiled using the 'sievec' tool.
180
* The new Sieve implementation uses the '.svbin' extension to store compiled
181
Sieve scripts (e.g. ".dovecot.svbin"). If there are errors or warnings in
182
the script, the messages are appended to a ".log" file (e.g.
183
".dovecot.sieve.log") until it grows too large. When that happens, the old
184
log file is rotated to a ".log.0" file and an empty log file is started.
185
Currently, scripts included using the include extension are compiled into
186
the main binary, meaning that the plug-in only needs write access to the
187
directory where the main script is located. This is also where the log file
188
is always written. Messages that could be of interest to the system
189
administrator are also written to the Dovecot logging facility (usually
192
How to stop using sieve
193
-----------------------
195
A user may want to stop using his/her own sieve (and maybe return to using
196
global sieve script). Or the administrator may want to disable global sieve.
198
To stop using sieve, both the .sieve source file and the compiled .sieve *c*
199
file must be deleted(or renamed).
62
Sieve is implemented as a plugin to deliver [http://wiki.dovecot.org/LDA].
63
Currently, two concurrent implementations of the Sieve plugin are available.
64
See their pages for specific instructions:
66
* <CMU Sieve> [LDA.Sieve.CMU.txt] uses the Sieve interpreter from the Cyrus
67
project. For Dovecot v1.0 .. v1.2.
68
* <Dovecot Sieve> [LDA.Sieve.Dovecot.txt] is a fully rewritten implementation.
69
For Dovecot v1.2 and newer.
204
Both implementations of the Sieve plug-in support various extensions to the
205
Sieve language. You can find more information about these at the Sieve Mail
74
Both Sieve implementations support various extensions to the Sieve language.
75
You can find more information about the extensions from the Sieve Mail
206
76
Filtering Language Charter
207
77
[http://www.ietf.org/html.charters/sieve-charter.html] or the Sieve.info wiki
208
78
page [http://www.sieve.info/].
210
*NB: Sieve doesn't support running external programs*.
215
The CMUSieve plugin v1.0.x code is taken from Cyrus IMAP v2.2.12. The CMUSieve
216
plugin v1.1.x code is taken from Cyrus IMAP v2.3.8. Whatever information you
217
can find about those versions of Cyrus Sieve, it should also apply to these
80
Note that Sieve doesn't support running external programs.
220
82
The supported Sieve features are:
226
* imapflags (old draft specification)
227
* notify (old draft specification)
233
* include (v1.1 only)
238
The new Sieve plug-in aims to at least match the extensions supported by the
255
In this respect the notify extension is notably missing. This is currently
256
under development. Note that the CMUSieve plug-in implements an older
257
specification that calls this extension *notify* and not *enotify* as it is
258
called nowadays. Something similar is true for the *imapflags* extension which
259
is now called *imap4flags*. The most valuable extension that the new Sieve
260
implementation adds to the list is the *variables* extension. As the name
261
implies, this adds support for variables to the language.
85
+--------------------------------------------------------------------+-------+-----------+
86
| Extension | CMU | Dovecot |
88
+--------------------------------------------------------------------+-------+-----------+
89
| fileinto [http://ietfreport.isoc.org/idref/rfc5228/] | yes | yes |
90
+--------------------------------------------------------------------+-------+-----------+
91
| reject | yes | yes |
92
| [http://ietfreport.isoc.org/idref/draft-ietf-sieve-refuse-reject/] | | |
93
+--------------------------------------------------------------------+-------+-----------+
94
| envelope [http://ietfreport.isoc.org/idref/rfc5228/] | yes | yes |
95
+--------------------------------------------------------------------+-------+-----------+
96
| vacation [http://ietfreport.isoc.org/idref/rfc5230/] | yes | yes |
97
+--------------------------------------------------------------------+-------+-----------+
98
| imap4flags [http://ietfreport.isoc.org/idref/rfc5232/] | no | yes |
99
+--------------------------------------------------------------------+-------+-----------+
100
| imapflags(old draft | yes | yes |
101
| [http://tools.ietf.org/html/draft-melnikov-sieve-imapflags-03]) | | (default |
103
+--------------------------------------------------------------------+-------+-----------+
104
| enotify [http://ietfreport.isoc.org/idref/rfc5435/] | no | yes |
105
+--------------------------------------------------------------------+-------+-----------+
106
| notify (old draft | yes | no |
107
| [http://tools.ietf.org/html/draft-ietf-sieve-notify-00]) | | |
108
+--------------------------------------------------------------------+-------+-----------+
109
| regex [http://ietfreport.isoc.org/idref/draft-ietf-sieve-regex/] | yes | yes |
110
+--------------------------------------------------------------------+-------+-----------+
111
| subaddress [http://ietfreport.isoc.org/idref/rfc5233/] | yes | yes |
112
+--------------------------------------------------------------------+-------+-----------+
113
| relational [http://ietfreport.isoc.org/idref/rfc5231/] | yes | yes |
114
+--------------------------------------------------------------------+-------+-----------+
115
| copy [http://ietfreport.isoc.org/idref/rfc3894/] | v1.1+ | yes |
116
+--------------------------------------------------------------------+-------+-----------+
117
| body [http://ietfreport.isoc.org/idref/rfc5173/] | v1.1+ | yes |
118
+--------------------------------------------------------------------+-------+-----------+
119
| include | v1.1+ | yes |
120
| [http://ietfreport.isoc.org/idref/draft-daboo-sieve-include/] | | |
121
+--------------------------------------------------------------------+-------+-----------+
122
| encoded-character [http://ietfreport.isoc.org/idref/rfc5228/] | no | yes |
123
+--------------------------------------------------------------------+-------+-----------+
124
| variables [http://ietfreport.isoc.org/idref/rfc5229/] | no | yes |
125
+--------------------------------------------------------------------+-------+-----------+
127
Note that the CMU Sieve plugin implements an older specification of the
128
*enotify* extension which was called *notify*. Something similar is true for
129
the *imap4flags* extension, which was known as *imapflags* for CMU Sieve. For
130
backwards compatibility, Dovecot Sieve plugin also supports the old *imapflags*
131
extension. The most valuable extension that the new Sieve implementation adds
132
to the list is the *variables* extension. As the name implies, this adds
133
support for variables to the language.
263
135
ManageSieve server
264
136
------------------