|
FastMail Forum All posts relating to FastMail.FM should go here: suggestions, comments, requests for help, complaints, technical issues etc. |
|
Thread Tools |
12 Dec 2019, 10:28 PM | #1 |
Cornerstone of the Community
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 603
|
sieve if/elseif question
Hi,
Using Fastmail's rule maker, I get sieve that looks like the following.... Code:
### 7. Sieve generated for organise rules if criteria-1{ do_thing-1; } elsif criteria-2{ do_thing-2; } |
12 Dec 2019, 11:10 PM | #2 |
The "e" in e-mail
Join Date: May 2003
Location: mostly in Thailand
Posts: 3,095
|
Yes. For that reason, it can be important to ensure the rules are in the desired order.
|
12 Dec 2019, 11:16 PM | #3 | |
Cornerstone of the Community
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 603
|
Quote:
Criteria-1 is X-Resolved-to is exactly ... Criteria-2 is List-Unsubscribe exists Both exist in the email in question but it is ending up in the folder set by Criteria-2. |
|
12 Dec 2019, 11:22 PM | #4 |
Cornerstone of the Community
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 603
|
|
14 Dec 2019, 11:42 PM | #5 |
Essential Contributor
Join Date: Dec 2017
Location: Scotland
Posts: 491
|
Have you raised a ticket?
If not, it seems to me that you need to know categorically if your "criteria-1" test condition is really being matched for this email, because if it is not then having action-2 occur is not a surprise. Other people have mentioned in other discussions that the sieve tester does not work properly. I don't know what it doesn't do, but perhaps your example has fallen down one of the tester's traps? Perhaps you could edit the sieve rules directly (using the link at the foot of the rules page) and place code, just containing that condition, much higher up. For example, I just added to my sieve code (in the optional user code section right at the top immediately after the "require" statement): Code:
if header :contains "Subject" "this is just a sieve test" { addflag "\\Flagged"; stop; } I sent myself a test email which didn't meet the condition and it ended up where I expected, then sent one which did.. and it was flagged. I don't set flags in any other rule so it must have been done by that rule. |
14 Dec 2019, 11:44 PM | #6 | |
Cornerstone of the Community
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 603
|
Quote:
|
|
15 Dec 2019, 12:29 AM | #7 |
Essential Contributor
Join Date: Dec 2017
Location: Scotland
Posts: 491
|
I've also experimented with the following actions:
Code:
addheader "X-JN-Breadcrumb" "Inserted at start of headers by my sieve code"; addheader :last "X-JN-Breadcrumb" "Appended at end of headers by sieve test 23"; Judicious use of this Sieve command allows one to see which parts of one's code have been executed. |
15 Dec 2019, 12:59 AM | #8 | |
Cornerstone of the Community
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 603
|
Quote:
|
|
15 Dec 2019, 06:36 PM | #9 |
Cornerstone of the Community
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 603
|
OK, took a look this morning and have added the code (flagging and breadcrumbs) - thanks both those great ideas!
...why is it clear that we should only add "X-" headers though? cheers, J. |
15 Dec 2019, 06:52 PM | #10 | |
Cornerstone of the Community
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 603
|
Quote:
I did find a piece of code that that I must have half written and forgotten about (it was an if with no then (if you know what I mean) and may have been throwing the whole thing off. thanks so much - I know I'll be using breadcrumbs again in future |
|
16 Dec 2019, 04:46 AM | #11 |
Essential Contributor
Join Date: May 2018
Posts: 478
|
I don't believe there are any restrictions on what you name the header (ignoring possible digital signature implications should you redirect the message).
Last edited by xyzzy : 16 Dec 2019 at 04:59 AM. |
16 Dec 2019, 08:03 AM | #12 | |
Essential Contributor
Join Date: Dec 2017
Location: Scotland
Posts: 491
|
Quote:
That appears to have been suggested in RFC822 - see: https://tools.ietf.org/html/rfc822 though in reverse where it is stated that no future email standard will define a 'standard' header whose name starts "X-". That means that in theory adding an "X-" header won't cause a problem if the email is then forwarded or whatever. However, there are now lots of "X-" headers added, mainly by anti-spam measures and those designed to detect email looping round and round between various servers and never being delivered, and one drawback of there being no standard naming convention for them is that you cannot be sure that a header you add won't cause a problem if it has a name conflict with someone-else's non-standard header. So, the idea of adding one's own X-headers is not perfect, but what else would you suggest? The fact that there's a myriad of X- headers in use, without any official agreement on what they all mean - so it's a mess - is discussed in other RFCs eg https://tools.ietf.org/html/rfc6648 The Sieve 'editheader' extension, which supports the 'addheader' command will prevent some specific standard headers from being added. Last edited by JeremyNicoll : 16 Dec 2019 at 08:10 AM. |
|
16 Dec 2019, 08:05 AM | #13 | |
Essential Contributor
Join Date: Dec 2017
Location: Scotland
Posts: 491
|
Quote:
|
|