This program can pull email and labels (and changes to labels) from your GMail account and store them locally in a maildir with the labels synchronized with a notmuch database. The changes to tags in the notmuch database may be pushed back remotely to your GMail account.
Gmailieer will not and can not:
- Add or delete messages on your remote account (except syncing the
trash
orspam
label to messages, and those messages will eventually be deleted) - Modify messages other than their labels
While Gmailieer has been used to successfully synchronize millions of messages and tags by now, it comes with NO WARRANTIES.
- Python 3
tqdm
google_api_python_client
(sometimesgoogle-api-python-client
)oauth2client
notmuch
python bindings: latest from git://notmuchmail.org/git/notmuch or>= 0.25
(when released)
After cloning this repository, symlink gmi
to somewhere on your path, or use python setup.py
.
This assumes your root mail folder is in ~/.mail
, all commands
should be run from the local mail repository unless otherwise specified.
- Make a directory for the gmailieer storage and state files
$ cd ~/.mail
$ mkdir account.gmail
$ cd account.gmail/
- Ignore the
.json
files in notmuch and usenew
for new tags. Set up apost-new
hook as described to process mail and remove thenew
tag afterwards. Thenew
tag is not synchronized with the remote bygmailieer
.
[new]
tags=new
ignore=*.json;
- Initialize the mail storage:
$ gmi init your.email@gmail.com
gmi init
will now open your browser and request limited access to your e-mail.
The access token is stored in
.credentials.gmailieer.json
in the local mail repository. If you wish, you can specify your own api key that should be used.
- You're now set up, and you can do the initial pull.
Use
gmi -h
orgmi command -h
to get more usage information.
will pull down all remote changes since last time, overwriting any local tag changes of the affected messages.
$ gmi pull
the first time you do this, or if a full synchronization is needed it will take longer.
will push up all changes since last push, conflicting changes will be ignored
unless -f
is specified. these will be overwritten with the remote changes at
the next pull
.
$ gmi push
$ cd ~/.mail/account.gmail
$ gmi sync
This effectively does a push
followed by a pull
. Any conflicts detected
with the remote in push
will not be pushed. After the next pull
has been
run the conflicts should be resolved, overwriting the local changes with the
remote changes. You can force the local changes to overwrite the remote changes
by using push -f
.
gmailieer ships with an API key that is shared openly, this key shares API quota, but cannot be used to access data unless access is gained to your private access_token
or refresh_token
.
You can get an api key for a CLI application to use for yourself. Store the client_secret.json
file somewhere safe and specify it to gmi auth -c
. You can do this on a repository that is already initialized.
-
The GMail API does not let you sync
muted
messages. Until this Google bug is fixed, themute
andmuted
tags are not synchronized with the remote. -
The
todo
label seems to be reserved and will be ignored. -
Only one of the tags
inbox
,spam
, andtrash
may be added to an email. For the time being,trash
will be prefered overspam
, andspam
over inbox.