Sunday, December 27, 2020

Mapping BCC for catch-all with Google Workspace

Long ago, before Google Workspace, before G-Suite, when it was called something different, you could sign-up and get an account for your domain with five free users. I'm still on that plan.

In any case, if you've used admin.google.com to create a user (alpha@yourdomain.com) with the catch-all secondary email (i.e. *@yourdomain.com), then you can use that account to multiply users by forwarding alice@yourdomain.com and bob@yourdomain.com to Alice and Bob's actual (probably gmail) accounts. Of course they won't be able to reply from these addresses, but I've found it nice to have.

You can achieve this by logging into gmail as alpha@yourdomain.com and setting up: Settings > Filters

Matches: deliveredto:(alice@yourdomain.com)
Do this: Skip Inbox, Mark as read, Forward to alice.long.and.complicated@gmail.com

Matches: deliveredto:(bob@yourdomain.com)
Do this: Skip Inbox, Mark as read, Forward to bob.long.and.complicated@gmail.com

This brings us to the difficulty in BCC. Here's what your alpha account actually receives when the following emails are sent.

To: alice@yourdomain.com

Delivered-To: alice@yourdomain.com
Received: from ... for <alice@yourdomain.com>
To: "alice@yourdomain.com" <alice@yourdomain.com>

To: alice@yourdomain.com, bob@yourdomain.com

Delivered-To: bob@yourdomain.com
To: "alice@yourdomain.com" <alice@yourdomain.com>, "bob@yourdomain.com" <bob@yourdomain.com>

CC: alice@yourdomain.com

Delivered-To: alice@yourdomain.com
Received: from ... for <alice@yourdomain.com>
CC: "alice@yourdomain.com" <alice@yourdomain.com>

CC: alice@yourdomain.com, bob@yourdomain.com

Delivered-To: alice@yourdomain.com
CC: "alice@yourdomain.com" <alice@yourdomain.com>, "bob@yourdomain.com" <bob@yourdomain.com>

BCC: alice@yourdomain.com

Delivered-To: alice@yourdomain.com
Received: from ... for <alice@yourdomain.com>

BCC: alice@yourdomain.com, bob@yourdomain.com

Delivered-To: alice@yourdomain.com

Note that when you send to both alice and bob, somewhere along the way it realizes that there is only *@yourdomain.com and your alpha account only receives a message for one party. The first conclusion is that you must not rely on deliveredto in your filter since that always contains just one party. The next conclusion is that you can't make this scheme work for BCC since that method deletes information.

However you can notice that the Received doesn't include an email when there were multiple recipients. So you could decide that matching Delivered-To without matching To or CC or Received means that you should forward to all possible aliases. It's messy, but if you're only forwarding for a few family members, it's not terrible.

So, to start, you need something like the following. Note it seems this wouldn't work because the first filter would remove it from the inbox, but all filters are run on all incoming mail, even if a previous filter matched. So I guess the filters are run on the initial state of the received message.

Matches: (to:(alice@yourdomain.com) OR cc:(alice@yourdomain.com) OR deliveredto:(alice@yourdomain.com))
Do this: Skip Inbox, Mark as read, Forward to alice.long.and.complicated@gmail.com

Matches: (to:(bob@yourdomain.com) OR cc:(bob@yourdomain.com) OR deliveredto:(bob@yourdomain.com))
Do this: Skip Inbox, Mark as read, Forward to bob.long.and.complicated@gmail.com

The above handles all cases except when both parties are in the BCC. For that we need a special rule that guesses when a BCC entry was dropped. I didn't bother checking Received since the only point of BCC is multiple recipients. So I just note that DeliveredTo without To or CC implies BCC and I guess that both parties were always on the BCC.

Matches: deliveredto:(alice@yourdomain.com) -{(to:(alice@yourdomain.com) OR cc:(alice@yourdomain.com))}
Do this: Forward to bob.long.and.complicated@gmail.com

Matches: deliveredto:(bob@yourdomain.com) -{(to:(bob@yourdomain.com) OR cc:(bob@yourdomain.com))}
Do this: Forward to alice.long.and.complicated@gmail.com

This works with two deficiencies:
- alice will receive an email that was only "BCC bob" (because we guess that "BCC alice" was deleted when in fact it was never there)
- alice won't receive an email that was "To: bob, BCC: alice" (because we only guess that "BCC alice" was present when bob wasn't To/CC)

web
{ "loggedin": false, "owner": false, "avatar": "", "render": "nothing", "trackingID": "UA-36983794-1", "description": "", "page": { "blogIds": [ 710 ] }, "domain": "holtstrom.com", "base": "\/michael", "url": "https:\/\/holtstrom.com\/michael\/", "frameworkFiles": "https:\/\/holtstrom.com\/michael\/_framework\/_files.4\/", "commonFiles": "https:\/\/holtstrom.com\/michael\/_common\/_files.3\/", "mediaFiles": "https:\/\/holtstrom.com\/michael\/media\/_files.3\/", "tmdbUrl": "http:\/\/www.themoviedb.org\/", "tmdbPoster": "http:\/\/image.tmdb.org\/t\/p\/w342" }