I want to provide links to specific GMail folders, GMail messages, Google Drive items etc on a company webpage.

Users may have multiple Google accounts and it is not guaranteed that their primary / default account is the company account.

You'd expect this to be trivial and well documented, but ... not so much. Google multi-account support uses URLs with /u/2 (or similar) to differentiate users by login ordinal position in the current session. These links break if the user logs out of an account then back in and they cannot be shared correctly between users.

Google accounts have the seemingly undocumented feature of supporting /[email protected] links which work but require a fully qualified user account. I could not find any documentation on it, nor any listing of supported paramters, and my guesses did not turn up any obvious "authdomain" type links that'd pick the currently logged in user matching the domain-part.

The redirect mechanism used by Google for subdomains does not appear to work for gmail links. You can't take a link to https://mail.google.com/mail/u/1/#search/rfc822msgid%xxxxx%40mydomain.com and massage it into https://mail.mydomain.com/mail/u/#search/rfc822msgid%xxxxx%40mydomain.com or variants I tried with /u? etc. You'll get an error like

Secure Connection Failed

An error occurred during a connection to mail.mydomain.com. PR_END_OF_FILE_ERROR


This site can’t be reached

mail.mydomain.com unexpectedly closed the connection.


So all in all, it's ghastly. Not to mention that GMail searches to specific messages or threads are already painful; you have to "view source" because you can't customise the headers shown, then hand-concoct a rfc822msgid:THE_MSGID_HERE msgid search.

Am I missing some simple sane way to just send a link that'll take the recipient to a specific label, mailbox, message ID, search, etc?

3 Answers 3


I've just managed to make this work, thus far reliably and transparently.

TL;DR: The URL is actually multiple separate layers of instructions encapsulated within each other, so it looks "wrong" but it works.

Starting with your discovery about removing /u/[0-9]/, then ignoring everything I know about properly formed URLs, I imagined that they're processed by multiple decoupled layers of code, resulting in the following monstrosity:

https://mail.google.com/[email protected]#search/in%3Aspam+click+here

which then redirected to:


I posit that the reason this works is because the authuser mapping happens early in the parsing process by a generic Google user services layer, which creates a redirect to the locally scoped /u/ number for the intended account, naively including the remainder of the URL. Therefore, everything from the # onwards isn't actually parsed until the URL matches what gmail expects, at which point it triggers the #search code.

I haven't tried this with rfc822msgid, but it works with other basic searches, like finding "click here" in the spam folder.

  • It's hilariously bad isn't it? Commented Mar 28, 2022 at 1:49

The two best options I've concocted so far, given a link to a msgid search with original URL



Use a http-only redirect link and remove the user-id-enumerator

        ^^^^^^^^^^^^^^^     ^^^^^
        mail.mydomain.com   delete


Redirect via the Google account-chooser

Strip the user qualifier from the URL, and use the Google Account selector redirector for Google Apps at https://admin.google.com/ (but this may only work for admin accounts?)


then url-escape and prefix:


Frankly this seems utterly ridiculous. Is there some sane sensible way to do this that doesn't require mangling URLs in undocumented might-break-tomorrow-if-Google-feels-like-it ways?


I think now, but have not 100% confirmed, that if you have signed into your account (I have three currently) on this device before, and you just happen to be logged in with the wrong number (1) like /u/1, /u/2, /u/3, etc. that Google magically redirects you because it knows that when you tried this...


... that you REALLY meant this ...


... and since you did log in at some point on this device with the correct profile (3), you get a pass and we'll send you to Drive using the right session/login.

......... ORRRRRR (different altogether), it's for a user who has never logged in here, you don't have access, do you want to log in with a different account, etc etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.