1

Trying to set up a "catch-all" rule in Gmail, the rule is catching all incoming messages to the domain however I want to exclude mail sent to specific addresses in the catch-all rule.

Have followed this: https://robbettis.blog/setting-a-catchall-email-for-g-suite-in-2018/ but with the variation of changing "1. Specify envelope recipients to match" from "All Recipients" to "Pattern Match"

and then used: Match everything except for specified strings

to try something like: ^(?!(red|green|blue)$).+$

in the pattern to match but Google apparently uses a different standard of RegExp and says my regexp has invalid syntax.

I don't have a strong RegExp background, any advice is appreciated.

Can someone please help finding an expression google's system will accept to achieve this or an alternative to achieve the same outcome?

biroshima
  • 71
  • 2
  • 7
  • 1
    In the pattern provided `^(?!(red|green|blue)$).+$`, what exactly are you trying to obtain? Am I correct in assuming you want to match anything that does not start with any of `red;blue;green`? If so, is there any reason for the first `$` sign? – niko May 20 '19 at 08:04
  • Have you tried breaking down the regex you're trying to use into smaller parts, to help identify which character(s) specifically cause the problem? For example, presumably if you start with just `red`, it will work, what about if you make that `(red)`, then `(red|green)`, etc? – DaveyDaveDave May 20 '19 at 08:07
  • 1
    From the catch all I am trying to exclude messages sent to "red@mydomain.com" or "green@mydomain.com" etc. – biroshima May 21 '19 at 05:07

2 Answers2

1

The flavour of regex used here is RE2 – https://github.com/google/re2/wiki/Syntax which doesn't support (before) text not matching such as (?!example).

In terms of a solution, a rule with a lower numbered order will be enacted first. So perhaps you could capture the ^(red|green|blue).+$ items using that to do x, then with the next rule do the desired action y.

Jake Lodge
  • 11
  • 1
0

You can achieve this by excluding certain emails using an Address List. To access this feature, your catch-all rule needs to be defined in the parent organisational unit's Routing. Default Routing does not provide the "Address lists" option.

I recently had this explained to me step by step by a Google Support staff member so thought I'd share the process for others.

  1. Navigate to "Routing", it's the one at the bottom: Routing

|

  1. Choose your parent organisational unit and click "ADD ANOTHER RULE". You may not have any child organisational units, in which case it will be the only one that appears here: ADD ANOTHER RULE

|

  1. Under "Email messages to affect", choose "Inbound" and "Internal – Receiving": Email messages to affect

|

  1. Under "For the types of messages above, do the following" enter the preferred action to take. For example, "Modify message" > "Change envelope recipient": Action to take

|

  1. Click "Show options" to reveal options for "Address lists" and "Account types to affect"
  • Choose "Apply address lists to recipients" ("correspondents" means senders)
  • Choose "Bypass this setting for specific addresses/domains"
  • Add or create a list of emails that you want to exclude from this catch-all rule. This is the magical part :). In the example below, I've created a list called "Exclude from catch-all rules". You can use this list across multiple catch-all rules for different domains.
  • Under "Account types to affect", untick "Users", tick " Unrecognised/catch-all" Magical options

|

  1. Under "Envelope filter", choose "Only affect specific envelope recipients" and select "Pattern match" to enter your catch-all regular expression: enter image description here
camslice
  • 571
  • 6
  • 8