how to configure imapsieve to be used per user
I only see configurations that are active for all users, how to configure this in the user sieve rules. I only need this for specific users.
according to the documentation, this has to be added to the IMAP METADATA dict per mailbox (https://doc.dovecot.org/configuration_manual/imap_metadata/):
https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve/ says:
The basic IMAPSIEVE capability allows attaching a Sieve script to a mailbox for any mailbox by setting a special IMAP METADATA entry. This way, users can configure Sieve scripts that are run for IMAP events in their mailboxes. But I can not find any example how this should work, neither which client supports setting those things. My guess is that these keys are used: https://www.iana.org/assignments/imap-metadata/imap-metadata.xhtml#imap-meta...
I would also be interested to know if and how that works, especially if you can add a rule when moving mails (from anywhere) to a certain mailbox for a single user.
Best, Sebastian
On 17.10.2022 12:46, Marc wrote:
I only see configurations that are active for all users, how to configure this in the user sieve rules. I only need this for specific users.
On 24-10-2022 12:00, Sebastian Bachmann wrote:
according to the documentation, this has to be added to the IMAP METADATA dict per mailbox (https://doc.dovecot.org/configuration_manual/imap_metadata/):
https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve/ says:
The basic IMAPSIEVE capability allows attaching a Sieve script to a mailbox for any mailbox by setting a special IMAP METADATA entry. This way, users can configure Sieve scripts that are run for IMAP events in their mailboxes. But I can not find any example how this should work, neither which client supports setting those things. My guess is that these keys are used: https://www.iana.org/assignments/imap-metadata/imap-metadata.xhtml#imap-meta...
I would also be interested to know if and how that works, especially if you can add a rule when moving mails (from anywhere) to a certain mailbox for a single user.
The basic capability works according to the specification: https://www.rfc-editor.org/rfc/rfc6785 This allows the users to configure these scripts.
If you want to arrange this solely at the administrator's discretion, you can use the _before/_after settings documented in https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve
Best, Sebastian
On 17.10.2022 12:46, Marc wrote:
I only see configurations that are active for all users, how to configure this in the user sieve rules. I only need this for specific users.
ok a few things about sieve
although it is a pain it is usually (on a per user basis) better to access the sieve scripting through thunderbird's plugin sieve or something similiar as it will sort out checksums, syntax etc.
see :
https://github.com/thsmi/sieve/
https://www.pair.com/support/kb/sieve-syntax-and-common-recipes/
https://wiki.dovecot.org/Pigeonhole/ManageSieve/Troubleshooting
also RFC
https://datatracker.ietf.org/doc/html/rfc5804#page-3
Next and all though way more complicated since you need to calculate checksums etc i use a telnet python script that generates forward's etc
again may (probably not) what you are looking for but it at least gives another example(s)
python2 code below:
last but not least there is an RFC avaliable for sieve scripting but again its at a programming level and may not be overally useful ? (note link above)
don't feel bad it took me a while to figure this out as well.
for any of this to work you need the sieve listener port running on the mail server
make sure you can telnet to mailserver:2000 (older) or port 4190 (current) depending how you are configured for sieve before going any further.
dovecot.conf
protocols = imap pop3 lmtp sieve
protocol lmtp { mail_plugins = $mail_plugins sieve postmaster_address = monitor@scom.ca }
sieve = file:~/sieve;active=~/sieve/.dovecot.sieve #sieve = ~/.dovecot.sieve sieve_duplicate_default_period = 1h sieve_duplicate_max_period = 1h sieve_extensions = +duplicate +notify +imapflags +vacation-seconds sieve_global_dir = /usr/local/etc/dovecot/sieve sieve_before = /usr/local/etc/dovecot/sieve/duplicates.sieve
service managesieve-login { process_limit = 1000 vsz_limit = 1g inet_listener sieve { port = 4190 } }
protocol sieve { managesieve_implementation_string = Dovecot Pigeonhole managesieve_max_line_length = 65536 }
above is my sieve conf alter accordingly if needed ....
below are examples of my sieve processing scripts for vacation notices and forward's, this data comes from my django project model but should be pretty clear what the code is doing.
note : you need to base64 the auth username & password to login to the users sieve account.
note : \r\n needs to be used as a line terminator and calculated accordingly. See count & count2 below. Basically \r\n = 1
you can expand on this ....
if self.vacation_active == True and dontupdate != True:
#debug = [debug,server,port,count,label,pid]
debug = 'syslog,10.228.0.6,514,0,sieve,0'
log_debug (debug, 'Sieve (Vacation) : Do Not Update Status for : %s'
%dontupdate ) import base64,telnetlib log_debug (debug, 'Enabling Sieve for : %s' %self.username ) auth = '\0%s\0%s' %(self.username,self.password) log_debug (debug, 'Auth : %s' %auth) auth = base64.b64encode(auth) log_debug (debug, 'Auth Encoded : %s' %auth) from telnetlib import Telnet tn = Telnet('10.220.0.18', 4190) connect = tn.read_until('OK',5) log_debug (debug, 'Connect : \n%s\n' %connect) authout = 'AUTHENTICATE "PLAIN" "%s"\n'%auth log_debug (debug, 'Authout : %s' %authout) tn.write(authout) status = tn.expect(['OK','NO'],5) log_debug (debug, 'Auth : %s' %str(status) ) tn.write('LISTSCRIPTS\r\n') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Current Scripts : %s' %str(status) ) #Send a Script script = 'keep;\r\nredirect "vacationprocessing@scom.ca";\r\n' count = len(script) count2 = script.count('\r\n') log_debug (debug, 'Count : %s' %count) log_debug (debug, 'Count 2 : %s' %count2) init = 'PUTSCRIPT "forward" {%s+}\r\n' %(count - count2) log_debug (debug, 'Init : %s' %init) tn.write ( init ) log_debug (debug, 'Script Len : %s' %len(script) ) log_debug (debug, 'Script : %s' %script) tn.write( script ) status = tn.expect(['OK','NO'],5) log_debug (debug, 'Write Status : %s' %str(status) ) log_debug (debug, 'Setting Active' ) tn.write('SETACTIVE "forward"\r\n') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Write Status : %s' %str(status) ) #logout tn.write('LOGOUT') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Logout Status : %s' %str(status) ) if (self.vacation_active == False and self.sieve_forwards == '') and dontupdate != True : #Deactivate Seive #debug = [debug,server,port,count,label,pid] debug = 'syslog,10.228.0.6,514,0,sieve,0' log_debug (debug, 'Sieve (Disable) : Do Not Update Status for : %s' %dontupdate ) import base64,telnetlib log_debug (debug, 'Disabling Sieve for : %s' %self.username) auth = '\0%s\0%s' %(self.username,self.password) log_debug (debug, 'Auth : %s' %auth) auth = base64.b64encode(auth) log_debug (debug, 'Auth Encoded : %s' %auth) from telnetlib import Telnet tn = Telnet('10.220.0.18', 4190) connect = tn.read_until('OK',5) log_debug (debug, 'Connect : \n%s\n' %connect) authout = 'AUTHENTICATE "PLAIN" "%s"\n'%auth log_debug (debug, 'Authout : %s' %authout) tn.write(authout) status = tn.expect(['OK','NO'],5) log_debug (debug, 'Auth : %s' %str(status) ) tn.write('LISTSCRIPTS\r\n') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Current Scripts : %s' %str(status) ) log_debug (debug, 'Setting Disabled' ) tn.write('SETACTIVE ""\r\n') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Write Status : %s' %str(status) ) #logout tn.write('LOGOUT') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Logout Status : %s' %str(status) )
#Check to see if forward is active
if (self.sieve_forwards != '' and self.vacation_active == False ) and
dontupdate != True: #debug = [debug,server,port,count,label,pid] debug = 'syslog,10.228.0.6,514,0,sieve,0' log_debug (debug, 'Do Not Update Status for : %s' %dontupdate ) import base64,telnetlib log_debug (debug, 'Enabling Sieve Forwards for : %s' %self.username ) auth = '\0%s\0%s' %(self.username,self.password) log_debug (debug, 'Auth : %s' %auth) auth = base64.b64encode(auth) log_debug (debug, 'Auth Encoded : %s' %auth) from telnetlib import Telnet tn = Telnet('10.220.0.18', 4190) connect = tn.read_until('OK',5) log_debug (debug, 'Connect : \n%s\n' %connect) authout = 'AUTHENTICATE "PLAIN" "%s"\n'%auth log_debug (debug, 'Authout : %s' %authout) tn.write(authout) status = tn.expect(['OK','NO'],5) log_debug (debug, 'Auth : %s' %str(status) ) tn.write('LISTSCRIPTS\r\n') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Current Scripts : %s' %str(status) ) #Send Script script = 'keep;\r\n' forwards = self.sieve_forwards.split(',') for nnn in range (0,len(forwards)) : script = script + 'redirect "%s";\r\n' %str(forwards[nnn]) count = len(script) count2 = script.count('\r\n') log_debug (debug, 'Count : %s' %count) log_debug (debug, 'Count 2 : %s' %count2) init = 'PUTSCRIPT "forward" {%s+}\r\n' %(count - count2 + len(forwards) - 1 ) log_debug (debug, 'Init : %s' %init) tn.write ( init ) log_debug (debug, 'Script Len : %s' %len(script) ) log_debug (debug, 'Script : %s' %script) tn.write( script ) status = tn.expect(['OK','NO'],5) log_debug (debug, 'Write Status : %s' %str(status) ) log_debug (debug, 'Setting Active' ) tn.write('SETACTIVE "forward"\r\n') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Write Status : %s' %str(status) ) #logout tn.write('LOGOUT') status = tn.expect(['OK','NO'],5) log_debug (debug, 'Logout Status : %s' %str(status) )
Happy Thursday !!! Thanks - paul
Paul Kudla
Scom.ca Internet Services <http://www.scom.ca> 004-1009 Byron Street South Whitby, Ontario - Canada L1N 4S3
Toronto 416.642.7266 Main 1.866.411.7266 Fax 1.888.892.7266 Email paul@scom.ca
On 10/26/2022 9:28 PM, Stephan Bosch wrote:
On 24-10-2022 12:00, Sebastian Bachmann wrote:
according to the documentation, this has to be added to the IMAP METADATA dict per mailbox (https://doc.dovecot.org/configuration_manual/imap_metadata/):
https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve/ says:
The basic IMAPSIEVE capability allows attaching a Sieve script to a mailbox for any mailbox by setting a special IMAP METADATA entry. This way, users can configure Sieve scripts that are run for IMAP events in their mailboxes. But I can not find any example how this should work, neither which client supports setting those things. My guess is that these keys are used: https://www.iana.org/assignments/imap-metadata/imap-metadata.xhtml#imap-meta...
I would also be interested to know if and how that works, especially if you can add a rule when moving mails (from anywhere) to a certain mailbox for a single user.
The basic capability works according to the specification: https://www.rfc-editor.org/rfc/rfc6785 This allows the users to configure these scripts.
If you want to arrange this solely at the administrator's discretion, you can use the _before/_after settings documented in https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve
Best, Sebastian
On 17.10.2022 12:46, Marc wrote:
I only see configurations that are active for all users, how to configure this in the user sieve rules. I only need this for specific users.
On 27.10.2022 13:54, Paul Kudla wrote:
again may (probably not) what you are looking for but it at least gives another example(s)
No, actually I was looking for something different. The TO and me were looking for imapsieve examples and how they can be configured on a per user & per mailbox basis.
I tried now some things, and I'm at least one step further. The important parts seemed to be:
- Enable IMAP METADATA
- Set
imapsieve_url = sieve://server:4190
(is that correct?)
Now you can add the metadata, for example to the mailbox "test": a SETMETADATA test (/shared/imapsieve/script "sieve/imap.sieve")
However, from this point on it does not work. I created a very simple example, which should simple copy any mail that is moved into the folder (right?):
require ["copy"]; redirect :copy "some_other_email_address";
but it looks like the script is never started. Is this because I mis-configured the path? Or something else? It is in the same folder as I store the other scripts, i.e., ~/sieve (the normal sieve scripts work fine)
-Sebastian
ok fair enuff
are you using a db to set the dir's
there is a master sieve (all) directory that handles the entire server (message duplicate supression etc)
mine is in
[17:26:12] mail18.scom.ca [root:0] /usr/local/etc/dovecot/sieve # ll total 38 drwxr-xr-x 2 vmail vmail uarch 4B Apr 2 2022 . drwxr-xr-x 5 root wheel uarch 29B Oct 27 07:41 .. -rw-r--r-- 1 vmail vmail uarch 97B Apr 2 2022 duplicates.sieve -rw-r--r-- 1 vmail vmail uarch 227B Apr 2 2022 duplicates.svbin
[17:26:17] mail18.scom.ca [root:0] /usr/local/etc/dovecot/sieve
from there each user (assuming dovecot config is correct will have it's own sieve folder under the maildir
example :
# mbox abuse@scom.ca
[17:27:24] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca # ll total 293 drwx------ 11 vmail vmail uarch 25B Oct 27 16:48 . drwx------ 164 vmail vmail uarch 164B Oct 27 06:52 .. drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Drafts drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Sent drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Trash -rw------- 1 vmail vmail uarch 1.4K Oct 26 16:49 .dovecot.lda-dupes drwx------ 5 vmail vmail uarch 7B Oct 27 16:48 .dovecot.lda-dupes.locks drwx------ 2 vmail vmail uarch 2B Oct 26 16:48 cur -rw------- 1 vmail vmail uarch 8.3K Oct 26 16:49 dovecot-uidlist -rw------- 1 vmail vmail uarch 8B Oct 26 16:49 dovecot-uidvalidity -r--r--r-- 1 vmail vmail uarch 0B Oct 26 16:48 dovecot-uidvalidity.63599d11 -rw------- 1 vmail vmail uarch 3.7K Oct 27 16:48 dovecot.index -rw------- 1 vmail vmail uarch 34K Oct 27 16:48 dovecot.index.cache -rw------- 1 vmail vmail uarch 644B Oct 27 16:48 dovecot.index.log -rw------- 1 vmail vmail uarch 40K Oct 27 16:48 dovecot.index.log.2 -rw------- 1 vmail vmail uarch 968B Oct 27 16:48 dovecot.list.index -rw------- 1 vmail vmail uarch 1.7K Oct 27 16:48 dovecot.list.index.log -rw------- 1 vmail vmail uarch 8.2K Oct 27 16:48 dovecot.list.index.log.2 -rw------- 1 vmail vmail uarch 96B Oct 26 16:48 dovecot.mailbox.log drwx------ 2 vmail vmail uarch 9B Oct 26 16:49 lucene-indexes -rw------- 1 vmail vmail uarch 0B Oct 26 16:48 maildirfolder drwx------ 2 vmail vmail uarch 142B Oct 26 16:49 new drwx------ 3 vmail vmail uarch 6B Oct 26 16:49 sieve -rw------- 1 vmail vmail uarch 29B Oct 26 16:48 subscriptions drwx------ 2 vmail vmail uarch 2B Oct 26 16:49 tmp
and then :
[17:27:42] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca/sieve # ll total 67 drwx------ 3 vmail vmail uarch 6B Oct 26 16:49 . drwx------ 11 vmail vmail uarch 25B Oct 27 16:48 .. lrwx------ 1 vmail vmail uarch 13B Oct 27 16:48 .dovecot.sieve -> forward.sieve -rw------- 1 vmail vmail uarch 239B Oct 26 16:49 .dovecot.svbin -rw------- 1 vmail vmail uarch 31B Oct 26 16:48 forward.sieve drwx------ 2 vmail vmail uarch 2B Oct 26 16:48 tmp
[17:27:44] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca/sieve
for a user script to be active you need to set the script active (after uploading etc?) which creates a link from dovecot.sieve to the script and a .svbin file (i believe, this is an observation on my side)
if all this is setup properly then the script should execute?
please note my system is db driven and i am using virtual maildir's
if you are doing this manually then make sure the dovecot's user right's are correct
you are probably far enough along the set
mail_debug = yes
in dovecot.conf (remember to restart the server)
this should dump a wack of logging somewhere (file or syslog)
sieve or pigeonhole will be in there when you try to do something
fyi
fyi
Happy Thursday !!! Thanks - paul
Paul Kudla
Scom.ca Internet Services <http://www.scom.ca> 004-1009 Byron Street South Whitby, Ontario - Canada L1N 4S3
Toronto 416.642.7266 Main 1.866.411.7266 Fax 1.888.892.7266 Email paul@scom.ca
On 10/27/2022 4:06 PM, Sebastian Bachmann wrote:
On 27.10.2022 13:54, Paul Kudla wrote:
again may (probably not) what you are looking for but it at least gives another example(s)
No, actually I was looking for something different. The TO and me were looking for imapsieve examples and how they can be configured on a per user & per mailbox basis.
I tried now some things, and I'm at least one step further. The important parts seemed to be:
- Enable IMAP METADATA
- Set
imapsieve_url = sieve://server:4190
(is that correct?)Now you can add the metadata, for example to the mailbox "test": a SETMETADATA test (/shared/imapsieve/script "sieve/imap.sieve")
However, from this point on it does not work. I created a very simple example, which should simple copy any mail that is moved into the folder (right?):
require ["copy"]; redirect :copy "some_other_email_address";
but it looks like the script is never started. Is this because I mis-configured the path? Or something else? It is in the same folder as I store the other scripts, i.e., ~/sieve (the normal sieve scripts work fine)
-Sebastian
Okay, I could have enabled debug log earlier, than that would have been easy... Thanks for the hint.
The key is to specify the sieve script inside the sieve directory without the .sieve suffix, i.e.:
a SETMETADATA test (/shared/imapsieve/script "imap")
which points to sieve/imap.sieve in the user's homedir.
Now it loads the script:
Debug: Mailbox test: Mailbox opened because: UID move
Debug: imapsieve: mailbox test: MOVE event
Debug: imapsieve: mailbox test: Mailbox attribute
/shared/imapsieve/script points to Sieve script imap' Debug: sieve: file script: Opened script
imap' from
/srv/vmail/username/sieve/imap.sieve' Debug: sieve: Opening script 1 of 1 from
/srv/vmail/username/sieve/imap.sieve'
Debug: sieve: Loading script /srv/vmail/username/sieve/imap.sieve
Debug: sieve: Script imap' from /srv/vmail/username/sieve/imap.sieve successfully compiled Debug: sieve: Executing script from
/srv/vmail/username/sieve/imap.sieve'
On 27.10.2022 23:33, Paul Kudla wrote:
ok fair enuff
are you using a db to set the dir's
there is a master sieve (all) directory that handles the entire server (message duplicate supression etc)
mine is in
[17:26:12] mail18.scom.ca [root:0] /usr/local/etc/dovecot/sieve # ll total 38 drwxr-xr-x 2 vmail vmail uarch 4B Apr 2 2022 . drwxr-xr-x 5 root wheel uarch 29B Oct 27 07:41 .. -rw-r--r-- 1 vmail vmail uarch 97B Apr 2 2022 duplicates.sieve -rw-r--r-- 1 vmail vmail uarch 227B Apr 2 2022 duplicates.svbin
[17:26:17] mail18.scom.ca [root:0] /usr/local/etc/dovecot/sieve
from there each user (assuming dovecot config is correct will have it's own sieve folder under the maildir
example :
# mbox abuse@scom.ca
[17:27:24] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca # ll total 293 drwx------ 11 vmail vmail uarch 25B Oct 27 16:48 . drwx------ 164 vmail vmail uarch 164B Oct 27 06:52 .. drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Drafts drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Sent drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Trash -rw------- 1 vmail vmail uarch 1.4K Oct 26 16:49 .dovecot.lda-dupes drwx------ 5 vmail vmail uarch 7B Oct 27 16:48 .dovecot.lda-dupes.locks drwx------ 2 vmail vmail uarch 2B Oct 26 16:48 cur -rw------- 1 vmail vmail uarch 8.3K Oct 26 16:49 dovecot-uidlist -rw------- 1 vmail vmail uarch 8B Oct 26 16:49 dovecot-uidvalidity -r--r--r-- 1 vmail vmail uarch 0B Oct 26 16:48 dovecot-uidvalidity.63599d11 -rw------- 1 vmail vmail uarch 3.7K Oct 27 16:48 dovecot.index -rw------- 1 vmail vmail uarch 34K Oct 27 16:48 dovecot.index.cache -rw------- 1 vmail vmail uarch 644B Oct 27 16:48 dovecot.index.log -rw------- 1 vmail vmail uarch 40K Oct 27 16:48 dovecot.index.log.2 -rw------- 1 vmail vmail uarch 968B Oct 27 16:48 dovecot.list.index -rw------- 1 vmail vmail uarch 1.7K Oct 27 16:48 dovecot.list.index.log -rw------- 1 vmail vmail uarch 8.2K Oct 27 16:48 dovecot.list.index.log.2 -rw------- 1 vmail vmail uarch 96B Oct 26 16:48 dovecot.mailbox.log drwx------ 2 vmail vmail uarch 9B Oct 26 16:49 lucene-indexes -rw------- 1 vmail vmail uarch 0B Oct 26 16:48 maildirfolder drwx------ 2 vmail vmail uarch 142B Oct 26 16:49 new drwx------ 3 vmail vmail uarch 6B Oct 26 16:49 sieve -rw------- 1 vmail vmail uarch 29B Oct 26 16:48 subscriptions drwx------ 2 vmail vmail uarch 2B Oct 26 16:49 tmp
and then :
[17:27:42] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca/sieve # ll total 67 drwx------ 3 vmail vmail uarch 6B Oct 26 16:49 . drwx------ 11 vmail vmail uarch 25B Oct 27 16:48 .. lrwx------ 1 vmail vmail uarch 13B Oct 27 16:48 .dovecot.sieve -> forward.sieve -rw------- 1 vmail vmail uarch 239B Oct 26 16:49 .dovecot.svbin -rw------- 1 vmail vmail uarch 31B Oct 26 16:48 forward.sieve drwx------ 2 vmail vmail uarch 2B Oct 26 16:48 tmp
[17:27:44] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca/sieve
for a user script to be active you need to set the script active (after uploading etc?) which creates a link from dovecot.sieve to the script and a .svbin file (i believe, this is an observation on my side)
if all this is setup properly then the script should execute?
please note my system is db driven and i am using virtual maildir's
if you are doing this manually then make sure the dovecot's user right's are correct
you are probably far enough along the set
mail_debug = yes
in dovecot.conf (remember to restart the server)
this should dump a wack of logging somewhere (file or syslog)
sieve or pigeonhole will be in there when you try to do something
fyi
fyi
Happy Thursday !!! Thanks - paul
Paul Kudla
Scom.ca Internet Services <http://www.scom.ca> 004-1009 Byron Street South Whitby, Ontario - Canada L1N 4S3
Toronto 416.642.7266 Main 1.866.411.7266 Fax 1.888.892.7266 Email paul@scom.ca
On 10/27/2022 4:06 PM, Sebastian Bachmann wrote:
On 27.10.2022 13:54, Paul Kudla wrote:
again may (probably not) what you are looking for but it at least gives another example(s)
No, actually I was looking for something different. The TO and me were looking for imapsieve examples and how they can be configured on a per user & per mailbox basis.
I tried now some things, and I'm at least one step further. The important parts seemed to be:
- Enable IMAP METADATA
- Set
imapsieve_url = sieve://server:4190
(is that correct?)Now you can add the metadata, for example to the mailbox "test": a SETMETADATA test (/shared/imapsieve/script "sieve/imap.sieve")
However, from this point on it does not work. I created a very simple example, which should simple copy any mail that is moved into the folder (right?):
require ["copy"]; redirect :copy "some_other_email_address";
but it looks like the script is never started. Is this because I mis-configured the path? Or something else? It is in the same folder as I store the other scripts, i.e., ~/sieve (the normal sieve scripts work fine)
-Sebastian
ok so are you good to go???
Happy Friday !!! Thanks - paul
Paul Kudla
Scom.ca Internet Services <http://www.scom.ca> 004-1009 Byron Street South Whitby, Ontario - Canada L1N 4S3
Toronto 416.642.7266 Main 1.866.411.7266 Fax 1.888.892.7266 Email paul@scom.ca
On 10/28/2022 2:13 AM, Sebastian Bachmann wrote:
Okay, I could have enabled debug log earlier, than that would have been easy... Thanks for the hint.
The key is to specify the sieve script inside the sieve directory without the .sieve suffix, i.e.:
a SETMETADATA test (/shared/imapsieve/script "imap")
which points to sieve/imap.sieve in the user's homedir.
Now it loads the script:
Debug: Mailbox test: Mailbox opened because: UID move Debug: imapsieve: mailbox test: MOVE event Debug: imapsieve: mailbox test: Mailbox attribute /shared/imapsieve/script points to Sieve script
imap' Debug: sieve: file script: Opened script
imap' from/srv/vmail/username/sieve/imap.sieve' Debug: sieve: Opening script 1 of 1 from
/srv/vmail/username/sieve/imap.sieve' Debug: sieve: Loading script /srv/vmail/username/sieve/imap.sieve Debug: sieve: Scriptimap' from /srv/vmail/username/sieve/imap.sieve successfully compiled Debug: sieve: Executing script from
/srv/vmail/username/sieve/imap.sieve'On 27.10.2022 23:33, Paul Kudla wrote:
ok fair enuff
are you using a db to set the dir's
there is a master sieve (all) directory that handles the entire server (message duplicate supression etc)
mine is in
[17:26:12] mail18.scom.ca [root:0] /usr/local/etc/dovecot/sieve # ll total 38 drwxr-xr-x 2 vmail vmail uarch 4B Apr 2 2022 . drwxr-xr-x 5 root wheel uarch 29B Oct 27 07:41 .. -rw-r--r-- 1 vmail vmail uarch 97B Apr 2 2022 duplicates.sieve -rw-r--r-- 1 vmail vmail uarch 227B Apr 2 2022 duplicates.svbin
[17:26:17] mail18.scom.ca [root:0] /usr/local/etc/dovecot/sieve
from there each user (assuming dovecot config is correct will have it's own sieve folder under the maildir
example :
# mbox abuse@scom.ca
[17:27:24] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca # ll total 293 drwx------ 11 vmail vmail uarch 25B Oct 27 16:48 . drwx------ 164 vmail vmail uarch 164B Oct 27 06:52 .. drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Drafts drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Sent drwx------ 5 vmail vmail uarch 8B Oct 27 16:48 .Trash -rw------- 1 vmail vmail uarch 1.4K Oct 26 16:49 .dovecot.lda-dupes drwx------ 5 vmail vmail uarch 7B Oct 27 16:48 .dovecot.lda-dupes.locks drwx------ 2 vmail vmail uarch 2B Oct 26 16:48 cur -rw------- 1 vmail vmail uarch 8.3K Oct 26 16:49 dovecot-uidlist -rw------- 1 vmail vmail uarch 8B Oct 26 16:49 dovecot-uidvalidity -r--r--r-- 1 vmail vmail uarch 0B Oct 26 16:48 dovecot-uidvalidity.63599d11 -rw------- 1 vmail vmail uarch 3.7K Oct 27 16:48 dovecot.index -rw------- 1 vmail vmail uarch 34K Oct 27 16:48 dovecot.index.cache -rw------- 1 vmail vmail uarch 644B Oct 27 16:48 dovecot.index.log -rw------- 1 vmail vmail uarch 40K Oct 27 16:48 dovecot.index.log.2 -rw------- 1 vmail vmail uarch 968B Oct 27 16:48 dovecot.list.index -rw------- 1 vmail vmail uarch 1.7K Oct 27 16:48 dovecot.list.index.log -rw------- 1 vmail vmail uarch 8.2K Oct 27 16:48 dovecot.list.index.log.2 -rw------- 1 vmail vmail uarch 96B Oct 26 16:48 dovecot.mailbox.log drwx------ 2 vmail vmail uarch 9B Oct 26 16:49 lucene-indexes -rw------- 1 vmail vmail uarch 0B Oct 26 16:48 maildirfolder drwx------ 2 vmail vmail uarch 142B Oct 26 16:49 new drwx------ 3 vmail vmail uarch 6B Oct 26 16:49 sieve -rw------- 1 vmail vmail uarch 29B Oct 26 16:48 subscriptions drwx------ 2 vmail vmail uarch 2B Oct 26 16:49 tmp
and then :
[17:27:42] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca/sieve # ll total 67 drwx------ 3 vmail vmail uarch 6B Oct 26 16:49 . drwx------ 11 vmail vmail uarch 25B Oct 27 16:48 .. lrwx------ 1 vmail vmail uarch 13B Oct 27 16:48 .dovecot.sieve -> forward.sieve -rw------- 1 vmail vmail uarch 239B Oct 26 16:49 .dovecot.svbin -rw------- 1 vmail vmail uarch 31B Oct 26 16:48 forward.sieve drwx------ 2 vmail vmail uarch 2B Oct 26 16:48 tmp
[17:27:44] mail18.scom.ca [root:0] /data/dovecot/users/scom.ca/abuse@scom.ca/sieve
for a user script to be active you need to set the script active (after uploading etc?) which creates a link from dovecot.sieve to the script and a .svbin file (i believe, this is an observation on my side)
if all this is setup properly then the script should execute?
please note my system is db driven and i am using virtual maildir's
if you are doing this manually then make sure the dovecot's user right's are correct
you are probably far enough along the set
mail_debug = yes
in dovecot.conf (remember to restart the server)
this should dump a wack of logging somewhere (file or syslog)
sieve or pigeonhole will be in there when you try to do something
fyi
fyi
Happy Thursday !!! Thanks - paul
Paul Kudla
Scom.ca Internet Services <http://www.scom.ca> 004-1009 Byron Street South Whitby, Ontario - Canada L1N 4S3
Toronto 416.642.7266 Main 1.866.411.7266 Fax 1.888.892.7266 Email paul@scom.ca
On 10/27/2022 4:06 PM, Sebastian Bachmann wrote:
On 27.10.2022 13:54, Paul Kudla wrote:
again may (probably not) what you are looking for but it at least gives another example(s)
No, actually I was looking for something different. The TO and me were looking for imapsieve examples and how they can be configured on a per user & per mailbox basis.
I tried now some things, and I'm at least one step further. The important parts seemed to be:
- Enable IMAP METADATA
- Set
imapsieve_url = sieve://server:4190
(is that correct?)Now you can add the metadata, for example to the mailbox "test": a SETMETADATA test (/shared/imapsieve/script "sieve/imap.sieve")
However, from this point on it does not work. I created a very simple example, which should simple copy any mail that is moved into the folder (right?):
require ["copy"]; redirect :copy "some_other_email_address";
but it looks like the script is never started. Is this because I mis-configured the path? Or something else? It is in the same folder as I store the other scripts, i.e., ~/sieve (the normal sieve scripts work fine)
-Sebastian
On 2022-10-27 02:28, Stephan Bosch wrote:
On 24-10-2022 12:00, Sebastian Bachmann wrote:
according to the documentation, this has to be added to the IMAP METADATA dict per mailbox (https://doc.dovecot.org/configuration_manual/imap_metadata/):
https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve/ says:
The basic IMAPSIEVE capability allows attaching a Sieve script to a mailbox for any mailbox by setting a special IMAP METADATA entry. This way, users can configure Sieve scripts that are run for IMAP events in their mailboxes. But I can not find any example how this should work, neither which client supports setting those things. My guess is that these keys are used: https://www.iana.org/assignments/imap-metadata/imap-metadata.xhtml#imap-meta...
I would also be interested to know if and how that works, especially if you can add a rule when moving mails (from anywhere) to a certain mailbox for a single user.
The basic capability works according to the specification: https://www.rfc-editor.org/rfc/rfc6785 This allows the users to configure these scripts.
If you want to arrange this solely at the administrator's discretion, you can use the _before/_after settings documented in https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve
Best, Sebastian
On 17.10.2022 12:46, Marc wrote:
I only see configurations that are active for all users, how to configure this in the user sieve rules. I only need this for specific users.
Why dont you use pigeonholes?
Also, I recommend to look for Symlink creation titled post here in the mailing list, there is few points in about setting up per user sieve scripts that will be helpful to you.
Also, there is other posts on how to setup sieve for per user scripts.
Zakaria.
My apologies to the response eariler
I was making the assumption that you were using pigeonholes
it needs to be compiled seperately after making dovecot's server installs
basically the pigeonholes has to be compiled against the dovecot version you are running
after which my post info will be valid.
fyi .....
Happy Thursday !!! Thanks - paul
Paul Kudla
Scom.ca Internet Services <http://www.scom.ca> 004-1009 Byron Street South Whitby, Ontario - Canada L1N 4S3
Toronto 416.642.7266 Main 1.866.411.7266 Fax 1.888.892.7266 Email paul@scom.ca
On 10/27/2022 9:48 AM, dovecot-bounces@dovecot.org wrote:
On 2022-10-27 02:28, Stephan Bosch wrote:
On 24-10-2022 12:00, Sebastian Bachmann wrote:
according to the documentation, this has to be added to the IMAP METADATA dict per mailbox (https://doc.dovecot.org/configuration_manual/imap_metadata/):
https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve/ says:
The basic IMAPSIEVE capability allows attaching a Sieve script to a mailbox for any mailbox by setting a special IMAP METADATA entry. This way, users can configure Sieve scripts that are run for IMAP events in their mailboxes. But I can not find any example how this should work, neither which client supports setting those things. My guess is that these keys are used: https://www.iana.org/assignments/imap-metadata/imap-metadata.xhtml#imap-meta...
I would also be interested to know if and how that works, especially if you can add a rule when moving mails (from anywhere) to a certain mailbox for a single user.
The basic capability works according to the specification: https://www.rfc-editor.org/rfc/rfc6785 This allows the users to configure these scripts.
If you want to arrange this solely at the administrator's discretion, you can use the _before/_after settings documented in https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve
Best, Sebastian
On 17.10.2022 12:46, Marc wrote:
I only see configurations that are active for all users, how to configure this in the user sieve rules. I only need this for specific users.
Why dont you use pigeonholes?
Also, I recommend to look for Symlink creation titled post here in the mailing list, there is few points in about setting up per user sieve scripts that will be helpful to you.
Also, there is other posts on how to setup sieve for per user scripts.
Zakaria.
On 10/17/22 04:46, Marc wrote:
I only see configurations that are active for all users, how to configure this in the user sieve rules. I only need this for specific users.
I have a working setup where every user can have their own sieve rules and manage them with managesieve, which I think is provided by pigeonhole. I have a very extensive sieve script on my mailbox that has been built using a managesieve plugin for Roundcube webmail. I tried to get an extension for Thunderbird going, but it doesn't work in the latest Thunderbird (102 at the time), and now that I am running a version 106 beta, that support is even less likely to happen.
This output should cover all my sieve-related configs:
https://paste.elyograg.org/view/c34f48ee
My users are in a mysql postfixadmin database. The username is the fully qualified email address. It's installed on a AWS instance running Ubuntu Server 20.04. I do want to upgrade that to Ubuntu 22, but a lot of my PHP software will not run on PHP 8.1, which is what Ubuntu 22 includes. So I am waiting for that.
Thanks, Shawn
The sieve Thunderbird add-on is broken very often - there is a standalone version as well which works much better. If the newest version does not work, check some older releases.
29.10.2022 00:54:47 Shawn Heisey <elyograg@elyograg.org>:
On 10/17/22 04:46, Marc wrote:
I only see configurations that are active for all users, how to configure this in the user sieve rules. I only need this for specific users.
I have a working setup where every user can have their own sieve rules and manage them with managesieve, which I think is provided by pigeonhole. I have a very extensive sieve script on my mailbox that has been built using a managesieve plugin for Roundcube webmail. I tried to get an extension for Thunderbird going, but it doesn't work in the latest Thunderbird (102 at the time), and now that I am running a version 106 beta, that support is even less likely to happen.
This output should cover all my sieve-related configs:
https://paste.elyograg.org/view/c34f48ee
My users are in a mysql postfixadmin database. The username is the fully qualified email address. It's installed on a AWS instance running Ubuntu Server 20.04. I do want to upgrade that to Ubuntu 22, but a lot of my PHP software will not run on PHP 8.1, which is what Ubuntu 22 includes. So I am waiting for that.
Thanks, Shawn
participants (7)
-
hi@zakaria.website
-
Marc
-
Paul Kudla
-
Sebastian Bachmann
-
Shawn Heisey
-
spi
-
Stephan Bosch