EmailDiscussions.com

EmailDiscussions.com (http://www.emaildiscussions.com/index.php)
-   FastMail Forum (http://www.emaildiscussions.com/forumdisplay.php?f=27)
-   -   Sieve:addflag command not working (http://www.emaildiscussions.com/showthread.php?t=74376)

blurk 5 May 2019 03:39 PM

Sieve:addflag command not working
 
Hi there,

It's been ages since I've posted here, but I'm wondering about FastMail's implementation of Sieve's addflag command for flagging messages with IMAP standard flags. I have recently reworked my Sieve script to try and use addflag with a view to using them with the new saved search feature.

But it looks like addflag only works on messages filed to INBOX, because I see no evidence of flags being set on the majority of my messages, which are filed to various mailboxes (based on an elaborate subdomain and address naming convention I have going). However, today I noticed that some of the very few messages that get filed into the top-level INBOX do have flags set.

So does anyone know how, with a Sieve script on FastMail, to conditionally add IMAP flags to messages and have them filed into specific mailboxes? What am I missing? I haven't studied every line of the relevant RFCs, but I saw nothing that said that addflag should be restricted to the INBOX.

Does anyone else have a Sieve script doing anything like this?

xyzzy 5 May 2019 05:10 PM

My script under some conditions files into spam with addflag "\\Seen" and works as expected. Not sure why it wouldn't work for any folder since the addflag is done before the fileinto and knows nothing about the final disposition of the message when the addflag is done.

You said you reworked your sieve script. Maybe it has a bug. Have you tried it in Sieve Tester with a test case to see if its going down the expected path?

When I am not sure of where a case is going I debug it in sieve tester by sprinkling fileinto's in places I expect the test case to go. Since sieve tester doesn't care what you use for folder names I specifiy "point1", "point2", etc. as fileinto folder names just to see it goes down the expected path. The results of these fileinto's will display in the sieve tester results. The addflag's are reported in the results too (at least seen is).

Note, if you do copy your entire sieve script into sieve tester you must remove the "fcc" at the end of the require command since FM never updated sieve tester to support it. I submitted a ticket on this some time ago but FM just doesn't consider sieve tester a priority worth updating since they think so few users deal with sieve scripts.:( I am not in a position to argue with that.

blurk 5 May 2019 05:43 PM

Thanks for the quick reply. It is good to have at least one data point validating that what I am doing should work. One difference is that I don't do an explicit fileinto after adding the flag, because FastMail's setup does an implicit fileinto in subfolders due to the way they support plus addressing. But still, it should all amount to the same thing: a message with flags set that eventually is filed into a mailbox.

I will try the Sieve tester again. I had used it before, but not recently. That's sensible advice. I'm pretty sure the script is hitting the paths I expect, because I've also made use of the addheader command to mark tracepoints in a way analogous to your extra fileinto commands in a test script.

blurk 5 May 2019 09:14 PM

Quote:

Originally Posted by xyzzy (Post 610028)
You said you reworked your sieve script. Maybe it has a bug. Have you tried it in Sieve Tester with a test case to see if its going down the expected path?

Wise advice. Following a classic divide and conquer debug strategy of adding traces and adding stops at different places to narrow down the point at which a working script stops working, my initial results suggest that the addheader Sieve extension command is somehow breaking the addflag Sieve extension command.

Go figure. It's not a syntax error, because the way my script fails would be totally different (in fact, I believe I wouldn't even be allowed to save a script with a syntax error).

Next thing to see is if it's the details of my addheader commands at fault, or whether there's a fundamental incompatibility between the two extensions. The latter would, in my opinion, be a bug. The odd thing is that I'm pretty sure I only added the addheader commands to trace my script, to see why addflag wasn't working. Chicken. Egg.

Update:

Works:
Code:

require ["fileinto", "reject", "vacation", "notify", "envelope", "body", "relational", "regex", "subaddress", "copy", "mailbox",
 "mboxmetadata", "servermetadata", "date", "index", "comparator-i;ascii-numeric", "variables",
 "imap4flags", "editheader", "duplicate", "vacation-seconds"];

addflag "\\Flagged";

Fails to add flag:
Code:

require ["fileinto", "reject", "vacation", "notify", "envelope", "body", "relational", "regex", "subaddress", "copy", "mailbox",
 "mboxmetadata", "servermetadata", "date", "index", "comparator-i;ascii-numeric", "variables",
 "imap4flags", "editheader", "duplicate", "vacation-seconds"];


addflag "\\Flagged";
addheader "X-Sieve" "x";


Terry 5 May 2019 09:38 PM

I thought it should have "imap4flags

blurk 5 May 2019 09:51 PM

Quote:

Originally Posted by Terry (Post 610037)
I thought it should have "imap4flags

It's there, perhaps scrolled off to the right. In any case, FastMail autogenerates the require line for you, with the extensions they have installed. I just copied that line from their "Edit Sieve script" UI. I'll re-flow the text.

It turns out the addheader breaks other Sieve extension commands (like fileinto) so I really think the editheader extension is the culprit here.

Terry 5 May 2019 09:54 PM

yea did not realise I had to scroll :D I am having a bad day.:)

blurk 5 May 2019 09:57 PM

Quote:

Originally Posted by Terry (Post 610040)
yea did not realise I had to scroll :D I am having a bad day.:)

Never mind, you got me to edit my post to be more readable. That's good!

xyzzy 6 May 2019 06:34 AM

Slightly off topic but I just want to verify is that require list you show is with fcc edited out? If not then I am curious why FM's sieve always is generating it for me since I don't have anything that would require it.

Also what's the effect of \\flagged? I searched for it and while I keep finding examples of it I am curious what it's effect is?

Update:
I think I found it in rfc3501 section 2.3.2.

blurk 6 May 2019 08:35 PM

Quote:

Originally Posted by xyzzy (Post 610047)
Slightly off topic but I just want to verify is that require list you show is with fcc edited out? If not then I am curious why FM's sieve always is generating it for me since I don't have anything that would require it.

Yes, I manually removed fcc from the require list.

Quote:

Also what's the effect of \\flagged? I searched for it and while I keep finding examples of it I am curious what it's effect is?

Update:
I think I found it in rfc3501 section 2.3.2.
Yes, it is the main user-settable IMAP flag. FastMail present this flag in their web UI as pinned messages.

Anyway, I have a further update. I removed all the addheader commands from my live FastMail copy of the Sieve script, and it's still not setting any flags. Copy the same script into the Sieve tester and it claims it will add the flag.

xyzzy 7 May 2019 05:52 AM

Quote:

Originally Posted by blurk (Post 610058)
Anyway, I have a further update. I removed all the addheader commands from my live FastMail copy of the Sieve script, and it's still not setting any flags. Copy the same script into the Sieve tester and it claims it will add the flag.

Strange. After I posted my "what effect does \Flagged have?" I added the following into my sieve code at the very end where anything that gets that far would be destined for the inbox.

Code:

if allof(true, header :contains "Subject" "test") {
  addflag "\\Flagged";
  addheader "X-Sieve" "x";
  fileinto "INBOX.test";
}

And the test email was pinned and had the X-Sieve line in it.

Oddly though when I tested just this with sieve tester I got no results at all!:confused: I think that's a sieve tester bug. The addheader confuses it.

blurk 15 May 2019 11:25 PM

Quote:

Originally Posted by blurk (Post 610027)
...
But it looks like addflag only works on messages filed to INBOX, because I see no evidence of flags being set on the majority of my messages, which are filed to various mailboxes (based on an elaborate subdomain and address naming convention I have going).

Turns out that the problem was due to my elaborate address naming convention, which gets transformed into plus addressing which FastMail autofiles into existing folders with names matching the plus address components. That happens after the Sieve script, and apparently FastMail had a bug where that behaviour interacted (or more to the point, didn't interact) with all the flag setting in my Sieve script, losing the flags. They're rolling out a fix for this, so I must say thanks to their support team for sorting that very edgy of edge cases out.

elvey 19 May 2019 02:39 AM

Yay! Keep us updated, please!


All times are GMT +9. The time now is 11:47 PM.


Copyright EmailDiscussions.com 1998-2013. All Rights Reserved. Privacy Policy