EmailDiscussions.com  

Go Back   EmailDiscussions.com > Email Service Provider-specific Forums > FastMail Forum
Register FAQ Members List Calendar Today's Posts
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 14 May 2026, 05:07 AM   #1
faldringham
Member
 
Join Date: Apr 2009
Posts: 30
Help with regular expressions?

I want to filter out emails that contain any of the words "Trash", "Reminder", or "Landscaping" in the subject. How to do that? I have tried several variations of

(?i)(trash|reminder|landscaping)

with <Subject> <matches regular expression>

in the no-preview rules setup. Can't get it to work.
Do I need quotation marks? No quotation marks? Am I indicating case-insensitive incorrectly? Do I need to use dot-asterisk(s) to indicate that anything can precede (or follow) the matching term?
faldringham is offline   Reply With Quote

Old 14 May 2026, 06:50 AM   #2
JeremyNicoll
Cornerstone of the Community
 
Join Date: Dec 2017
Location: Scotland
Posts: 854
You don't need quotes.
You don't have to indicate case insensitivity.
You don't need leading or trailing dot asterisk

Just: (trash|reminder|landscaping) should work.


Whn googling for help bear in mind that Sieve (which is the language that the filter rules get translated into from what you specify in the FM GUI) uses "POSIX" regexes. It's not PCRE.

You might find this useful: https://www.regular-expressions.info/posix.html

Also: https://www.regular-expressions.info/refflavors.html ... which allows you to follow a link to a sub-topic (eg character classes) & will then offer you the chance to nominate two flavours of regex (eg PCRE if you know that well) & POSIX ... & let you see to what extent those flavours of regex implement various things.


I should add that - if you look at the Sieve rules generated from the GUI - you'll see some escaping of characters - which you don't (as far as I know ) need to do yourself in your GUI rules - indeed if you do escape stuff in the GUI it'll (probably) be doubled in what's generated. The distinction matters because most of the advice on the internet for this sort of filtering (Sieve) is for people writing rules directly in Sieve (which in fact FM's system allows you to do if you need to).

If there's any chance that you'd want to write your own Sieve rules you really need to read the RFCs (technical specs for lots of internet stuff) for Sieve ... which are hard going if you've not got an academic Computing background. These include:

https://tools.ietf.org/html/rfc3028 the original Sieve RFC, made obsolete by

https://tools.ietf.org/html/rfc5228 a newer base Sieve specification

https://tools.ietf.org/html/rfc2244 describes comparators, eg for testing INTEGERS

https://tools.ietf.org/html/rfc3431 adds: counting and value-comparison tests; see rfc5231 too

https://tools.ietf.org/html/rfc5173 adds: testing of BODY contents

https://tools.ietf.org/html/rfc5229 adds: "Variables" support

https://tools.ietf.org/html/rfc5231 .... improves rfc3431

https://tools.ietf.org/html/rfc5293 adds: "editheader" support to add/delete headers

https://tools.ietf.org/html/rfc5429 adds: REJECT and extended EREJECT

https://tools.ietf.org/html/rfc6785 adds: IMAP

Last edited by JeremyNicoll : 14 May 2026 at 07:50 AM.
JeremyNicoll is offline   Reply With Quote
Old 14 May 2026, 10:50 PM   #3
faldringham
Member
 
Join Date: Apr 2009
Posts: 30
Thanks. I will give it another try.
faldringham is offline   Reply With Quote
Old Today, 01:02 AM   #4
faldringham
Member
 
Join Date: Apr 2009
Posts: 30
I tried the above, but it still wasn't working.

My goal was to send the matching emails directly to Trash, but instead they kept going to Spam.

Reviewing the automatically generated Sieve rules, I noticed that any rules I was adding using the routine custom-rules template were being added after the automatic Spam screening rules. So I gave up on the template and added a custom Sieve rule at the beginning, before the automatic Spam screen. So far, that seems to have fixed the problem.

I would give the Help information on FastMail's website a low grade in this area, as the problem I had been experiencing would seem to be a pretty common issue--yet I didn't see information on how to use the standard rules template to send emails to Trash, bypassing Spam screening, until I really dug into the weeds.

I wish they would spend some of the resources they use for periodically "upgrading" the user interface (with changes I usually don't want or need) on polishing the Help info instead.

This issue of having the template-generated rules be ignored and getting unwanted emails sent again and again to Spam has been annoying me for years, actually.
faldringham is offline   Reply With Quote
Old Today, 01:07 AM   #5
faldringham
Member
 
Join Date: Apr 2009
Posts: 30
(I suppose I should add that while I don't have an academic computing background, I write scripts in my spare time all the time--web browser extensions in Javascript, other scripts in Python, and PowerShell, and in the past Swift and AppleScript. I am very familiar with regular expressions in general, but had never worked with the Sieve script syntax before now.)
faldringham is offline   Reply With Quote
Old Today, 04:08 AM   #6
JeremyNicoll
Cornerstone of the Community
 
Join Date: Dec 2017
Location: Scotland
Posts: 854
Quote:
Originally Posted by faldringham View Post
My goal was to send the matching emails directly to Trash, but instead they kept going to Spam.

Reviewing the automatically generated Sieve rules, I noticed that any rules I was adding using the routine custom-rules template were being added after the automatic Spam screening rules.
Ah.

I have no "blocked senders" defined.

In the spam settings ... well first you need to know there's a GUI problem (which I noted a while ago) which is that if you explore what happens if you choose each of the four levels the system loses any explicit values/choices you previously made - so it's important that you note those BEFORE clicking anything.

(It used to be worse - some options were behind an "Advanced" link & as you chose different levels, values you couldn't even see if you'd not first clicked the link got changed & you wouldn't know it.)


I just had a wee explore and found that an option that the GUI showed me when I entered it just now ... is no longer present. Huh.


Anyway I (now) have:


..... protection level - Custom

..... Move msgs with a score of 20.0 to Spam - turned on


..... Permanently delete - turned off


..... Mark spam as read - turned off


Virtually nothing ends up in "Spam".


Quote:
Originally Posted by faldringham View Post
I would give the Help information on FastMail's website a low grade in this area, as the problem I had been experiencing would seem to be a pretty common issue--yet I didn't see information on how to use the standard rules template to send emails to Trash, bypassing Spam screening, until I really dug into the weeds.

I wish they would spend some of the resources they use for periodically "upgrading" the user interface (with changes I usually don't want or need) on polishing the Help info instead.
Concur! In the past I've raised tickets for documentation errors and even once they've agreed, MONTHS passed before they fixed the text.


Quote:
Originally Posted by faldringham View Post
This issue of having the template-generated rules be ignored and getting unwanted emails sent again and again to Spam has been annoying me for years, actually.
If you turn off the logic that moves things to Spam you should then be able to use normal rules - possibly ones that look at the spam-score headers - to do what you want with them.
JeremyNicoll is offline   Reply With Quote
Reply



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:52 AM.

 

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