Simple CLI to migrate email from specific people (girlfriend, mum) *from* your work Google Apps *to* personal GMail
A simple command-line tool to divide your personal GMail from your work Google Apps/GMail account. Remove personal messages from your work accounts while still keeping them available in the cloud.
Uses the GMail API.
You have a work email on Google Apps and a personal GMail (or Google Apps) account. Your significant other (or mother, or dogsitter) sometimes sends you stuff to your work address, which you want to keep, but don’t want to share with your assistant/auditor/etc.
This tool lets you move personal messages that have somehow leaked into your work account back to your personal account. It maintains threads and tries (pretty successfully) to deduplicate based on message content.
Essentially all GDivide does is:
private-correspondents in your work emailWith a bit of patience you can get the same result from using an IMAP client to transfer messages. However things like correct date display on imported messages can be a crapshoot, and processing large numbers (or even small numbers) of messages in Thunderbird or Outlook is no fun.
This tool does not work perfectly but it’s much better than dragging 5,000 messages between Outlook mailboxes.
--skip-deduplicate option.429 errors)By default (see Options below) gdivide will make changes to BOTH email accounts that you give it. It may result in you losing data (although it doesn’t delete anything irrevocably, just moves to trash, so you should be able to undo any changes if you need to as long as you move quick-ish). You should make sure you have backups of any important data before using it. If you want to get a full dump of your email data you can do so via Google Takeout.
I take no responsibility for any damage resulting from use of this tool, howsoever caused, including by negligence.
Based on https://developers.google.com/identity/protocols/OAuth2InstalledApp - in particular
Installed apps are distributed to individual machines, and it is assumed that these apps cannot keep secrets.
I am distributing this app with oauth secret available in the code. I may revoke this at any time for any or no reason if there is any abuse associated with it.
pip install -r requirements.txtpython gdivide.py --work-gmail me@work.com --home-gmail me@personal.com --private-correspondents girlfriend@example.com mum@gmail.com--work-gmail [name@example.com]
The account you want to move emails FROM.
WARNING: EMAILS IN THIS ACCOUNT MAY GET TRASHED/DELETED
--home-gmail [name@example.com]
The account you want to move emails TO.
WARNING: EMAILS WILL BE ADDED TO THIS ACCOUNT
--private-correspondents PRIVATE_CORRESPONDENTS [PRIVATE_CORRESPONDENTS ...]
Email address(es) that you want to cleanse from your
work google account and move to home gmail
--limit [INT]
Only process this many messages
--dry-run
Don't actually make any changes to either home or work accounts
--skip-deduplicate
Don't attempt to deduplicate based on existing emails in target inbox
--clear-credentials
Delete any stored OAuth credentials
IMAP is a pain, and I wanted to see if the GMail API was any better.
The short story is, yes and no. In practice you seem to have to learn about MIME encodings, multipart email structures and a load of other things to do anything remotely useful, and the documentation leaves a lot to be desired.
However if you want to do simple things, it’s a lot easier to understand than IMAP.