Sieve Rule weirdness
Hi all,
Can anyone please tell me what I am doing wrong, such that this email: notifications-noreplyATlinkedin.comgoes into my subscriptions folder despite these rules: I thought the use of elsif meant that a subsequent elsif isn't tested if the previous if or elsif is successful. thanks, James. |
Firstly I don't think you can have a trailing comma on the end of a list.
Secondly, I don't see anything in RFC 5228 to suggest that [.@] is supported. |
Quote:
Quote:
|
Quote:
Quote:
:matches doesn't use a regular expression, it's a basic glob. You need :regex. |
Hi,
Thanks for the fast replies. Quote:
and
Quote:
|
Commas are only needed to separate multiple tests, i.e., a list of tests. It has nothing to do with multiple lines. You can put the list items on multiple lines, single lines, any combination.
I keep looking at the construct, :matches "From" "*[.@]linkedin.com" So is the intent here to look for anything or nothing followed by a dot or @ followed by linkedin.com? What's wrong with just "*@linkedin.com"? Personally I never used square brackets within a globing expression so that's what threw me off. For matches brackets are also for specifying a list of alternatives, i.e., ["a", "b", "c']. In regex brackets enclose a list of characters or character ranges. But as shown that is not a valid regex expression. The equivalent regex to a matches "*@linkedin.com" would be would be ".*@linkedin.com" or if you're a purist maybe ".+@linkedin.com". |
Quote:
Quote:
Note the double backslash. An extended regular expression would only need one to escape the dot, but the backslash character itself needs to be escaped in sieve strings if it's not escaping a double quote. |
Quote:
["*@linkedin.com", "*@*.linkedin.com"] Quote:
".+@(.*\\.)?linkedin\\.com$" taking into account that case you mentioned for the matches, i.e., any email address whose parent domain is linkedin.com. At this point then the regex is probably more concise than the matches. Of course in the real world, IMO, a matches on "*@*linkedin.com" is probably "good enough".;) Note, I created the following sieve tester script for these cases: Code:
require ["regex", "fileinto"]; |
Thanks for your reply!
Quote:
Quote:
name@domain.tld Quote:
Quote:
|
Quote:
Code:
.+@(.+\.)?linkedin\.com$ James. btw, I am not actually looking for subdomains of LinkedIn - it was just an example to use. [edit: added my proposed version] |
Quote:
cheers, James. |
Quote:
Quote:
And yes, I really meant address, not header. My mind has a tendency to mean one thing and write another too. |
Quote:
I got the gist of your code (thanks). but my question was specifically why two slahes were needed in succession. I can see that Fastmail translates my single slash into two, but why? ...I cannot see any reference to double-shlashing having a special meaning in regex (it seems to me that the first slash escapes the second slash). thanks for being so helpful :-) |
Quote:
That's why I stay away from regex in sieve whenever possible. What about this alternative approach? Code:
if anyof( |
thanks, hbs.
I was not aware of :domain, but that is certainly a robust way of doing it. Whilst I was trying to implement a rule, I was also trying to use it as a way to further my regex/sieve knowledge. Knowing that "this is how fastmail does it" is a bit of a relief as I could not find documentation anywhere for the double-slash. By the way, would the line not be: Code:
address :domain :matches "From" ["@linkedin.com", "*.linkedin.com"] cheers, James. |
All times are GMT +9. The time now is 03:44 AM. |
Copyright EmailDiscussions.com 1998-2022. All Rights Reserved. Privacy Policy