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 11 Jan 2022, 04:36 AM   #1
ArtMG
Junior Member
 
Join Date: Oct 2004
Posts: 20
Sieve rule on attachment types without mime extension

Any idea how I could filter on attachment mime type in Sieve?

I have been trying to create a custom sieve rule to handle emails containing iCalendar attachments according to RFC6047, i.e. bearing attachments with a Content-Type of "text/calendar". I have not managed to find any hints in this Fastmail Forum yet, but another forum's post led me to Sieve Extensions for Mime in RFC5703 which would allow me to use

Code:
require ["mime", "fileinto"];

   if header :mime :anychild :contenttype
             "Content-Type" "text/calendar"
Unfortunately, when trying such code out in the Fastmail Sieve tester I get the error
Quote:
line 1: Unsupported feature(s) in "require": "mime"
indicating that RFC5703 Mime Extensions are not yet amongst those supported by Fastmail.

Does anyone have any other suggestions of how I could go about forwarding just the emails containing iCalendar attachments to the external calendar provider I am required to use? Thanks.

PS: I did try if header :matches "X-Attached" [".ics"] which works ok with Google calendar objects having the X-Attached: invite.ics header, but this does not with Microsoft calendar objects that just have the separate mime parts.

Last edited by ArtMG : 11 Jan 2022 at 05:05 AM. Reason: extra info
ArtMG is offline   Reply With Quote

Old 11 Jan 2022, 05:26 AM   #2
ArtMG
Junior Member
 
Join Date: Oct 2004
Posts: 20
Use the headers added by FM for invitation processing

Self-answer here, as I spotted a big clue lurking in the bottom of my FM autogenerated sieve code under section

Code:
  ### 6. Sieve generated for calendar preferences
which led me to Bron's blog article on automatic invitatation processing mentioning the Messaging Engine generated X-ME-Cal-Method header. Now I use the code

Code:
if exists "X-ME-Cal-Method"
and it correctly identifies both Google and Microsoft (and one would hope Apple, etc etc) iMIP messages.
ArtMG is offline   Reply With Quote
Old 11 Jan 2022, 11:16 AM   #3
gardenweed
Cornerstone of the Community
 
Join Date: Jun 2008
Location: Perth
Posts: 664
Thanks for sharing
gardenweed is offline   Reply With Quote
Old 12 Jan 2022, 03:17 AM   #4
JeremyNicoll
Essential Contributor
 
Join Date: Dec 2017
Location: Scotland
Posts: 483
Quote:
Originally Posted by ArtMG View Post
Unfortunately, when trying such code out in the Fastmail Sieve tester I get the error indicating that RFC5703 Mime Extensions are not yet amongst those supported by Fastmail.

I've never used the Sieve Tester but I have noticed that it gets mentioned every so often.

Unfortunately I'm fairly sure that that's been in discussions about how (a) it doesn't work very well, and (b) that Fastmail have decided not to keep it uptodate. If both those things are still true then errors from it might be misleading.
JeremyNicoll is offline   Reply With Quote
Old 12 Jan 2022, 07:25 AM   #5
xyzzy
Essential Contributor
 
Join Date: May 2018
Posts: 474
Quote:
Originally Posted by JeremyNicoll View Post
I've never used the Sieve Tester but I have noticed that it gets mentioned every so often.

Unfortunately I'm fairly sure that that's been in discussions about how (a) it doesn't work very well, and (b) that Fastmail have decided not to keep it uptodate. If both those things are still true then errors from it might be misleading.
When I was working on my script additions I used it a lot for testing various constructs as I went up the learning curve. For the most part Sieve Tester works "good enough" for isolated testing. But one "rough spot" I thought worth mentioning is never let Sieve Tester "see" a mailboxexists and mailboxidexists. Mailboxidexists are generated by FM's UI user rules. Sometimes it is desirable to test your entire script on an email for one reason or another. If Sieve Tester encounters a mailboxexists or mailboxidexists in its execution flow Sieve Tester will not produce any results even from the stuff done before it saw mailboxexists or mailboxidexists.

Example:
Code:
require ["fileinto", "mailbox", "editheader", "mailboxid"];
addheader "x" "point1";
if false {if mailboxidexists "xxx" {addheader "x" "point2";}}
if false {if mailboxexists "xyz" {addheader "x" "point3";}}
addheader "x" "point4";
Set either of those false tests to true and none of the script's output is generated. Not very user friendly. Ok Sieve Tester is running outside of the context of the actual mailbox environment but IMO at least something could have been done to not simply behave the way it does. For example always assume the test is true or false.

But having Sieve Testers is better than nothing or having to run the actual script sprinkled with additional trace displays (addheaders usually) and sending test cases that you have to compose and send to yourself.

In a old ticket I once asked why they don't really maintain Sieve Tester and was told they had plans to rewrite it. That was years ago now. They say very few of their users ever write their own Sieve code so it's low priority and they never seem to make any time to work on it. From what I can tell the only changes they make is to fix the require command so it doesn't choke on new extensions that FM might add to their boiler plate code (e.g., the JMAP additions).

Last edited by xyzzy : 12 Jan 2022 at 07:38 AM.
xyzzy is offline   Reply With Quote
Old 12 Jan 2022, 08:25 PM   #6
ArtMG
Junior Member
 
Join Date: Oct 2004
Posts: 20
Sieve Tester now presumes less

Quote:
Originally Posted by xyzzy View Post
In a old ticket I once asked why they don't really maintain Sieve Tester and was told they had plans to rewrite it. That was years ago now. They say very few of their users ever write their own Sieve code so it's low priority and they never seem to make any time to work on it. From what I can tell the only changes they make is to fix the require command so it doesn't choke on new extensions that FM might add to their boiler plate code (e.g., the JMAP additions).
Quote:
Originally Posted by JeremyNicoll View Post
I've never used the Sieve Tester but I have noticed that it gets mentioned every so often.

Unfortunately I'm fairly sure that that's been in discussions about how (a) it doesn't work very well, and (b) that Fastmail have decided not to keep it uptodate. If both those things are still true then errors from it might be misleading.
Thanks to you both for your useful feedback about the Sieve Tester and its pitfalls.

It may reassure you to hear they have changed their tack, maybe to prevent Sieve Tester from drifting too far from their production environment. Now, when you manually Edit custom Sieve Script rules, you will see the first block in (uneditable) grey is the current require []; statement - presumably listing all the Extensions currently supported in production. When you go to run Sieve Tester there is NO built in require statement. This means that the requires is always explicit, which forces you to build your own - or, better, copy it from your Sieve editor instance. That way you are testing against the same set of Sieve Extensions that are in production (give or take versions).

Just in case I tried adding require ["mime"]; into my real Sieve Script and it failed with the same error as in the Sieve Tester (line X: Unsupported feature(s) in "require": "mime") whereas require ["fileinto"]; worked fine. This satisfied me that the real Sieve Script fails in the same way the tester did in my first post.
ArtMG is offline   Reply With Quote
Old 13 Jan 2022, 07:19 AM   #7
xyzzy
Essential Contributor
 
Join Date: May 2018
Posts: 474
Quote:
Originally Posted by ArtMG View Post
Now, when you manually Edit custom Sieve Script rules, you will see the first block in (uneditable) grey is the current require []; statement - presumably listing all the Extensions currently supported in production.
Actually that's not quite the case. There are some extensions that are not included that are supported. In my script I had to add a require "encoded-character" line (as the first line of the edit block following the FM generated require - nothing can precede requires) to support some unicode character range testing I wanted to do.

I'm doing this from memory so I could be wrong but if I recall I believe the Sieve standard specifies a core set of of extensions any Sieve interpreter needs to support and (lucky for me) "encoded-character" happens to be one of them (or it might be that one just happens to be mentioned in the rfc5228 standards spec). So while the FM generated require is all the extensions FM will ever need for it's UI functions the fact that I could add "encoded-character" means it's not all the extensions their Sieve interpreter supports. So as you did all you can do is try it in Sieve Tester to see if it errors out.

Last edited by xyzzy : 13 Jan 2022 at 07:31 AM.
xyzzy 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 10:40 PM.

 

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