#1373 new
Vadim Belobrovka

Regular Expressions for Conditions and Submailboxes

Reported by Vadim Belobrovka | January 6th, 2016 @ 02:41 PM

Hi,

  1. Please provide support for Regex in Smart Mailbox Conditions. "Contains" is just not cutting it.

  2. Another huge one is Regex support in Submailboxes - I would like to be able to group by unique value that is extracted via a REGEX. For example github emails that are coming in due to a given pull request communication come in this format:

    "[repo name] pull request name"

I would like to be able to extract repo name and group all the github communication emails by those repo names via Submailboxes.

All hail MailMate!
Thank you very much!
Vadim

Comments and changes to this ticket

  • Chris

    Chris February 8th, 2017 @ 12:41 AM

    Hi, I endorse the request for regex support in conditions.

    In addition, I suggest the following:

    1) add condition "Value in Header"
    2) allow user to enter header elements (e.g., custom x-headers) not found in current mails while setting up rules
    3) interface to manage, import and export rules or rulesets, so that you can easily assign them to different folders

    Fortunately, one can edit the relevant config files; that helps a lot with 2) and 3).

    May I use the opportunity to ask what "any address" includes?

  • Muescha
  • Tee Yen Ng

    Tee Yen Ng November 29th, 2017 @ 06:01 AM

    FWIW, I was just looking for a way to do just this. Turned up this ticket, but found a semi-solution subsequent. Thought it best to leave a bread crumb for anyone else searching :)

    You can use regexp in the Mailbox name format: entry under sub-mailboxes.

    I still end up with a submailbox for each individual subject, but the mailbox names are displayed as per the regexp. For example:

    ${subject.body/(.*)RFI[ -]*([0-9]+)\s*(.*)/RFI-${2} - ${3}/}
    

    Would be curious if there is a way to use the custom mailbox name format as the unique value!

    Found this over here:
    http://blog.froztbyte.net/2016/12/mailmate-submailbox-snr-hack/

  • Tee Yen Ng
  • benny

    benny November 29th, 2017 @ 12:35 PM

    • State changed from “new” to “accepted”

    @Tee Yen Ng: Thanks for the updates and for finding the relevant information yourself. The low-level editing of custom specifiers is still the only way to get regular expressions. I'm thinking it'll stay this way, but I might eventually add a GUI for creating new specifiers more easily. This is what the “accepted” state is for in this ticket.

    Sorry for not replying to this ticket earlier on.

  • Muescha

    Muescha January 25th, 2018 @ 12:58 AM

    i tried all rules for submailbox:

    ${subject.body/([\[\]a-zA-Z]*).*/${1}/}

    but for a "[abc] Subject" i always get an list of unique folders with always one entry (like the screenshot)

    i get it not working

    But i find out just Change it to "subject -> blob" i get a list of the [abc] selectors.

    BTW:

    • i think there should be a better documentation of all the hidden features
    • editing the plist fildes are to complicated just now :(
  • Mike K
  • X X

    X X July 8th, 2024 @ 03:16 PM

    • State changed from “accepted” to “new”

    I came across this while searching for a way to use regular expressions when creating a smart mailbox. I tried using regex along with the "contains" option but that did not work.

    Here's what I would like to do. Student emails at our school have a very specific format: a letter followed by nine digits, and I would like to create a smart mailbox that contains emails from those with that address format.

    Is there a way to do this?

    Thanks!

  • benny

    benny July 10th, 2024 @ 07:08 AM

    Regular expressions are not directly supported in the query system, but it's possible to introduce new specifiers which is what you need here. It's low-level, but here we go. Create this folder and file:

    /Users/<username>/Library/Application Support/MailMate/Resources/specifiers.plist
    

    Give it this content:

    {
        parsers =
        {
            extra_from = {
                header = "from";
                specifierRegex = '.*([A-Za-z]\d{9})@.*';
                specifierCaptures = {
                    1 = { specifier = "student"; };
                };
            };
        };
    }
    

    I haven't tested it, but try relaunching MailMate and then use the Statistics layout (see View > Layout) to see if you now have the option of selecting “From > Student”. You can then also see the values it found if it works.

    I'm sorry it's not more user-friendly.

  • X X

    X X July 10th, 2024 @ 08:46 AM

    Thank you very much Benny for the quick response and for the details on how to get this done!

    Can confirm this works exactly as I expected.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Mac OS X email client.

Shared Ticket Bins

Pages