unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
@ 2017-03-13 10:55 Gaute Hope
  2017-03-13 13:13 ` David Bremner
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Gaute Hope @ 2017-03-13 10:55 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 849 bytes --]

Hi,

  'gmailieer' (or 'gmi') is a small program that 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.

The initial fetch of all emails takes some time, but synchronizing
labels and tags, and checking for new messages, is usually done in 1-2
seconds.

It requires the most recent notmuch, the python googleapi bindings and
tqdm.

Disclaimer:

  This is still experimental, but it does not have access to delete
  e-mail on your account - only fetch and change labels, so damage
  should be limited.



Instructions and source code can be found here:

  https://github.com/gauteh/gmailieer




Regards, Gaute

[-- Attachment #2: Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
  2017-03-13 10:55 [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail Gaute Hope
@ 2017-03-13 13:13 ` David Bremner
  2017-03-14 15:51 ` Rafael Avila de Espindola
  2017-04-03 14:35 ` Rafael Avila de Espindola
  2 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2017-03-13 13:13 UTC (permalink / raw)
  To: Gaute Hope, notmuch

Gaute Hope <eg@gaute.vetsj.com> writes:

> Hi,
>
>   'gmailieer' (or 'gmi') is a small program that 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.

Hi Gaute;

Thanks for writing this. It seems like the right approach for people who
want to sync gmail labels with notmuch.

d

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
  2017-03-13 10:55 [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail Gaute Hope
  2017-03-13 13:13 ` David Bremner
@ 2017-03-14 15:51 ` Rafael Avila de Espindola
       [not found]   ` <87k27r26xd.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
  2017-04-03 14:35 ` Rafael Avila de Espindola
  2 siblings, 1 reply; 10+ messages in thread
From: Rafael Avila de Espindola @ 2017-03-14 15:51 UTC (permalink / raw)
  To: Gaute Hope, notmuch


That looks really interesting. What is the license? :-)

Cheers,
Rafael

Gaute Hope <eg@gaute.vetsj.com> writes:

> Hi,
>
>   'gmailieer' (or 'gmi') is a small program that 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.
>
> The initial fetch of all emails takes some time, but synchronizing
> labels and tags, and checking for new messages, is usually done in 1-2
> seconds.
>
> It requires the most recent notmuch, the python googleapi bindings and
> tqdm.
>
> Disclaimer:
>
>   This is still experimental, but it does not have access to delete
>   e-mail on your account - only fetch and change labels, so damage
>   should be limited.
>
>
>
> Instructions and source code can be found here:
>
>   https://github.com/gauteh/gmailieer
>
>
>
>
> Regards, Gaute
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
       [not found]   ` <87k27r26xd.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
@ 2017-03-14 21:15     ` Gaute Hope
  2017-03-27  2:32       ` Rafael Avila de Espindola
  0 siblings, 1 reply; 10+ messages in thread
From: Gaute Hope @ 2017-03-14 21:15 UTC (permalink / raw)
  To: notmuch, Rafael Avila de Espindola

Rafael Avila de Espindola writes on mars 14, 2017 16:51:
> 
> That looks really interesting. What is the license? :-)

Ay, GPL v3+ it is!

- gaute


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
  2017-03-14 21:15     ` Gaute Hope
@ 2017-03-27  2:32       ` Rafael Avila de Espindola
       [not found]         ` <878tnrla97.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
  0 siblings, 1 reply; 10+ messages in thread
From: Rafael Avila de Espindola @ 2017-03-27  2:32 UTC (permalink / raw)
  To: Gaute Hope, notmuch

I currently have a mbsync + notmuch setup and I am just about to give
this a try.

One question is what the notmuch setup should look like. I assume I
should create a new config file pointing to the directory where the
emails will be written to. Do I have to run notmuch setup to create the
db?

Cheers,
Rafael

Gaute Hope <eg@gaute.vetsj.com> writes:

> Rafael Avila de Espindola writes on mars 14, 2017 16:51:
>> 
>> That looks really interesting. What is the license? :-)
>
> Ay, GPL v3+ it is!
>
> - gaute

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
       [not found]         ` <878tnrla97.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
@ 2017-03-27  5:52           ` Gaute Hope
  2017-03-27 13:23             ` Rafael Espíndola
  0 siblings, 1 reply; 10+ messages in thread
From: Gaute Hope @ 2017-03-27  5:52 UTC (permalink / raw)
  To: notmuch, Rafael Avila de Espindola

Rafael Avila de Espindola writes on mars 27, 2017 4:32:
> I currently have a mbsync + notmuch setup and I am just about to give
> this a try.
>
> One question is what the notmuch setup should look like. I assume I
> should create a new config file pointing to the directory where the
> emails will be written to. Do I have to run notmuch setup to create the
> db?
>

Yes, it is a good idea to just back up your entire notmuch db and set up
a new one to test gmailieer with.

gmailieer respects $NOTMUCH_CONFIG and reads it to figure out which
'new' tags to add (no need to use inbox or unread here, that will only
create confusion - I only use 'new' to do tagging).

Assuming you want to set up a separate notmuch database to test you do
the following:

first:
    get a client secret API key for gmailieer [0], you only need this
  during setup or if gmailieer needs to be re-authenticated. so store it
  somewhere safe, say: ~/.secret/client_secret.json. ideally this should
  be unnecessary [1].

# setting up a separate notmuch db
$ mkdir ~/test_mail/  # our new mail root
$ cd ~/test_mail
$ export NOTMUCH_CONFIG=$(pwd)/.notmuch-config
$ mkdir mail          # new mail database root
$ notmuch setup
  * specify ~/test_mail/mail as mail database
  * specify only 'new' as new tag
$ notmuch new         # create db
$ cd mail

NOTE: As long as you are using a non-standard notmuch config location make
sure that environment variable is set when using gmailieer.

# setting up gmailieer
$ mkdir gmail
  * this will be the gmailieer local repository.
  * it should be a sub-dir of the root mail db.
  * you can keep other mail (from other accounts) outside this
    gmailieer local repository.
$ cd gmail
$ gmi auth -c ~/.secret/client_secret.json
  * authenticate gmailieer, choose the correct account, say:
    charlie.root@gmail.com
$ gmi init -a charlie.root@gmail.com # gmailieer should now be set up
$ gmi pull # does the initial pull, fetching all you messages - this
           # could take some time.

When you want to synchronize your account you do:
$ gmi sync    # which effectively does gmi push; gmi pull

this will also update the notmuch database so it should not be necessary
to run 'notmuch new' afterwards.

Regards, Gaute

[0] https://console.developers.google.com/flows/enableapi?apiid=gmail
[1] https://github.com/gauteh/gmailieer/issues/1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
  2017-03-27  5:52           ` Gaute Hope
@ 2017-03-27 13:23             ` Rafael Espíndola
  2017-03-27 13:41               ` Gaute Hope
  0 siblings, 1 reply; 10+ messages in thread
From: Rafael Espíndola @ 2017-03-27 13:23 UTC (permalink / raw)
  To: Gaute Hope; +Cc: notmuch

> Assuming you want to set up a separate notmuch database to test you do
> the following:
>
> first:
>    get a client secret API key for gmailieer [0], you only need this
>  during setup or if gmailieer needs to be re-authenticated. so store it
>  somewhere safe, say: ~/.secret/client_secret.json. ideally this should
>  be unnecessary [1].
>
> # setting up a separate notmuch db
> $ mkdir ~/test_mail/  # our new mail root
> $ cd ~/test_mail
> $ export NOTMUCH_CONFIG=$(pwd)/.notmuch-config
> $ mkdir mail          # new mail database root
> $ notmuch setup
>  * specify ~/test_mail/mail as mail database
>  * specify only 'new' as new tag
> $ notmuch new         # create db
> $ cd mail
>
> NOTE: As long as you are using a non-standard notmuch config location make
> sure that environment variable is set when using gmailieer.
>
> # setting up gmailieer
> $ mkdir gmail
>  * this will be the gmailieer local repository.
>  * it should be a sub-dir of the root mail db.
>  * you can keep other mail (from other accounts) outside this
>    gmailieer local repository.
> $ cd gmail
> $ gmi auth -c ~/.secret/client_secret.json
>  * authenticate gmailieer, choose the correct account, say:
>    charlie.root@gmail.com
> $ gmi init -a charlie.root@gmail.com # gmailieer should now be set up
> $ gmi pull # does the initial pull, fetching all you messages - this
>           # could take some time.

It is currently running. Thank you so much.

The only things I noticed so far:

* running auth before init fails, but running init -c ... -a ... works
* I had to name the auth file client_secret.json or "gmi pull" would
fail trying to read it.

Thanks again for writing this. It seems a much better way to sync with
gmail. My previous setup was to use mbsync. It is really fast for
fetching new emails (--pull-new), but with imap the only way to get
flag changes (including read/unread) seems to be to ask for the flag
of every message!

Cheers,
Rafael

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
  2017-03-27 13:23             ` Rafael Espíndola
@ 2017-03-27 13:41               ` Gaute Hope
  0 siblings, 0 replies; 10+ messages in thread
From: Gaute Hope @ 2017-03-27 13:41 UTC (permalink / raw)
  To: Rafael Espíndola; +Cc: notmuch

Rafael Espíndola writes on mars 27, 2017 15:23:
>> $ gmi pull # does the initial pull, fetching all you messages - this
>>           # could take some time.
> 
> It is currently running. Thank you so much.
> 
> The only things I noticed so far:
> 
> * running auth before init fails, but running init -c ... -a ... works
> * I had to name the auth file client_secret.json or "gmi pull" would
> fail trying to read it.


Right, that should be the other way around. I'll update the README.

There are two secret files. One is the API client_secret which can be
specified with the '-c' option (also for pull), this one is only needed
initially and can otherwise be stored somewhere else:

When authenticating (either running 'auth' or some operation requiring
authentication: pull/push) a local access token is retrieved, this is
stored in: .credentials.gmailieer.json in the local mail repository.

> gmail. My previous setup was to use mbsync. It is really fast for
> fetching new emails (--pull-new), but with imap the only way to get
> flag changes (including read/unread) seems to be to ask for the flag
> of every message!

Thanks!

- gaute

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
  2017-03-13 10:55 [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail Gaute Hope
  2017-03-13 13:13 ` David Bremner
  2017-03-14 15:51 ` Rafael Avila de Espindola
@ 2017-04-03 14:35 ` Rafael Avila de Espindola
       [not found]   ` <8760ily2wg.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
  2 siblings, 1 reply; 10+ messages in thread
From: Rafael Avila de Espindola @ 2017-04-03 14:35 UTC (permalink / raw)
  To: Gaute Hope, notmuch

After a few issues with the initial sync this is working perfectly.

Thanks a lot, it is a big improvement over mbsync.

Cheers,
Rafael

Gaute Hope <eg@gaute.vetsj.com> writes:

> Hi,
>
>   'gmailieer' (or 'gmi') is a small program that 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.
>
> The initial fetch of all emails takes some time, but synchronizing
> labels and tags, and checking for new messages, is usually done in 1-2
> seconds.
>
> It requires the most recent notmuch, the python googleapi bindings and
> tqdm.
>
> Disclaimer:
>
>   This is still experimental, but it does not have access to delete
>   e-mail on your account - only fetch and change labels, so damage
>   should be limited.
>
>
>
> Instructions and source code can be found here:
>
>   https://github.com/gauteh/gmailieer
>
>
>
>
> Regards, Gaute
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail
       [not found]   ` <8760ily2wg.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
@ 2017-04-03 14:51     ` Gaute Hope
  0 siblings, 0 replies; 10+ messages in thread
From: Gaute Hope @ 2017-04-03 14:51 UTC (permalink / raw)
  To: notmuch, Rafael Avila de Espindola

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

Rafael Avila de Espindola writes on april 3, 2017 16:35:
> After a few issues with the initial sync this is working perfectly.
>
> Thanks a lot, it is a big improvement over mbsync.
>

Great, thanks for the patches! This made inital sync much more robust.

I have a non-user-api-key version working [0], but I need to figure out if
it is safe first [1].

- Gaute

[0] https://github.com/gauteh/gmailieer/pull/9
[1] http://stackoverflow.com/questions/43173367/is-it-safe-to-distribute-client-id-and-client-secret-for-google-api-for-an-insta

[-- Attachment #2: Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-04-03 14:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13 10:55 [gmailieer] fast fetch and two-way tag synchronization between notmuch and GMail Gaute Hope
2017-03-13 13:13 ` David Bremner
2017-03-14 15:51 ` Rafael Avila de Espindola
     [not found]   ` <87k27r26xd.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
2017-03-14 21:15     ` Gaute Hope
2017-03-27  2:32       ` Rafael Avila de Espindola
     [not found]         ` <878tnrla97.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
2017-03-27  5:52           ` Gaute Hope
2017-03-27 13:23             ` Rafael Espíndola
2017-03-27 13:41               ` Gaute Hope
2017-04-03 14:35 ` Rafael Avila de Espindola
     [not found]   ` <8760ily2wg.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-ti ckle-me>
2017-04-03 14:51     ` Gaute Hope

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).