[Dovecot] Sieve: redirect and keep action, possible bug
Hi,
Using Dovecot 1.2.4 and the new Sieve implementation in version 0.1.12, I ran into a problem that could indicate a bug in Sieve.
The following is a simple script (as generated by Horde's Ingo application) to redirect incoming mail and also keep a copy of the message in the local inbox:
if true { redirect "foo@example.org"; }
if true { keep; stop; }
Problem is, it doesn't work as expected: no copy of the message is kept in the local inbox. However, if I explicitly tell Sieve to "fileinto" it works fine:
require ["fileinto"];
if true { redirect "foo@example.org"; }
if true { fileinto "INBOX"; stop; }
Is this a bug in Sieve or am I wrong about how "keep" works?
Thanks in advance!
Andreas
Andreas Ntaflos Vienna, Austria
GPG Fingerprint: 6234 2E8E 5C81 C6CB E5EC 7E65 397C E2A8 090C A9B4
On 09/26/2009 02:01 AM Andreas Ntaflos wrote:
Hi,
Using Dovecot 1.2.4 and the new Sieve implementation in version 0.1.12, I ran into a problem that could indicate a bug in Sieve.
The following is a simple script (as generated by Horde's Ingo application) to redirect incoming mail and also keep a copy of the message in the local inbox:
if true { redirect "foo@example.org"; }
if true { keep; stop; }
Problem is, it doesn't work as expected: no copy of the message is kept in the local inbox. However, if I explicitly tell Sieve to "fileinto" it works fine:
require ["fileinto"];
if true { redirect "foo@example.org"; }
if true { fileinto "INBOX"; stop; }
Is this a bug in Sieve or am I wrong about how "keep" works?
Thanks in advance!
Andreas
Your script looks strange for me. I'm simply using:
# sieve script start redirect "user@example.com"; keep; # sieve script end (no conditions)
All emails is forwarded to user@example.com and will be saved in the inbox.
Regards, Pascal
The trapper recommends today: face1e55.0926902@localdomain.org
On Saturday 26 September 2009 02:17:34 Pascal Volk wrote:
Your script looks strange for me. I'm simply using:
# sieve script start redirect "user@example.com"; keep; # sieve script end (no conditions)
Hi,
thanks for the reply. I know it looks strange but that is how Ingo (Horde's filter application) generates it. But essentially it is the same as your script (just ignore the "if true" parts).
All emails is forwarded to user@example.com and will be saved in the inbox.
Funny thing is that it doesn't work here, even when I strip it down to just the two lines:
redirect "foo@example.org" keep;
Only the redirection is executed, the keep action seems to be ignored. If I again change it to a 'fileinto "INBOX";' it works as expected.
What version of Dovecot and Sieve are you using if I may ask?
Thanks,
Andreas
Andreas Ntaflos Vienna, Austria
GPG Fingerprint: 6234 2E8E 5C81 C6CB E5EC 7E65 397C E2A8 090C A9B4
On 09/26/2009 02:27 AM Andreas Ntaflos wrote:
… Funny thing is that it doesn't work here, even when I strip it down to just the two lines:
redirect "foo@example.org" keep;
Hm, sorry no idea what could be the reason for this behavior.
What version of Dovecot and Sieve are you using if I may ask?
Tested with Dovecot v1.2.5 + Patch http://hg.dovecot.org/dovecot-1.2/rev/0f04c7da33f1 and Sieve from http://www.rename-it.nl/dovecot/1.2/dovecot-1.2-sieve-0.1.12.tar.gz
Regards, Pascal
The trapper recommends today: face1e55.0926902@localdomain.org
On Saturday 26 September 2009 02:40:40 Pascal Volk wrote:
On 09/26/2009 02:27 AM Andreas Ntaflos wrote:
… Funny thing is that it doesn't work here, even when I strip it down to just the two lines:
redirect "foo@example.org" keep;
Hm, sorry no idea what could be the reason for this behavior.
What version of Dovecot and Sieve are you using if I may ask?
Tested with Dovecot v1.2.5 + Patch http://hg.dovecot.org/dovecot-1.2/rev/0f04c7da33f1 and Sieve from http://www.rename-it.nl/dovecot/1.2/dovecot-1.2-sieve-0.1.12.tar.gz
Thank you for confirming that it should work correctly with the latest versions of Dovecot and Sieve. I found the problem in my setup.
I found that one of my "before" scripts (sieve_before = /etc/dovecot/sieve/before.d, [1]) had a fileinto action together with an explicit "keep". It seems that was a problem for the redirect action later in the user's own script.
I modified that "before" script to use
fileinto :copy "INBOX/foo/bar";
instead of
fileinto "INBOX/foo/bar"; keep;
and now the redirect action works as expected, like you tested and posted earlier.
Still, I wonder why this is happening? In both cases there is a keep action in effect, otherwise the user's script wouldn't get executed at all. Could someone explain what I am missing here? More details follow.
The script in /etc/dovecot/sieve/before.d looks as follows (I use it to keep a backup copy of all mail received in an extra, hidden namespace):
001-backup-mails.sieve:
# We only want to backup incoming mail if it is not marked as spam. if header :contains "X-Spam-Flag" ["YES"] { discard; stop; } else { # This works fileinto :copy :flags "\\Seen" "Backup/received-backup";
# This doesn't, as explained above
# fileinto :flags "\\Seen" "Backup/received-backup";
# keep;
}
This user's script is again only two lines:
user.sieve:
redirect "foo@example.org" keep;
As explained, in the user's sieve script the "keep" after the redirect action is ignored when the backup mails script uses an explicit "keep" after "fileinto", but not when "fileinto" is used with "copy".
Why?
Thanks,
Andreas
[1] http://wiki.dovecot.org/LDA/Sieve/Dovecot
Andreas Ntaflos Vienna, Austria
GPG Fingerprint: 6234 2E8E 5C81 C6CB E5EC 7E65 397C E2A8 090C A9B4
Andreas Ntaflos schreef:
As explained, in the user's sieve script the "keep" after the redirect action is ignored when the backup mails script uses an explicit "keep" after "fileinto", but not when "fileinto" is used with "copy".
Why? Because you have tripped a bug that is fixed in the repository, but not in the final release:
http://www.dovecot.org/list/dovecot/2009-September/042591.html
Your script executes as follows in the latest release (wrong):
$ sieve-test -s before.sieve user.sieve message.eml
## Executing script: /home/stephan/before.sieve Performed actions:
- store message in folder: Backup/received-backup + add IMAP flags: \seen
- keep Implicit keep: (none)
Executing script: /home/stephan/frop.sieve
Performed actions:
- redirect message to: foo@example.org Implicit keep: (none)
Info: final result: success
== In the latest repository version it executes as follows (ok):
$ sieve-test -s before.sieve user.sieve message.eml
## Executing script: /home/stephan/before.sieve Performed actions:
- store message in folder: Backup/received-backup + add IMAP flags: \seen
- keep Implicit keep: (none)
Executing script: /home/stephan/frop.sieve
Performed actions:
- redirect message to: foo@example.org
- store message in folder: INBOX Implicit keep: (none)
Info: final result: success
== Due to persisting headaches since last week I haven't had the ability nor the motivation to make a new release. Now that I am better I should release new Sieve and ManageSieve(s) in the next few days or so.
Regards,
-- Stephan Bosch stephan@rename-it.nl
On Saturday 26 September 2009 16:21:34 Stephan Bosch wrote:
Andreas Ntaflos schreef:
As explained, in the user's sieve script the "keep" after the redirect action is ignored when the backup mails script uses an explicit "keep" after "fileinto", but not when "fileinto" is used with "copy".
Why?
Because you have tripped a bug that is fixed in the repository, but not in the final release:
http://www.dovecot.org/list/dovecot/2009-September/042591.html [...] Due to persisting headaches since last week I haven't had the ability nor the motivation to make a new release. Now that I am better I should release new Sieve and ManageSieve(s) in the next few days or so.
Hi Stephan,
thanks for the reply and explanation and confirmation of this bug. Great to hear you are feeling better. Looking forward to testing the next releases.
Andreas
Andreas Ntaflos
GPG Fingerprint: 6234 2E8E 5C81 C6CB E5EC 7E65 397C E2A8 090C A9B4
participants (3)
-
Andreas Ntaflos
-
Pascal Volk
-
Stephan Bosch