Commit 31e90a81 31e90a814915648fe37d1e579cfec4e407290396 by Sergey Poznyakoff

Document Sieve extensions

1 parent cdb95d01
...@@ -968,6 +968,35 @@ less than @var{count}, the test is true; otherwise, it is false. ...@@ -968,6 +968,35 @@ less than @var{count}, the test is true; otherwise, it is false.
968 If the tagged argument is not given, @samp{:over} is assumed. 968 If the tagged argument is not given, @samp{:over} is assumed.
969 @end deftypefn 969 @end deftypefn
970 970
971 @deftypefn Test {} pipe [:envelope] [:header] [:body] @
972 [:exit @var{code}(number)] @
973 [:signal @var{code}(number)] @
974 @var{command}(string)
975 @*Synopsis:
976 @smallexample
977 require "test-pipe";
978
979 if pipe @var{command}
980 @{
981 @dots{}
982 @}
983 @end smallexample
984 @*Description:
985 The @code{pipe} test executes a shell command specified by its
986 argument and pipes the entire message (including envelope) to its
987 standard input. When given, tags @code{:envelope}, @code{:header},
988 and @code{:body} control what parts of the message to pipe to the command.
989
990 In the absence of the @code{:exit} tag, the test returns true if
991 the command exits with code 0. If @code{:exit} is given, the test returns
992 true if the command exits with code equal to its argument.
993
994 The @code{:signal} tag determines the result of the test in case if the program
995 exits on signal. By default, the test returns false. If @code{:signal}
996 is given and the number of signal which caused the program to terminate
997 matches its argument, the test returns true.
998 @end deftypefn
999
971 @deftypefn Test {} spamd [:host @var{tcp-host}(string)] @ 1000 @deftypefn Test {} spamd [:host @var{tcp-host}(string)] @
972 [:port @var{tcp-port}(number)] @ 1001 [:port @var{tcp-port}(number)] @
973 [:socket @var{unix-socket}(string)] @ 1002 [:socket @var{unix-socket}(string)] @
...@@ -1046,7 +1075,7 @@ if list @var{args} ...@@ -1046,7 +1075,7 @@ if list @var{args}
1046 @} 1075 @}
1047 @end smallexample 1076 @end smallexample
1048 @*Description: 1077 @*Description:
1049 The @code{list} test evaluates to true if any of @var{headers} match any 1078 The @code{list} test evaluates to true if any of @var{headers} matches any
1050 key from @var{keys}. Each header is regarded as containing a list of 1079 key from @var{keys}. Each header is regarded as containing a list of
1051 keywords. By default, comma is assumed as list separator. This can be 1080 keywords. By default, comma is assumed as list separator. This can be
1052 overridden by specifying the @code{:delim} tag, whose value is a 1081 overridden by specifying the @code{:delim} tag, whose value is a
...@@ -1362,13 +1391,13 @@ the old message in a new one. ...@@ -1362,13 +1391,13 @@ the old message in a new one.
1362 1391
1363 @node External Actions 1392 @node External Actions
1364 @subsection External Actions 1393 @subsection External Actions
1365 @UNREVISED
1366 GNU Mailutils is shipped with a set of external Sieve 1394 GNU Mailutils is shipped with a set of external Sieve
1367 actions. These actions are compiled as loadable modules and must be 1395 actions. These actions are compiled as loadable modules and must be
1368 required prior to use (@pxref{Require Statement}). 1396 required prior to use (@pxref{Require Statement}).
1369 1397
1370 @deftypefn Action {} moderator [:keep] [:address @var{address}(string)] @ 1398 @deftypefn Action {} moderator [:keep] [:address @var{address}(string)] @
1371 [:source @var{sieve-file}(string)] 1399 [:source @var{sieve-file}(string)] @
1400 [:program @var{sieve-text}(string)]
1372 @*Synopsis: 1401 @*Synopsis:
1373 @smallexample 1402 @smallexample
1374 require "moderator" 1403 require "moderator"
...@@ -1401,9 +1430,16 @@ control message, thereby causing the submission to be discarded. The ...@@ -1401,9 +1430,16 @@ control message, thereby causing the submission to be discarded. The
1401 @code{:address} tag. After discarding the message, @code{moderator} 1430 @code{:address} tag. After discarding the message, @code{moderator}
1402 marks it as deleted, unless it is given @code{:keep} tag. 1431 marks it as deleted, unless it is given @code{:keep} tag.
1403 1432
1404 The argument of @code{:source} tag, if given, specifies the Sieve 1433 If the @code{:source} tag is given, its argument specifies a Sieve
1405 source file to be used on the message. If @code{:tag} is not present, 1434 source file to be used on the message. Otherwise, if @code{:program}
1406 @code{moderator} will create and use a copy of the existing Sieve machine. 1435 is given, its argument supplies a Sieve program to be used on this
1436 message. At most one of these tags may be specified. Supplying them
1437 both, or supplying several instances of the same tag, is an error. The
1438 behavior of the action in this case is undefined.
1439
1440 If neither @code{:program} nor @code{:source} is given,
1441 @code{moderator} will create a copy of the existing Sieve machine and
1442 use it on the message.
1407 1443
1408 The action checks the message structure: it will bail out if the message 1444 The action checks the message structure: it will bail out if the message
1409 does not have exactly 3 MIME parts, or if parts 2 and 3 are not of 1445 does not have exactly 3 MIME parts, or if parts 2 and 3 are not of
...@@ -1421,22 +1457,19 @@ if allof(header :is "Sender" "mailman-bounces@@gnu.org", ...@@ -1421,22 +1457,19 @@ if allof(header :is "Sender" "mailman-bounces@@gnu.org",
1421 @end smallexample 1457 @end smallexample
1422 @end deftypefn 1458 @end deftypefn
1423 1459
1424 @deftypefn Action {} pipe [:envelope] @var{command}(string) 1460 @deftypefn Action {} pipe [:envelope] [:header] [:body] @var{command}(string)
1425 @*Synopsis: 1461 @*Synopsis:
1426 @smallexample 1462 @smallexample
1427 require "pipe"; 1463 require "pipe";
1428 if pipe @var{args} 1464
1429 @{ 1465 pipe @var{command}
1430 @dots{}
1431 @}
1432 @end smallexample 1466 @end smallexample
1433 @*Description: 1467 @*Description:
1434 The @code{pipe} action sends executes a command specified by its 1468 The @code{pipe} action executes a shell command specified by its
1435 argument and sends the entire message to its standard input. The 1469 argument and pipes the entire message (including envelope) to its
1436 @var{command} argument supplies the command line. 1470 standard input. When given, tags @code{:envelope}, @code{:header},
1437 1471 and @code{:body} control what parts of the message to pipe to the
1438 The envelope of the message is included, if the @code{:envelope} tag 1472 command.
1439 is given.
1440 1473
1441 @*Example: 1474 @*Example:
1442 The example below uses the @command{maidag} utility 1475 The example below uses the @command{maidag} utility
...@@ -1479,12 +1512,12 @@ If the @code{:file} tag is present, @var{text} is treated as the name ...@@ -1479,12 +1512,12 @@ If the @code{:file} tag is present, @var{text} is treated as the name
1479 of the file to read the body of the reply message from. When used together 1512 of the file to read the body of the reply message from. When used together
1480 with tag @code{:rfc2822}, the file should be formatted as a valid RFC 1513 with tag @code{:rfc2822}, the file should be formatted as a valid RFC
1481 2822 message, i.e. headers followed by empty line and body. Headers 1514 2822 message, i.e. headers followed by empty line and body. Headers
1482 must not contain @samp{To}, @samp{From}, and @samp{Subject}, as these 1515 may not contain @samp{To}, @samp{From}, and @samp{Subject}, as these
1483 will be generated automatically. 1516 will be generated automatically.
1484 1517
1485 If the @code{:subject} tag is given, its argument sets the subject of 1518 If the @code{:subject} tag is given, its argument sets the subject of
1486 the message. Otherwise, the subject is formed by prefixing original 1519 the message. Otherwise, the subject is formed by prefixing original
1487 subject with @samp{Re:}, or @var{prefix}, given with the 1520 subject with @samp{Re:}, or the @var{prefix} given with the
1488 @code{:reply_prefix} tag. Before prefixing, any original prefixes 1521 @code{:reply_prefix} tag. Before prefixing, any original prefixes
1489 matching extended regular expression @var{expr} (@code{:reply_regex} 1522 matching extended regular expression @var{expr} (@code{:reply_regex}
1490 tag) are stripped from the subject line. If @code{:reply_regex} is not 1523 tag) are stripped from the subject line. If @code{:reply_regex} is not
...@@ -1586,11 +1619,11 @@ may disappear from the subsequent releases. ...@@ -1586,11 +1619,11 @@ may disappear from the subsequent releases.
1586 @item @code{fileinto} action 1619 @item @code{fileinto} action
1587 1620
1588 The @code{fileinto} action allows to specify permissions on the mailbox, 1621 The @code{fileinto} action allows to specify permissions on the mailbox,
1589 in case it is created (@pxref{fileinto}). 1622 in case it will be created (@pxref{fileinto}).
1590 1623
1591 @item Match type optional argument. 1624 @item Match type optional argument.
1592 1625
1593 Along with the usual @code{:is}, @code{:matches} and @code{contains} 1626 Along with the usual @code{:is}, @code{:matches} and @code{:contains}
1594 matching type, GNU sieve library understands @code{:regex} type. This 1627 matching type, GNU sieve library understands @code{:regex} type. This
1595 matching type toggles POSIX Extended Regular Expression matching. 1628 matching type toggles POSIX Extended Regular Expression matching.
1596 @end enumerate 1629 @end enumerate
......
...@@ -16,12 +16,37 @@ ...@@ -16,12 +16,37 @@
16 Public License along with this library. If not, see 16 Public License along with this library. If not, see
17 <http://www.gnu.org/licenses/>. */ 17 <http://www.gnu.org/licenses/>. */
18 18
19 /* Syntax: pipe [:envelope] <program: string> 19 /* The "pipe" action
20
21 Syntax: pipe [:envelope] [:header] [:body]
22 <command: string>
20 23
21 The pipe action executes a shell command specified by its 24 The pipe action executes a shell command specified by its
22 argument and pipes the entire message to its standard input. 25 argument and pipes the entire message (including envelope) to its
23 The envelope of the message is included, if the :envelope tag is given. 26 standard input. When given, tags :envelope, :header, and :body
24 27 control what parts of the message to pipe to the command.
28
29 The "pipe" test
30
31 Syntax: pipe [:envelope] [:header] [:body]
32 [:exit <code: number>]
33 [:signal <code: number>]
34 <command: string>
35
36 The pipe test executes a shell command specified by its
37 argument and pipes the entire message (including envelope) to its
38 standard input. When given, tags :envelope, :header, and :body
39 control what parts of the message to pipe to the command.
40
41 In the absence of :exit and :signal tags, the test returns true if
42 the command exits with code 0. If :exit is given, the test returns
43 true if the command exits with code equal to its argument.
44
45 The :signal tag determines the result in case if the program
46 exits on signal. By default, the test returns false. If :signal
47 is given and the number of signal which caused the program to terminate
48 matches its argument, the test returns true.
49
25 Notes/FIXME: 1. it would be nice to implement meta-variables in 50 Notes/FIXME: 1. it would be nice to implement meta-variables in
26 <program call> which would expand to various 51 <program call> which would expand to various
27 items from the message being handled. 52 items from the message being handled.
......