imapsieve: Change message flags on COPY
Hello, I'm trying to do a simple thing using imapsieve, I want messages to be marked as read when moved to certain folders (Trash, Archive, Spam).
All the set up to run the imapsieve script works perfectly, but I'm having trouble to make changes effective. As the RFC says, IMAP messages are immutable, but it's not clear to me reading the specs if this applies to IMAP flags too, as one can really change flags in IMAP without having to create a new (modified) message, I guess this is an exception?
3.8. The "setflag", "deleteflag", and "removeflag" Actions
Implementations of IMAP events in Sieve MUST also support the imap4flags extension [RFC5232], and the actions associated with it are all applicable to any case that falls under IMAP events in Sieve.
It is worth noting also that the "hasflag" test that is defined in the imap4flags extension might be particularly useful in scripts triggered by flag changes ("hasflag" will see the new, changed flags). The flag changes behave as though a client had made the change.
As explained above, in order to avoid script loops, flag changes that are made as a result of a script that was itself invoked because of flag changes SHOULD NOT result in another script invocation. In any case, implementations MUST take steps to avoid such loops.
https://tools.ietf.org/html/rfc6785
Should changing flags just work for imapsieve? I even tried to use fileinto to explicitly save a new message (as far as I understand if I use fileinto the implicit keep should be cancelled, so the original message should be flagged as \Deleted (this is another hint that changing flags in immutable messages should be fine), and a new message should be created with the changed flags. But this is not happening, after moving the message I see unseen message still not flagged with \Seen.
This is my imapsieve script:
require ["variables", "imap4flags", "fileinto", "vnd.dovecot.imapsieve", "vnd.dovecot.environment", "vnd.dovecot.execute", "vnd.dovecot.debug"];
if header :matches "Subject" "*" { set "subject" "${1}"; } if header :matches "From" "*" { set "from" "${1}"; } if environment :matches "imap.mailbox" "*" { set "dst" "${1}"; }
debug_log "IMAPSIEVE TEST ---------------------"; debug_log "subject:${subject}"; debug_log "from:${from}"; debug_log "dst:${dst}"; debug_log "END IMAPSIEVE TEST -----------------";
if string :is "${dst}" ["Archive", "Trash", "Spam", "Sent"] { debug_log "Moved to ${dst}, marking as read: '${subject}' <${from>"; setflag "\\Seen"; fileinto "${dst}"; }
This is the log:
Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: Archive: Mailbox opened because: UID MOVE
Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: Mailbox INBOX: Opened mail UID=13304 because: copying
Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: imapsieve: mailbox Archive: MOVE event
Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: imapsieve: Matched static mailbox rule [1]
Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: file storage: Using Sieve script path: /home/luca/sieve/imapsieve.sieve
Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: file script: Opened script imapsieve' from
/home/luca/sieve/imapsieve.sieve'
Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: Opening script 1 of 1 from /home/luca/sieve/imapsieve.sieve' Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: Loading script /home/luca/sieve/imapsieve.sieve Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: Script binary /home/luca/sieve/imapsieve.svbin successfully loaded Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: binary save: not saving binary /home/luca/sieve/imapsieve.svbin, because it is already stored Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: Executing script from
/home/luca/sieve/imapsieve.svbin'
Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 11: DEBUG: IMAPSIEVE TEST ---------------------
Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 12: DEBUG: subject:Ihr DHL Paket wurde zugestellt.
Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 13: DEBUG: from:DHL Paket noreply@dhl.de
Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 16: DEBUG: dst:Archive
Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 17: DEBUG: END IMAPSIEVE TEST -----------------
Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 23: DEBUG: Moved to Archive, marking as read: 'Ihr DHL Paket wurde zugestellt.'
The last line looks weird, it seems like the message is not being copied, right? I tried adding a stop; too, as suggested in this thread https://www.dovecot.org/list/dovecot/2017-April/107658.html, but the effect is the same, the message in Archive is still not flagged as \Seen.
So the main question here is if changing IMAP flags in imapsieve scripts shouldn't just work, without even having to use fileinto, and if not, why isn't even using fileinto working?
PS: Please Cc me, I'm not in the list.
Thanks!
-- Leandro Lucarella (Luca) https://llucax.com
What is your configuration (output from dovecot -n
)?
Op 16/08/2018 om 14:01 schreef Leandro Lucarella:
Hello, I'm trying to do a simple thing using imapsieve, I want messages to be marked as read when moved to certain folders (Trash, Archive, Spam).
All the set up to run the imapsieve script works perfectly, but I'm having trouble to make changes effective. As the RFC says, IMAP messages are immutable, but it's not clear to me reading the specs if this applies to IMAP flags too, as one can really change flags in IMAP without having to create a new (modified) message, I guess this is an exception?
3.8. The "setflag", "deleteflag", and "removeflag" Actions
Implementations of IMAP events in Sieve MUST also support the imap4flags extension [RFC5232], and the actions associated with it are all applicable to any case that falls under IMAP events in Sieve. It is worth noting also that the "hasflag" test that is defined in the imap4flags extension might be particularly useful in scripts triggered by flag changes ("hasflag" will see the new, changed flags). The flag changes behave as though a client had made the change. As explained above, in order to avoid script loops, flag changes that are made as a result of a script that was itself invoked because of flag changes SHOULD NOT result in another script invocation. In any case, implementations MUST take steps to avoid such loops.
https://tools.ietf.org/html/rfc6785
Should changing flags just work for imapsieve? I even tried to use fileinto to explicitly save a new message (as far as I understand if I use fileinto the implicit keep should be cancelled, so the original message should be flagged as \Deleted (this is another hint that changing flags in immutable messages should be fine), and a new message should be created with the changed flags. But this is not happening, after moving the message I see unseen message still not flagged with \Seen.
This is my imapsieve script:
require ["variables", "imap4flags", "fileinto", "vnd.dovecot.imapsieve", "vnd.dovecot.environment", "vnd.dovecot.execute", "vnd.dovecot.debug"];
if header :matches "Subject" "*" { set "subject" "${1}"; } if header :matches "From" "*" { set "from" "${1}"; } if environment :matches "imap.mailbox" "*" { set "dst" "${1}"; }
debug_log "IMAPSIEVE TEST ---------------------"; debug_log "subject:${subject}"; debug_log "from:${from}"; debug_log "dst:${dst}"; debug_log "END IMAPSIEVE TEST -----------------";
if string :is "${dst}" ["Archive", "Trash", "Spam", "Sent"] { debug_log "Moved to ${dst}, marking as read: '${subject}' <${from>"; setflag "\\Seen"; fileinto "${dst}"; }
This is the log: Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: Archive: Mailbox opened because: UID MOVE Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: Mailbox INBOX: Opened mail UID=13304 because: copying Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: imapsieve: mailbox Archive: MOVE event Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: imapsieve: Matched static mailbox rule [1] Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: file storage: Using Sieve script path: /home/luca/sieve/imapsieve.sieve Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: file script: Opened script
imapsieve' from
/home/luca/sieve/imapsieve.sieve' Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: Opening script 1 of 1 from/home/luca/sieve/imapsieve.sieve' Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: Loading script /home/luca/sieve/imapsieve.sieve Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: Script binary /home/luca/sieve/imapsieve.svbin successfully loaded Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: binary save: not saving binary /home/luca/sieve/imapsieve.svbin, because it is already stored Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: sieve: Executing script from
/home/luca/sieve/imapsieve.svbin' Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 11: DEBUG: IMAPSIEVE TEST --------------------- Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 12: DEBUG: subject:Ihr DHL Paket wurde zugestellt. Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 13: DEBUG: from:DHL Paket noreply@dhl.de Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 16: DEBUG: dst:Archive Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 17: DEBUG: END IMAPSIEVE TEST ----------------- Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: imapsieve: line 23: DEBUG: Moved to Archive, marking as read: 'Ihr DHL Paket wurde zugestellt.'noreply@dhl.de> Aug 16 10:31:51 alerce dovecot: imap(luca): Debug: Archive: Mailbox opened because: lib-lda delivery Aug 16 10:31:51 alerce dovecot: imap(luca): sieve: left message in mailbox 'Archive' The last line looks weird, it seems like the message is not being copied, right? I tried adding a stop; too, as suggested in this thread https://www.dovecot.org/list/dovecot/2017-April/107658.html, but the effect is the same, the message in Archive is still not flagged as \Seen.
So the main question here is if changing IMAP flags in imapsieve scripts shouldn't just work, without even having to use fileinto, and if not, why isn't even using fileinto working?
PS: Please Cc me, I'm not in the list.
Thanks!
On Friday 17 August 2018 01:41:39 CEST Stephan Bosch wrote:
dovecot -n
Hi, here it is (I don't know why I get the SSLv2 warning because it is disabled in ssl_protocols, any ideas about that too?).
BTW, even when storing the message in a different folder with fileinto,
the original message is still saved in the original mailbox. I also tried
using discard;
and makes no difference, I can never get rid of the
original message.
# dovecot -n # 2.2.33.2 (d6601f4ec): /etc/dovecot/dovecot.conf # Pigeonhole version 0.4.21 (92477967) doveconf: Warning: SSLv2 not supported by OpenSSL. Please consider removing it from ssl_protocols. doveconf: Warning: SSLv2 not supported by OpenSSL. Please consider removing it from ssl_protocols. # OS: Linux 4.15.0-30-generic x86_64 Ubuntu 18.04.1 LTS mail_location = mbox:~/mail:INBOX=/var/mail/%u mail_privileged_group = mail managesieve_notify_capability = mailto managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relationa l regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttex t editheader vnd.dovecot.debug vnd.dovecot.environment imapsieve vnd.dovecot.imapsieve vnd.dovecot.pipe vnd.dovecot.filter vnd.dov ecot.execute namespace inbox { inbox = yes location = mailbox Drafts { special_use = \Drafts } mailbox Junk { special_use = \Junk } mailbox Sent { special_use = \Sent } mailbox "Sent Messages" { special_use = \Sent } mailbox Trash { special_use = \Trash } prefix = } passdb { args = scheme=CRYPT username_format=%u /etc/dovecot/users driver = passwd-file } plugin { imapsieve_mailbox1_before = file:~/sieve/imapsieve.sieve imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_name = * sieve = file:~/sieve;active=~/.dovecot.sieve sieve_execute_bin_dir = /usr/local/lib/dovecot/sieve-bin sieve_extensions = +editheader +vnd.dovecot.execute +vnd.dovecot.filter +vnd.dovecot.pipe +vnd.dovecot.debug +vnd.dovecot.enviro nment sieve_filter_bin_dir = /usr/local/lib/dovecot/sieve-bin sieve_pipe_bin_dir = /usr/lib/dovecot/sieve-bin sieve_plugins = sieve_imapsieve sieve_extprograms } protocols = " imap lmtp sieve pop3 sieve" service imap-login { inet_listener imap { port = 0 } inet_listener imaps { port = 1993 } } service pop3-login { inet_listener pop3 { port = 0 } inet_listener pop3s { port = 1995 } } ssl = required ssl_cert =
-- Leandro Lucarella (Luca) https://llucax.com
Op 17/08/2018 om 19:44 schreef Leandro Lucarella:
On Friday 17 August 2018 01:41:39 CEST Stephan Bosch wrote:
dovecot -n
I tried your configuration here with your Sieve script. It works here as expected with or without the fileinto action (so also with only setflag).
I changed your script a little to detect "INBOX/Archive" rather than just "Archive" to match my setup.
Testing looked as follows (using /usr/lib/dovecot/imap from command line):
- Create two mailboxes, one of which will trigger the flag rule:
2343 CREATE INBOX/Archive imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: Namespace INBOX/: /home/stephan/Maildir/.Archive doesn't exist yet, using default permissions imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: Namespace INBOX/: Using permissions from /home/stephan/Maildir: mode=0700 gid=default imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: acl vfile: file /home/stephan/Maildir/.Archive/dovecot-acl not found imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX: Debug: Mailbox opened because: copy caching decisions imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX/Archive: Debug: Mailbox opened because: CREATE imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: /home/stephan/Maildir/.Archive/dovecot.index.cache: Compressed, file_seq changed 0 -> 1534536851, size=32, max_uid=0 2343 OK Create completed (0.061 + 0.000 + 0.060 secs). 234 CREATE INBOX/Storage imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: Namespace INBOX/: /home/stephan/Maildir/.Storage doesn't exist yet, using default permissions imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: Namespace INBOX/: Using permissions from /home/stephan/Maildir: mode=0700 gid=default imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX: Debug: Mailbox opened because: copy caching decisions imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX/Storage: Debug: Mailbox opened because: CREATE imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: /home/stephan/Maildir/.Storage/dovecot.index.cache: Compressed, file_seq changed 0 -> 1534536860, size=32, max_uid=0 234 OK Create completed (0.059 + 0.000 + 0.058 secs).
- Choose a message from INBOX (in this case without any flags assigned):
23423 SELECT INBOX imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX: Debug: Mailbox opened because: SELECT
- FLAGS (\Answered \Flagged \Deleted \Seen \Draft $MailFlagBit1 $label1 Flagged FreeBSD $Label3 $Label5 $Label4 $Label2)
- OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $MailFlagBit1 $label1 Flagged FreeBSD $Label3 $Label5 $Label4 $Label2 \*)] Flags permitted.
- 57 EXISTS
- 0 RECENT
- OK [UNSEEN 6] First unseen.
- OK [UIDVALIDITY 1415917190] UIDs valid
- OK [UIDNEXT 430] Predicted next UID
- OK [HIGHESTMODSEQ 800] Highest 23423 OK [READ-WRITE] Select completed (0.001 + 0.000 secs). 233 FETCH 40 FLAGS
- 40 FETCH (FLAGS ()) 233 OK Fetch completed (0.000 + 0.000 secs).
- Copy it to archive mailbox first:
23423 COPY 40 INBOX/Archive
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX/Archive:
Debug: Mailbox opened because: COPY
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: mailbox
INBOX/Archive: COPY event
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: mailbox
INBOX/Archive: Mailbox attribute /shared/imapsieve/script not found
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: mailbox
INBOX/Archive: Server attribute /shared/imapsieve/script not found
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Pigeonhole
version 0.6.devel (c7bd7456) initializing
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Sieve
imapsieve plugin for Pigeonhole version 0.6.devel (c7bd7456) loaded
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Sieve
Extprograms plugin for Pigeonhole version 0.6.devel (c7bd7456) loaded
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve:
vnd.dovecot.pipe extension: no bin or socket directory specified;
extension is unconfigured (both sieve_pipe_bin_dir and
sieve_pipe_socket_dir are not set)
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve:
vnd.dovecot.filter extension: no bin or socket directory specified;
extension is unconfigured (both sieve_filter_bin_dir and
sieve_filter_socket_dir are not set)
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve:
vnd.dovecot.execute extension: no bin or socket directory specified;
extension is unconfigured (both sieve_execute_bin_dir and
sieve_execute_socket_dir are not set)
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: Static
mailbox rule [1]: mailbox=Spam' from=
*' causes=(COPY) =>
before=file:/usr/lib/dovecot/sieve/report-spam.sieve' after=(none) imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: Static mailbox rule [2]: mailbox=
*' from=Spam' causes=(COPY) => before=
file:/usr/lib/dovecot/sieve/report-ham.sieve' after=(none)
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: Static
mailbox rule [3]: mailbox=*' from=
*' causes=(COPY) =>
before=file:~/imapsieve.sieve' after=(none) imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: Matched static mailbox rule [3] imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: file storage: Using Sieve script path: /home/stephan/imapsieve.sieve imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: file script: Opened script
imapsieve' from /home/stephan/imapsieve.sieve' imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Opening script 1 of 1 from
/home/stephan/imapsieve.sieve'
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Loading
script /home/stephan/imapsieve.sieve
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Script
binary /home/stephan/imapsieve.svbin successfully loaded
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: binary save:
not saving binary /home/stephan/imapsieve.svbin, because it is already
stored
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Executing
script from `/home/stephan/imapsieve.svbin'
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve:
line 9: DEBUG: IMAPSIEVE TEST ---------------------
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve:
line 10: DEBUG: subject:Frop!
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve:
line 11: DEBUG: from:stephan@rename-it.nl
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve:
line 12: DEBUG: dst:INBOX/Archive
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve:
line 13: DEBUG: END IMAPSIEVE TEST -----------------
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve:
line 17: DEBUG: Moved to INBOX/Archive, marking as read: 'Frop!' <${from>
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: left message
in mailbox 'INBOX/Archive'
23423 OK [COPYUID 1415917215 412 1] Copy completed (0.068 + 0.000 +
0.067 secs).
- Verify that \Seen flag is assigned:
23423 SELECT INBOX/Archive imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX/Archive: Debug: Mailbox opened because: SELECT
- OK [CLOSED] Previous mailbox closed.
- FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
- OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
- 1 EXISTS
- 1 RECENT
- OK [UIDVALIDITY 1415917215] UIDs valid
- OK [UIDNEXT 2] Predicted next UID 23423 OK [READ-WRITE] Select completed (0.001 + 0.000 secs). 234234 FETCH 1 FLAGS
- 1 FETCH (FLAGS (\Seen \Recent)) 234234 OK Fetch completed (0.001 + 0.000 secs).
- Go back to INBOX and copy the same message to the other recently-created mailbox:
23423 SELECT INBOX imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX: Debug: Mailbox opened because: SELECT script 1 of 1 from `/home/stephan/imapsieve.sieve'
- OK [CLOSED] Previous mailbox closed.
- FLAGS (\Answered \Flagged \Deleted \Seen \Draft $MailFlagBit1 $label1 Flagged FreeBSD $Label3 $Label5 $Label4 $Label2)
- OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $MailFlagBit1 $label1 Flagged FreeBSD $Label3 $Label5 $Label4 $Label2 \*)] Flags permitted.
- 57 EXISTS
- 0 RECENT
- OK [UNSEEN 6] First unseen.
- OK [UIDVALIDITY 1415917190] UIDs valid
- OK [UIDNEXT 430] Predicted next UID
- OK [HIGHESTMODSEQ 800] Highest
23423 OK [READ-WRITE] Select completed (0.001 + 0.000 secs).
2423 COPY 40 INBOX/Storage
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX/Storage:
Debug: Mailbox opened because: COPY
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: mailbox
INBOX/Storage: COPY event
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: mailbox
INBOX/Storage: Mailbox attribute /shared/imapsieve/script not found
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: mailbox
INBOX/Storage: Server attribute /shared/imapsieve/script not found
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: imapsieve: Matched
static mailbox rule [3]
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: file
storage: Using Sieve script path: /home/stephan/imapsieve.sieve
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: file script:
Opened script
imapsieve' from
/home/stephan/imapsieve.sieve' imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Opening
imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Loading script /home/stephan/imapsieve.sieve imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Script binary /home/stephan/imapsieve.svbin successfully loaded imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: binary save: not saving binary /home/stephan/imapsieve.svbin, because it is already stored imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Debug: sieve: Executing script from `/home/stephan/imapsieve.svbin' imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve: line 9: DEBUG: IMAPSIEVE TEST --------------------- imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve: line 10: DEBUG: subject:Frop! imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve: line 11: DEBUG: from:stephan@rename-it.nl imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve: line 12: DEBUG: dst:INBOX/Storage imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: imapsieve: line 13: DEBUG: END IMAPSIEVE TEST ----------------- imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Info: sieve: left message in mailbox 'INBOX/Storage' 2423 OK [COPYUID 1415917216 412 1] Copy completed (0.066 + 0.000 + 0.065 secs).
- Verify that \Seen flag is not assigned:
23423 SELECT INBOX/Storage imap(stephan)<15247><fmJGKYEsd1uPOwAAmoV78g>: Mailbox INBOX/Storage: Debug: Mailbox opened because: SELECT
- OK [CLOSED] Previous mailbox closed.
- FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
- OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
- 1 EXISTS
- 1 RECENT
- OK [UNSEEN 1] First unseen.
- OK [UIDVALIDITY 1415917216] UIDs valid
- OK [UIDNEXT 2] Predicted next UID 23423 OK [READ-WRITE] Select completed (0.001 + 0.000 secs). 423 FETCH 1 FLAGS
- 1 FETCH (FLAGS (\Recent)) 423 OK Fetch completed (0.001 + 0.000 secs).
You can try this at your end. If it really doesn't work, you may need to upgrade. I am not sure, but quite a few IMAPSieve bugs were fixed in the last year or so.
Hi, here it is (I don't know why I get the SSLv2 warning because it is disabled in ssl_protocols, any ideas about that too?).
BTW, even when storing the message in a different folder with fileinto, the original message is still saved in the original mailbox. I also tried using
discard;
and makes no difference, I can never get rid of the original message.
The original message (the one in the COPY target mailbox in this case) is marked as \Deleted when implicit keep is canceled (discard), waiting to be expunged by the client. Dovecot currently does not perform this step implicitly.
# dovecot -n # 2.2.33.2 (d6601f4ec): /etc/dovecot/dovecot.conf # Pigeonhole version 0.4.21 (92477967) doveconf: Warning: SSLv2 not supported by OpenSSL. Please consider removing it from ssl_protocols. doveconf: Warning: SSLv2 not supported by OpenSSL. Please consider removing it from ssl_protocols.
I am not too familiar with the SSL guts of Dovecot, but it might be that "!SSLv2" also triggers this warning; which is imo a bit confusing.
# OS: Linux 4.15.0-30-generic x86_64 Ubuntu 18.04.1 LTS mail_location = mbox:~/mail:INBOX=/var/mail/%u mail_privileged_group = mail managesieve_notify_capability = mailto managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relationa l regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttex t editheader vnd.dovecot.debug vnd.dovecot.environment imapsieve vnd.dovecot.imapsieve vnd.dovecot.pipe vnd.dovecot.filter vnd.dov ecot.execute namespace inbox { inbox = yes location = mailbox Drafts { special_use = \Drafts } mailbox Junk { special_use = \Junk } mailbox Sent { special_use = \Sent } mailbox "Sent Messages" { special_use = \Sent } mailbox Trash { special_use = \Trash } prefix = } passdb { args = scheme=CRYPT username_format=%u /etc/dovecot/users driver = passwd-file } plugin { imapsieve_mailbox1_before = file:~/sieve/imapsieve.sieve imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_name = * sieve = file:~/sieve;active=~/.dovecot.sieve sieve_execute_bin_dir = /usr/local/lib/dovecot/sieve-bin sieve_extensions = +editheader +vnd.dovecot.execute +vnd.dovecot.filter +vnd.dovecot.pipe +vnd.dovecot.debug +vnd.dovecot.enviro nment sieve_filter_bin_dir = /usr/local/lib/dovecot/sieve-bin sieve_pipe_bin_dir = /usr/lib/dovecot/sieve-bin sieve_plugins = sieve_imapsieve sieve_extprograms } protocols = " imap lmtp sieve pop3 sieve" service imap-login { inet_listener imap { port = 0 } inet_listener imaps { port = 1993 } } service pop3-login { inet_listener pop3 { port = 0 } inet_listener pop3s { port = 1995 } } ssl = required ssl_cert =
On Friday 17 August 2018 22:27:05 CEST Stephan Bosch wrote:
Op 17/08/2018 om 19:44 schreef Leandro Lucarella:
On Friday 17 August 2018 01:41:39 CEST Stephan Bosch wrote:
dovecot -n
I tried your configuration here with your Sieve script. It works here as expected with or without the fileinto action (so also with only setflag).
I changed your script a little to detect "INBOX/Archive" rather than just "Archive" to match my setup.
Testing looked as follows (using /usr/lib/dovecot/imap from command line): [snip working test]
You can try this at your end. If it really doesn't work, you may need to upgrade. I am not sure, but quite a few IMAPSieve bugs were fixed in the last year or so.
OK, thanks for trying this out. I did a quick check by connecting to the server manually and issuing the IMAP commands myself (COPY of a message without flags and then check the flags in the new folder) and I verified in my case the flags are not set properly.
I guess that test is enough to conclude that probably the version I'm using (the one in Ubuntu 18.04.1) is buggy, right?
Is there some mode you are using to run a test server and issue the commands to do the testing, or is it just some manual work to set up a new server with a test account etc. you are using?
Thanks again a lot for the testing.
PS: Removing the !SSLv2 removed the warning too. Thanks!
-- Leandro Lucarella (Luca) https://llucax.com
participants (2)
-
Leandro Lucarella
-
Stephan Bosch