]> code.delx.au - gnu-emacs/blob - doc/misc/sieve.texi
Convert consecutive FSF copyright years to ranges.
[gnu-emacs] / doc / misc / sieve.texi
1 \input texinfo @c -*-texinfo-*-
2 @setfilename ../../info/sieve
3 @settitle Emacs Sieve Manual
4 @synindex fn cp
5 @synindex vr cp
6 @synindex pg cp
7
8 @copying
9 This file documents the Emacs Sieve package, for server-side mail filtering.
10
11 Copyright @copyright{} 2001-2011 Free Software Foundation, Inc.
12
13 @quotation
14 Permission is granted to copy, distribute and/or modify this document
15 under the terms of the GNU Free Documentation License, Version 1.3 or
16 any later version published by the Free Software Foundation; with no
17 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
18 and with the Back-Cover Texts as in (a) below. A copy of the license
19 is included in the section entitled ``GNU Free Documentation License''.
20
21 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
22 modify this GNU manual. Buying copies from the FSF supports it in
23 developing GNU and promoting software freedom.''
24 @end quotation
25 @end copying
26
27 @dircategory Emacs
28 @direntry
29 * Sieve: (sieve). Managing Sieve scripts in Emacs.
30 @end direntry
31 @iftex
32 @finalout
33 @end iftex
34 @setchapternewpage odd
35
36 @titlepage
37 @title Emacs Sieve Manual
38
39 @author by Simon Josefsson
40 @page
41 @vskip 0pt plus 1filll
42 @insertcopying
43 @end titlepage
44
45 @summarycontents
46 @contents
47
48 @node Top
49 @top Sieve Support for Emacs
50
51 This is intended as a users manual for Sieve Mode and Manage Sieve, and
52 as a reference manual for the @samp{sieve-manage} protocol Emacs Lisp
53 API.
54
55 Sieve is a language for server-side filtering of mail. The language
56 is documented in RFC 3028. This manual does not attempt to document
57 the language, so keep RFC 3028 around.
58
59 @ifnottex
60 @insertcopying
61 @end ifnottex
62
63 @menu
64 * Installation:: Getting ready to use the package.
65 * Sieve Mode:: Editing Sieve scripts.
66 * Managing Sieve:: Managing Sieve scripts on a remote server.
67 * Examples :: A few Sieve code snippets.
68 * Manage Sieve API :: Interfacing to the Manage Sieve Protocol API.
69 * Standards:: A summary of RFCs and working documents used.
70 * GNU Free Documentation License:: The license for this documentation.
71 * Index:: Function and variable index.
72 @end menu
73
74
75 @node Installation
76 @chapter Installation
77 @cindex Install
78 @cindex Setup
79
80 The Sieve package should come with your Emacs version, and should be
81 ready for use directly.
82
83 However, to manually set up the package you can put the following
84 commands in your @code{~/.emacs}:
85
86 @lisp
87 (autoload 'sieve-mode "sieve-mode")
88 @end lisp
89 @lisp
90 (setq auto-mode-alist (cons '("\\.s\\(v\\|iv\\|ieve\\)\\'" . sieve-mode)
91 auto-mode-alist))
92 @end lisp
93
94
95 @node Sieve Mode
96 @chapter Sieve Mode
97
98 Sieve mode provides syntax-based indentation, font-locking support and
99 other handy functions to make editing Sieve scripts easier.
100
101 Use @samp{M-x sieve-mode} to switch to this major mode. This command
102 runs the hook @code{sieve-mode-hook}.
103
104 @vindex sieve-mode-map
105 @vindex sieve-mode-syntax-table
106 Sieve mode is derived from @code{c-mode}, and is very similar except
107 for the syntax of comments. The keymap (@code{sieve-mode-map}) is
108 inherited from @code{c-mode}, as are the variables for customizing
109 indentation. Sieve mode has its own abbrev table
110 (@code{sieve-mode-abbrev-table}) and syntax table
111 (@code{sieve-mode-syntax-table}).
112
113 In addition to the editing utility functions, Sieve mode also contains
114 bindings to manage Sieve scripts remotely. @xref{Managing Sieve}.
115
116 @table @kbd
117
118 @item C-c RET
119 @kindex C-c RET
120 @findex sieve-manage
121 @cindex manage remote sieve script
122 Open a connection to a remote server using the Managesieve protocol.
123
124 @item C-c C-l
125 @kindex C-c C-l
126 @findex sieve-upload
127 @cindex upload sieve script
128 Upload the Sieve script to the currently open server.
129
130 @end table
131
132
133 @node Managing Sieve
134 @chapter Managing Sieve
135
136 Manage Sieve is a special mode used to display Sieve scripts available
137 on a remote server. It can be invoked with @kbd{M-x sieve-manage
138 RET}, which queries the user for a server and if necessary, user
139 credentials to use.
140
141 When a server has been successfully contacted, the Manage Sieve buffer
142 looks something like:
143
144 @example
145 Server : mailserver:2000
146
147 2 scripts on server, press RET on a script name edits it, or
148 press RET on <new script> to create a new script.
149 <new script>
150 ACTIVE .sieve
151 template.siv
152 @end example
153
154 One of the scripts are highlighted, and standard point navigation
155 commands (@kbd{<up>}, @kbd{<down>} etc) can be used to navigate the
156 list.
157
158 The following commands are available in the Manage Sieve buffer:
159
160 @table @kbd
161
162 @item m
163 @kindex m
164 @findex sieve-activate
165 Activates the currently highlighted script.
166
167 @item u
168 @kindex u
169 @findex sieve-deactivate
170 Deactivates the currently highlighted script.
171
172 @item C-M-?
173 @kindex C-M-?
174 @findex sieve-deactivate-all
175 Deactivates all scripts.
176
177 @item r
178 @kindex r
179 @findex sieve-remove
180 Remove currently highlighted script.
181
182 @item RET
183 @item mouse-2
184 @item f
185 @kindex RET
186 @kindex mouse-2
187 @kindex f
188 @findex sieve-edit-script
189 Bury the server buffer and download the currently highlighted script
190 into a new buffer for editing in Sieve mode (@pxref{Sieve Mode}).
191
192 @item o
193 @kindex o
194 @findex sieve-edit-script-other-window
195 Create a new buffer in another window containing the currently
196 highlighted script for editing in Sieve mode (@pxref{Sieve Mode}).
197
198 @item q
199 @kindex q
200 @findex sieve-bury-buffer
201 Bury the Manage Sieve buffer without closing the connection.
202
203 @item ?
204 @item h
205 @kindex ?
206 @kindex h
207 @findex sieve-help
208 Displays help in the minibuffer.
209
210 @end table
211
212 @node Examples
213 @chapter Examples
214
215 If you are not familiar with Sieve, this chapter contains a few simple
216 code snippets that you can cut'n'paste and modify at will, until you
217 feel more comfortable with the Sieve language to write the rules from
218 scratch.
219
220 The following complete Sieve script places all messages with a matching
221 @samp{Sender:} header into the given mailbox. Many mailing lists uses
222 this format. The first line makes sure your Sieve server understands
223 the @code{fileinto} command.
224
225 @example
226 require "fileinto";
227
228 if address "sender" "owner-w3-beta@@xemacs.org" @{
229 fileinto "INBOX.w3-beta";
230 @}
231 @end example
232
233 A few mailing lists do not use the @samp{Sender:} header, but has a
234 unique identifier in some other header. The following is not a
235 complete script, it assumes that @code{fileinto} has already been
236 required.
237
238 @example
239 if header :contains "Delivered-To" "auc-tex@@sunsite.dk" @{
240 fileinto "INBOX.auc-tex";
241 @}
242 @end example
243
244 At last, we have the hopeless mailing lists that does not have any
245 unique identifier and you are forced to match on the @samp{To:} and
246 @samp{Cc} headers. As before, this snippet assumes that @code{fileinto}
247 has been required.
248
249 @example
250 if address ["to", "cc"] "kerberos@@mit.edu" @{
251 fileinto "INBOX.kerberos";
252 @}
253 @end example
254
255 @node Manage Sieve API
256 @chapter Manage Sieve API
257
258 The @file{sieve-manage.el} library contains low-level functionality
259 for talking to a server with the @sc{managesieve} protocol.
260
261 A number of user-visible variables exist, which all can be customized
262 in the @code{sieve} group (@kbd{M-x customize-group RET sieve RET}):
263
264 @table @code
265
266 @item sieve-manage-default-port
267 @vindex sieve-manage-default-port
268 Sets the default port to use, the suggested port number is @code{2000}.
269
270 @item sieve-manage-log
271 @vindex sieve-manage-log
272 If non-@code{nil}, should be a string naming a buffer where a protocol trace
273 is dumped (for debugging purposes).
274
275 @end table
276
277 The API functions include:
278
279 @table @code
280
281 @item sieve-manage-open
282 @findex sieve-manage-open
283 Open connection to managesieve server, returning a buffer to be used
284 by all other API functions.
285
286 @item sieve-manage-opened
287 @findex sieve-manage-opened
288 Check if a server is open or not.
289
290 @item sieve-manage-close
291 @findex sieve-manage-close
292 Close a server connection.
293
294 @item sieve-manage-authenticate
295 @findex sieve-manage-authenticate
296 Authenticate to the server.
297
298 @item sieve-manage-capability
299 @findex sieve-manage-capability
300 Return a list of capabilities the server supports.
301
302 @item sieve-manage-listscripts
303 @findex sieve-manage-listscripts
304 List scripts on the server.
305
306 @item sieve-manage-havespace
307 @findex sieve-manage-havespace
308 Return non-@code{nil} if the server has room for a script of given
309 size.
310
311 @item sieve-manage-getscript
312 @findex sieve-manage-getscript
313 Download script from server.
314
315 @item sieve-manage-putscript
316 @findex sieve-manage-putscript
317 Upload script to server.
318
319 @item sieve-manage-setactive
320 @findex sieve-manage-setactive
321 Indicate which script on the server should be active.
322
323 @end table
324
325 @node Standards
326 @chapter Standards
327
328 The Emacs Sieve package implements all or parts of a small but
329 hopefully growing number of RFCs and drafts documents. This chapter
330 lists the relevant ones. They can all be fetched from
331 @uref{http://quimby.gnus.org/notes/}.
332
333 @table @dfn
334
335 @item RFC3028
336 Sieve: A Mail Filtering Language.
337
338 @item draft-martin-managesieve-03
339 A Protocol for Remotely Managing Sieve Scripts
340
341 @end table
342
343 @node GNU Free Documentation License
344 @appendix GNU Free Documentation License
345 @include doclicense.texi
346
347 @node Index
348 @unnumbered Index
349 @printindex cp
350
351 @bye
352
353 @c End: