Skip to content

Commit a37950c

Browse files
stephanboschcmouse
authored andcommitted
Sieve: Document support for extlists extension
1 parent 55a1b05 commit a37950c

File tree

5 files changed

+144
-0
lines changed

5 files changed

+144
-0
lines changed

.github/actions/spelling/expect.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ACAP
33
actimeo
44
addflag
55
addprinc
6+
addressbook
67
ADDRESULT
78
ADH
89
Adleman
@@ -208,6 +209,7 @@ euid
208209
examplescripts
209210
execv
210211
exim
212+
extlists
211213
exportkeytab
212214
extprograms
213215
extracttext

.github/actions/spelling/patterns.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,8 @@ key=[0-9a-f]+:\w+\}\s*=\s*(?:[0-9a-f$]+|pass)
161161

162162
# directory permissions
163163
[-bcdlpsw](?:[-r][-w][-SsTtx]){3}[\.+*]?\s+\d+\s+\S+\s+\S+\s+\d+\s+
164+
165+
# URNs
166+
urn:[A-Za-z0-9][A-Za-z0-9-]{0,31}:([A-Za-z0-9()+,\-.:=@;$_!*'?\/&]|%[0-9A-Fa-f]{2})+
167+
:addrbook:([A-Za-z0-9()+,\-.:=@;$_!*'?\/&]|%[0-9A-Fa-f]{2})+
168+

data/settings.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,61 @@ command.
10921092
The minimum value for this setting is \`1024\` bytes.`
10931093
},
10941094

1095+
sieve_extlists_list: {
1096+
tags: [ 'sieve', 'sieve-extlists' ],
1097+
plugin: 'sieve',
1098+
values: setting_types.NAMED_LIST_FILTER,
1099+
seealso: [ '[[link,sieve_extlists]]' ],
1100+
text: `
1101+
This named list filter creates a new list definition for the ":list" match type
1102+
in Sieve (extlists extension). The filter name refers to the
1103+
[[setting,sieve_extlists_list_name]] setting. That is the name of the list as it
1104+
will be accessible from the Sieve. A dict definition that is placed inside
1105+
the scope of this list filter will serve as the lookup for this extlists list.
1106+
So, values from Sieve are looked up in the defined dict. This is often used to
1107+
define an address book or whitelist external to the Sieve script. If no dict is
1108+
present, the list will function as an empty list.
1109+
1110+
Example:
1111+
1112+
\`\`\`
1113+
sieve_extlists_list :addrbook:default {
1114+
dict proxy {
1115+
name = addressbook
1116+
}
1117+
}
1118+
\`\`\``
1119+
},
1120+
1121+
sieve_extlists_list_name: {
1122+
tags: [ 'sieve', 'sieve-extlists' ],
1123+
plugin: 'sieve',
1124+
values: setting_types.STRING,
1125+
seealso: [ '[[link,sieve_extlists]]' ],
1126+
text: `
1127+
The name of the list as it will be accessible through the Sieve ":list" match
1128+
type (extlists extension). According to the standard, this name must be a valid
1129+
URI. This implementation further limits that to a valid URN or TAG URI. Note
1130+
that the standard URN and TAG equality rules dictate that at least parts of
1131+
these URIs are case-sensitive, so it is best to consider the configured name
1132+
case-sensitive entirely.
1133+
1134+
The [[setting,sieve_extlists_list]] filter refers to this setting.`
1135+
},
1136+
1137+
sieve_extlists_list_max_lookup_size: {
1138+
tags: [ 'sieve', 'sieve-extlists' ],
1139+
plugin: 'sieve',
1140+
values: setting_types.SIZE,
1141+
default: '1k',
1142+
seealso: [ '[[link,sieve_extlists]]' ],
1143+
text: `
1144+
The maximum size of a value looked up from this Sieve extlists list. If the
1145+
value is too large, the lookup will be skipped and will yield no result. Note
1146+
that individual lists may have different limits, meaning that lookups in other
1147+
lists may still succeed.`
1148+
},
1149+
10951150
sieve_notify_mailto_envelope_from: {
10961151
tags: [ 'sieve', 'sieve-enotify' ],
10971152
plugin: 'sieve',
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
layout: doc
3+
title: Extlists
4+
dovecotlinks:
5+
sieve_extlists: Sieve extlists extension
6+
---
7+
8+
# Sieve: Extlists Extension
9+
10+
The extlists extension ([[rfc,6134]]) enables Sieve scripts to check membership
11+
of a value in an external list or for redirecting messages to an external list
12+
of recipients. An "external list" is a list whose members are stored externally
13+
to the Sieve script. This extension adds a new ":list" match type to apply to
14+
supported tests and it can be be used to implement email whitelisting,
15+
blacklisting, addressbook lookups, and other sorts of list matching.
16+
17+
For Dovecot, the external list is always implemented using a dict lookup.
18+
Redirecting messages to a list of recipients as described in the standard
19+
([[rfc,6134]]) is currently not implemented in Dovecot and will always trigger
20+
an error if used.
21+
22+
## Configuration
23+
24+
The extlists extension is not available by default and needs to be
25+
enabled explicitly by adding it to [[setting,sieve_extensions]].
26+
27+
### Settings
28+
29+
<SettingsComponent tag="sieve-extlists" level="3" />
30+
31+
### Example
32+
33+
```
34+
# Use extlists
35+
sieve_extensions {
36+
extlists = yes
37+
}
38+
39+
# No value looked up from a list may exceed 512 bytes, or it will forcibly not
40+
# match
41+
sieve_extlists_list_max_lookup_size = 512
42+
43+
# The default addressbook stored in a proxied dict
44+
sieve_extlists_list :addrbook:default {
45+
dict proxy {
46+
name = addressbook
47+
}
48+
}
49+
50+
sieve_extlists_list tag:example.com,2025-02-26:BadFileExts {
51+
dict proxy {
52+
name = bad_file_extensions
53+
}
54+
55+
# Limit lookups to 10 bytes
56+
max_lookup_size = 10B
57+
}
58+
59+
```
60+
61+
## Sieve Example
62+
63+
The following example excludes senders listed in the user's default address book
64+
from Spam filtering. The example demonstrates the use of the
65+
[[link,sieve_spamtest,spamtest extension]] as well.
66+
67+
```
68+
require ["envelope", "extlists", "fileinto", "spamtest",
69+
"relational", "comparator-i;ascii-numeric"];
70+
71+
if allof( not envelope :list "from" ":addrbook:default",
72+
spamtest :value "ge" :comparator "i;ascii-numeric" "3" ) {
73+
fileinto "spam";
74+
}
75+
```
76+
77+
78+
79+
80+
81+

docs/core/config/sieve/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ The interpreter recognizes the following Sieve extensions:
5656
| <code>[[link,sieve_enotify,enotify]]</code> ([[rfc,5435]]) | **yes** | Provides the ability to send notifications by various means (currently only mailto) |
5757
| `envelope` ([[rfc,5228,5.4]]) | **yes** | Allows evaluating envelope parts, i.e. sender and recipient |
5858
| `environment` ([[rfc,5183]]) | **yes** | Allows testing against various labeled values from the execution environment |
59+
| <code>[[link,sieve_extlists,extlists]]</code> ([[rfc,6134]]) | no | Allows looking up and matching values from external lists (dict lookup) |
5960
| `extracttext` ([[rfc,5703,7]]) | **yes** | Allows extracting text from individual message MIME parts |
6061
| `fileinto` ([[rfc,5228,4.1]]) | **yes** | Allows storing messages in folders other than INBOX |
6162
| `foreverypart` ([[rfc,5703,3]]) | **yes** | Allows iterating through the message's MIME parts |

0 commit comments

Comments
 (0)