|
FastMail Forum All posts relating to FastMail.FM should go here: suggestions, comments, requests for help, complaints, technical issues etc. |
|
Thread Tools |
11 Mar 2021, 12:26 AM | #1 |
Cornerstone of the Community
Join Date: Jul 2002
Location: Tacoma, WA
Posts: 642
|
email moved by rule retains copy in Inbox
I have a rule I created through the Fastmail search, which is intended to move a matching email to a different folder. The rule works, sort of (a copy of the email is in the destination folder), but a copy of the email is also retained in the inbox.
This rule matches a sender and a subject. I have another rule that moves a email based upon the sender which correctly moves matching emails but does not retain a copy in the inbox, but it doesn't also match on the subject. How do I change the original rule so that matches are deleted from the inbox? |
11 Mar 2021, 09:36 AM | #2 | |
Essential Contributor
Join Date: May 2018
Posts: 474
|
Quote:
Last edited by xyzzy : 11 Mar 2021 at 10:14 AM. |
|
11 Mar 2021, 02:46 PM | #3 |
The "e" in e-mail
Join Date: May 2003
Location: mostly in Thailand
Posts: 3,084
|
Do you have any custom sieve? If so, that is where I would first look for the cause of this. Also, look to see if there is any mechanism by which the message could be received twice under different receiving addresses.
|
11 Mar 2021, 03:14 PM | #4 |
Cornerstone of the Community
Join Date: Jul 2002
Location: Tacoma, WA
Posts: 642
|
Yes, I do have custom sieve, but no rules that should impact this situation, since I just started using that email address and the rule acts on the To: field and the Subject.
OK, I was looking at the Edit Sieve screen, and I see that FM interface rules are acted upon first, before the user Sieve code. Here's an excerpt from what was generated by the rule: ### 4d. Do rule actions else { if string :is "${L0_archives_to_delete_permenently}" "Y" { fileinto :copy :mailboxid "655686524b36ba99" "INBOX.archives.to delete permenently"; set "hasmailbox" "Y"; } if string :is "${L1_Dads_mail_VITA_RAC_Volunteer_Hours}" "Y" { fileinto :copy :mailboxid "c5c83b43-921a-4a80-8324-e36b774e6b68" "INBOX.Dads mail.VITA.RAC Volunteer Hours"; set "hasmailbox" "Y"; } # Then archive or clear implicit keep if skipping inbox if string :is "${skipinbox}" "Y" { if not string :is "${hasmailbox}" "Y" { fileinto :mailboxid "8fb0a692-ab78-4e62-a475-7f7fe05c14c9" :specialuse "\\Archive" "INBOX.Archive"; } else { discard; } I don't read Sieve code all that well, but it seems to me that since after fileinto is copy, then the behavior I'm seeing may make sense. But, why does the rule generate this code? Last edited by camner : 11 Mar 2021 at 03:23 PM. |
11 Mar 2021, 07:35 PM | #5 | |
Essential Contributor
Join Date: Dec 2017
Location: Scotland
Posts: 483
|
Quote:
On the face of it, that's alarming, but the code says if a variable named "L0_archives_to_delete_permenently" is "Y" then do various stuff Looking at my Sieve rules I see lots of this sort of thing too, but earlier in the file, some of the logic that could create variables with those sorts of names is commented out. For example, here, this section exists if allof( not string :is "${stop}" "Y", header :contains "Return-Path" "<ispf-l-list" ) { if mailboxidexists "8c0136de-5597-410e-81e4-450d642911a4" { set "L31_INBOX_in_listserv_ls_ISPF" "Y"; set "skipinbox" "Y"; } set "stop" "Y"; } and that could define the "L31_INBOX_in_listserv_ls_ISPF" variable, so any test later that examines it might take some actions. But I also have sections like # if # allof( not string :is "${stop}" "Y", # header :is ["List-Id","List-Post"] ["<hercules-390.yahoogroups.com>","<<hercules-390.yahoogroups.com>>"] # ) # { # if mailboxidexists "24354043-e3b7-490c-8184-09ea116686ab" { # set "L63_INBOX_in_herc_all_maillists_herc_390_yh__ie_the_emulator_" "Y"; # set "skipinbox" "Y"; # } # set "stop" "Y"; # } - which in my rules is the only place where variable "L63_INBOX_in_herc_all_maillists_herc_390_yh__ie_the_emulator_" might have been set. It clearly isn't set so the later logic if string :is "${L63_INBOX_in_herc_all_maillists_herc_390_yh__ie_the_emulator_}" "Y" { fileinto :copy :mailboxid "24354043-e3b7-490c-8184-09ea116686ab" "INBOX.INBOX.in-herc all maillists.herc-390-yh (ie the emulator)"; set "hasmailbox" "Y"; } will never actually do anything (except waste CPU cycles on the FM server). I'm, not sure how happy I am to see what looks like test code being generated mixed up with live code. |
|
11 Mar 2021, 08:07 PM | #6 |
Essential Contributor
Join Date: May 2018
Posts: 474
|
The general FM Sieve "logic" is that section 4a (Calculate rule action) tests the rule conditions and a match sets the corresponding Lx_... and hasmailbox variables. Disabled rules still show the code but it is simply commented out and thus it's Lx... variable will never be set.
Section 4d (Do rule action) checks the Lx... variable to see which rule matched in section 4a, and if so do the fileinto :copy and set hasmailbox. Finally at the end of these action tests (where it has the comment "Then archive or clear implicit keep if skipping inbox") if both skipinbox (set from the rule that matched in section 4a) and hasmailbox (set from the corresponding 4d action) are true (both will be) then discard the copy the fileinto made. On the surface I see no problems with the section 4d code you show. So what does the corresponding section 4a code show, i.e., where the rule conditions are tested to set L0_archives_to_delete_permenently and L1_Dads_mail_VITA_RAC_Volunteer_Hours? I say "on the surface" because one thing does strike me as somewhat "odd". That is the mailboxid used for fileinto INBOX.archives.to delete permenently, i.e, 655686524b36ba99. Admittedly I don't know much about mailboxid's but all the ones I've seen are not in that format. They are usually 5 dash separated hex components like the one for INBOX.Dads mail.VITA.RAC Volunteer Hours (c5c83b43-921a-4a80-8324-e36b774e6b68). I wonder if that has something to do with the otherwise unexplained behavior, and if so, how/why did that odd looking mailboxid get created (if it really is "odd")? ----- Update due to mistake pointed out in the next post: The first paragraph should read: The general FM Sieve "logic" is that section 4a (Calculate rule action) tests the rule conditions and a match sets the corresponding Lx_... and skipinbox variables. Disabled rules still show the code but it is simply commented out and thus it's Lx... variable will never be set. Last edited by xyzzy : 12 Mar 2021 at 06:10 AM. Reason: Corrected 1st paragraph |
11 Mar 2021, 10:49 PM | #7 | ||||
Essential Contributor
Join Date: Dec 2017
Location: Scotland
Posts: 483
|
Quote:
Quote:
Quote:
Quote:
I just looked at my Sieve code; all of my mailboxids are the '5 dash separated hex' values type too. |
||||
12 Mar 2021, 06:04 AM | #8 | ||||
Essential Contributor
Join Date: May 2018
Posts: 474
|
Quote:
Quote:
Quote:
Quote:
I'd still like to see the section 4a code (appropriately censored if necessary). Last edited by xyzzy : 12 Mar 2021 at 06:12 AM. |
||||
13 Mar 2021, 02:29 PM | #9 |
Cornerstone of the Community
Join Date: Jul 2002
Location: Tacoma, WA
Posts: 642
|
Well, this has gotten way over my head very quickly!
FWIW, here is the complete section 4, with personal stuff (if I caught it all...), munged. There are two custom rules set up (though I have a huge Sieve code as well, but that executes after section 4 rules, no?) The second custom rule works fine, with no retention of emails in the Inbox. Just the first rule has that occur. Code:
### 4. User configured rules ### 4a. Calculate rule actions # Search: "to:vita_r-not-filing@myaddress.com subject:(GetYourRefund Client)" if allof( not string :is "${stop}" "Y", jmapquery text: { "conditions" : [ { "conditions" : [ { "to" : "vita_r-not-filing@myaddress.com" }, { "cc" : "vita_r-not-filing@myaddress.com" }, { "bcc" : "vita_r-not-filing@myaddress.com" }, { "deliveredTo" : "vita_r-not-filing@myaddress.com" } ], "operator" : "OR" }, { "conditions" : [ { "subject" : "GetYourRefund" }, { "subject" : "Client" } ], "operator" : "AND" } ], "operator" : "AND" } . ) { set "read" "Y"; if mailboxidexists "655686524b36ba99" { set "L0_archives_to_delete_permenently" "Y"; set "skipinbox" "Y"; } set "stop" "Y"; } # Search: "from:michelec@anotheraddress.org" if allof( not string :is "${stop}" "Y", jmapquery text: { "from" : "michelec@anotheraddress.org" } . ) { set "read" "Y"; if mailboxidexists "c5c83b43-921a-4a80-8324-e36b774e6b68" { set "L1_Dads_mail_VITA_RAC_Volunteer_Hours" "Y"; set "skipinbox" "Y"; } set "stop" "Y"; } ### 4b. Rule sent message to trash if anyof( string :is "${deletetotrash}" "Y", string :is "${spam}" "Y" ) { set "skipinbox" "Y"; } # Copies always get marked read for better compatibility with IMAP clients # and labels mode. if anyof( string :is "${read}" "Y", not string :is "${skipinbox}" "Y" ) { if hasflag "\\Seen" { set "read" "Y"; } else { addflag "\\Seen"; } } # Similarly, only the inbox copy gets flagged if allof( string :is "${flagged}" "Y", string :is "${skipinbox}" "Y" ) { addflag "\\Flagged"; } if string :is "${deletetotrash}" "Y" { fileinto :specialuse "\\Trash" "INBOX.Trash"; } ### 4c. Rule says message is spam elsif string :is "${spam}" "Y" { fileinto :specialuse "\\Junk" "INBOX.Junk Mail"; } ### 4d. Do rule actions else { if string :is "${L0_archives_to_delete_permenently}" "Y" { fileinto :copy :mailboxid "655686524b36ba99" "INBOX.archives.to delete permenently"; set "hasmailbox" "Y"; } if string :is "${L1_Dads_mail_VITA_RAC_Volunteer_Hours}" "Y" { fileinto :copy :mailboxid "c5c83b43-921a-4a80-8324-e36b774e6b68" "INBOX.Dads mail.VITA.RAC Volunteer Hours"; set "hasmailbox" "Y"; } # Then archive or clear implicit keep if skipping inbox if string :is "${skipinbox}" "Y" { if not string :is "${hasmailbox}" "Y" { fileinto :mailboxid "8fb0a692-ab78-4e62-a475-7f7fe05c14c9" :specialuse "\\Archive" "INBOX.Archive"; } else { discard; } } else { # Set flags for inbox copy if not string :is "${read}" "Y" { removeflag "\\Seen"; } if string :is "${flagged}" "Y" { addflag "\\Flagged"; } # Do MailFetch filing if applicable, otherwise deliver to inbox } Last edited by camner : 16 Mar 2021 at 02:20 PM. |
13 Mar 2021, 07:21 PM | #10 | |
Essential Contributor
Join Date: May 2018
Posts: 474
|
Just to be sure about what you say the problem is in terms of that code.
You say that if a message is sent to vita_r-not-filing@myaddress.com and the subject is "GetYourRefund Client" the message is filed into "archives_to_delete_permenently" and your inbox? Is that correct? I have to ask because aside from the weird looking mailboxid I see nothing wrong with that code and a message with the stated conditions should only appear in "archives_to_delete_permenently". The weird looking mailboxid must be ok to the extent of causing the section 4a conditions tests to work to set L0_archives_to_delete_permenently and skipinbox. That in turn will allow the section 4d actions to do it's fileinto and set hasmailbox. So with both hasmailbox and skipinbox set the "keep" will get cancelled from the discard and nothing further should be done. So I have to ask, are you sure it's the same message also in the inbox, i.e., is the message id and time stamps identical? I said the weird looking mailboxid must be correct to allow the above described actions. But I think it is also true that if it is somehow invalid to the fileinto the specified folder name is used instead, at least I think that's what's supposed to happen. If there's a bug with that fileinto behavior then perhaps that explains it. I am still curious about the weird looking mailboxid. Was the folder "archives_to_delete_permenently" originally some other name? I'm not totally clear on mailboxid's but I believe they have something to do with renaming folders in a IMAP environment. Quote:
BUT... You need to know that one of the above section 4 rules was satisfied if you don't want any of your code at the bottom to see the message! If you look at the last 3 lines at the end of the FM generated code before that edit block you will see: Code:
if string :is "${stop}" "Y" { # For backwards compatibility } --- By the way, here's a "meta comment" about posting code in this forum. Please use the "code" format, i.e., the '#' formatting option, so that the code retains its original formatting (specifically the indenting). I show the use of the code formatting code in the 3-line block above. Last edited by xyzzy : 13 Mar 2021 at 07:57 PM. |
|
13 Mar 2021, 08:06 PM | #11 |
Essential Contributor
Join Date: Dec 2017
Location: Scotland
Posts: 483
|
One minor comment, most unlikely to have any bearing on the OP's problem... In the block of code that the OP posted, that starts
# Search: "to:vita_r-not-filing@myaddress.com subjectGetYourRefund Client)" the logic isn't looking for a Subject header that contains "GetYourRefund Client" but instead for a Subject that contains "GetYourRefund" and "Client", in any order, separated by any other words. That's seen here: { "conditions" : [ { "subject" : "GetYourRefund" }, { "subject" : "Client" } ], "operator" : "AND" } Regarding xyzzy's question about whether the apparently equal messages really are equal, I would compare them by using the "More" menu within display of each message to select "Show Raw Message" then c&p all of the contents of each raw message to a text file. I'd then use a (programmer's) file compare utility to look for differences in the two saved files. Last edited by JeremyNicoll : 13 Mar 2021 at 08:12 PM. |
13 Mar 2021, 08:34 PM | #12 | |
Essential Contributor
Join Date: May 2018
Posts: 474
|
Quote:
Last edited by xyzzy : 14 Mar 2021 at 06:08 AM. |
|
14 Mar 2021, 07:08 AM | #13 | |||||
Cornerstone of the Community
Join Date: Jul 2002
Location: Tacoma, WA
Posts: 642
|
Quote:
The message IDs are: 604d3111da153_82ad34870f968457184@d529f0443c84.mail[AND 604d3111da153_82ad34870f968457184@d529f0443c84.mail which are the same. Quote:
Quote:
Quote:
--- Quote:
|
|||||
14 Mar 2021, 08:17 AM | #14 | ||
Essential Contributor
Join Date: May 2018
Posts: 474
|
Quote:
Note, if you don't want to enclose your code within an else or elsif then precede your code with the following: Code:
if string :is "${stop}" "Y" {stop;} Quote:
------------- ** That three line block that tests for stop is commented as "For backwards compatibility" precisely because it assumes any user code at the end is in it's own else or elsif block, i.e., the logical sequence to follow the "old" elsif's that preceded it. Initially when in beta testing the new FM code they didn't have that 3-line block in there. That meant that the user code that followed starting with an else or elsif for the "old" FM code resulted in a syntax error. I guess they didn't test that out since I had to submit a ticket on it because I too have code at the end starting with elsif. Hence the comment about "backward compatibility", i.e., to make the user's code at the end remain syntactically compatible with the new section 4 code. Last edited by xyzzy : 14 Mar 2021 at 01:51 PM. |
||
16 Mar 2021, 09:08 AM | #15 |
Cornerstone of the Community
Join Date: Jul 2002
Location: Tacoma, WA
Posts: 642
|
Hmmm...I may have figured this out.
The very last line of my custom Sieve code is: Code:
#redirect all other mail to the inbox keep; It seems to me that I've got a couple of choices.... I could keep using custom Sieve only, as I have been doing for years. If I wanted to use the FM rules interface so I could create a rule from a search, for example, is there I way I could alter the code so that my custom sieve rules are only considered if a given email does not satisfy any of the FM rules interface rules I have set up? |
Thread Tools | |
|
|