For gmail how do you setup notmuch mail ?...

Jani Nikula jani at nikula.org
Sat Feb 4 04:35:05 PST 2012


On Sat, 04 Feb 2012 09:15:16 +0000, David Edmondson <dme at dme.org> wrote:
> On Sat, 4 Feb 2012 03:39:23 -0500, don warner saklad <don.saklad at gmail.com> wrote:
> > a) For gmail how do you setup notmuch mail ?...
> > 
> > b) Any workarounds?
> > 
> > c) Any kludges?

I'll describe my own setup for using notmuch with gmail. I don't pretend
it will work for everyone, but you might find some bits of it useful.

I don't even try to sync notmuch tags and gmail labels (because I rarely
use the labels or the web interface anyway), but I do get sync for
"unread" and "flagged" (gmail and Android "starred"). You'll need
maildir.synchronize_flags = true in your ~/.notmuch-config for this.

> Many people around here do that using offlineimap, which will
> synchronise an IMAP server (Gmail in this instance) with various local
> directories in Maildir format.

I use offlineimap. I run it from the notmuch pre-new hook. This means I
have to run "notmuch new" to receive new mail.

$ cat ~/.maildir/.notmuch/hooks/pre-new
#!/bin/sh
exec /usr/bin/offlineimap

I only sync "All Mail" from gmail. Perhaps there would be some
optimizations that could be done, but I haven't bothered yet.

$ cat ~/.offlineimaprc
[general]
accounts = Gmail
ui = Noninteractive.Basic

[Account Gmail]
localrepository = Local
remoterepository = Remote

[Repository Local]
type = Maildir
localfolders = ~/.maildir

[Repository Remote]
type = IMAP
ssl = yes
remotehost = imap.gmail.com
remoteuser = USER at gmail.com
expunge = no
realdelete = no

folderfilter = lambda foldername: foldername in ['[Gmail]/All Mail']
nametrans = lambda foldername: re.sub('^\[Gmail\]/All Mail', 'gmail', foldername)

> Sending mail via Gmail can be done in various ways. You can set up your
> local MTA (Postfix, Exim, ...) to deliver mail via Gmail, or have Emacs
> do the same directly using the smtpmail.el package.

Personally I use msmtp (msmtp and msmtp-mta packages in Debian based
distros). The msmtp-mta sets up a sendmail-like binary that works out of
the box in Emacs. Beware that it doesn't have a local queue, it works
synchronously.

$ cat ~/.msmtprc
defaults
logfile ~/.msmtp.log
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account default
host smtp.gmail.com
from USER at gmail.com
tls on
tls_starttls off
auth on
user USER at gmail.com

Finally, I use goobook to use the gmail contacts as addressbook in
Emacs. See http://mid.gmane.org/87zkfuh3i0.fsf@nikula.org for that.


HTH,
Jani.


More information about the notmuch mailing list