EmailDiscussions.com  

Go Back   EmailDiscussions.com > Email Service Provider-specific Forums > FastMail Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Stay in touch wirelessly

FastMail Forum All posts relating to FastMail.FM should go here: suggestions, comments, requests for help, complaints, technical issues etc.

Reply
 
Thread Tools
Old 5 May 2019, 03:39 PM   #1
blurk
Member
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 33
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?
blurk is offline   Reply With Quote

Old 5 May 2019, 05:10 PM   #2
xyzzy
Essential Contributor
 
Join Date: May 2018
Posts: 474
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.
xyzzy is offline   Reply With Quote
Old 5 May 2019, 05:43 PM   #3
blurk
Member
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 33
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 is offline   Reply With Quote
Old 5 May 2019, 09:14 PM   #4
blurk
Member
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 33
Quote:
Originally Posted by xyzzy View Post
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";

Last edited by blurk : 5 May 2019 at 09:53 PM.
blurk is offline   Reply With Quote
Old 5 May 2019, 09:38 PM   #5
Terry
The "e" in e-mail
 
Join Date: Jul 2002
Location: VK4
Posts: 2,994
I thought it should have "imap4flags
Terry is online now   Reply With Quote
Old 5 May 2019, 09:51 PM   #6
blurk
Member
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 33
Quote:
Originally Posted by Terry View Post
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.
blurk is offline   Reply With Quote
Old 5 May 2019, 09:54 PM   #7
Terry
The "e" in e-mail
 
Join Date: Jul 2002
Location: VK4
Posts: 2,994
yea did not realise I had to scroll I am having a bad day.
Terry is online now   Reply With Quote
Old 5 May 2019, 09:57 PM   #8
blurk
Member
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 33
Quote:
Originally Posted by Terry View Post
yea did not realise I had to scroll I am having a bad day.
Never mind, you got me to edit my post to be more readable. That's good!
blurk is offline   Reply With Quote
Old 6 May 2019, 06:34 AM   #9
xyzzy
Essential Contributor
 
Join Date: May 2018
Posts: 474
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.

Last edited by xyzzy : 6 May 2019 at 06:59 AM.
xyzzy is offline   Reply With Quote
Old 6 May 2019, 08:35 PM   #10
blurk
Member
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 33
Quote:
Originally Posted by xyzzy View Post
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.

Last edited by blurk : 6 May 2019 at 08:42 PM.
blurk is offline   Reply With Quote
Old 7 May 2019, 05:52 AM   #11
xyzzy
Essential Contributor
 
Join Date: May 2018
Posts: 474
Quote:
Originally Posted by blurk View Post
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! I think that's a sieve tester bug. The addheader confuses it.
xyzzy is offline   Reply With Quote
Old 15 May 2019, 11:25 PM   #12
blurk
Member
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 33
Quote:
Originally Posted by blurk View Post
...
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.
blurk is offline   Reply With Quote
Old 19 May 2019, 02:39 AM   #13
elvey
The "e" in e-mail
 
Join Date: Jan 2002
Location: San Francisco
Posts: 2,458
Yay! Keep us updated, please!
elvey is offline   Reply With Quote
Old 10 Apr 2020, 04:14 PM   #14
blurk
Member
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 33
Quote:
Originally Posted by elvey View Post
Yay! Keep us updated, please!
Well. It's almost a year late, but too be honest it took me a long time to get back to this to verify the fix, because my workflow kind of changed in the meantime. But yes, I'm getting flags set in my Sieve scripts now with my addressing scheme.
blurk is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +9. The time now is 05:27 PM.

 

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