Re: [notmuch] Guide for new users?

Subject: Re: [notmuch] Guide for new users?

Date: Sun, 22 Nov 2009 18:02:36 +0100

To: Brett Viren, Jjgod Jiang

Cc: notmuch@notmuchmail.org

From: Jed Brown


On Sun, 22 Nov 2009 09:41:16 -0500, Brett Viren <brett.viren@gmail.com> wrote:
> On Sat, Nov 21, 2009 at 11:44 PM, Jjgod Jiang <gzjjgod@gmail.com> wrote:
> 
> > 1. What's the most efficient way to sync mails from my gmail
> > account to a local Maildir? I've tried offlineimap but it
> > keeps crashing python (!) on my system (python 2.6, Mac OS X
> > 10.6.2).
> 
> OfflineIMAP would have been my suggestion.

Yes, however it will change flags which changes file names and currently
confuses notmuch.  I synced [Gmail].All Mail with OfflineIMAP and am now
using Getmail to pull via POP.  In the Gmail settings, activate POP
starting at the current time.  I'll switch back to OfflineIMAP when
notmuch is happy with changing file names.

The following should save notmuch + Gmail users some time.


~/.getmail/gmail:

[retriever]
# Getmail can also do IMAP
# type = SimpleIMAPSSLRetriever
# server = imap.gmail.com
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = yourname@gmail.com
password = Pa55W0rd
# Use this with IMAP to only download one copy of each message
# mailboxes = ('[Gmail]/All Mail',)

[destination]
type = Maildir
path = ~/.mail-archive/gmail/pop/

[options]
# print messages about each action (verbose = 2)
# Other options:
# 0 prints only warnings and errors
# 1 prints messages about retrieving and deleting messages only
verbose = 2
message_log = ~/.getmail/gmail.log


With getmail, put something like this in your crontab (checks every 2
minutes)

# MIN HOUR DAY MONTH DAYOFWEEK   COMMAND
*/2 * * * * getmail -r gmail && notmuch new




~/.offlineimaprc:

[general]
accounts = GMail
maxsyncaccounts = 1
ui = Noninteractive.Basic

[Account GMail]
localrepository = Local
remoterepository = Remote
autorefresh = 1
quick = 10
postsynchook = notmuch new

[Repository Local]
type = Maildir
localfolders = /home/jed/.mail-archive/gmail/imap

[Repository Remote]
type = Gmail
folderfilter = lambda foldername: foldername in ['[Gmail]/All Mail']
remotehost = imap.gmail.com
remoteuser = yourname@gmail.com
remotepass = Pa55W0rd
ssl = yes
maxconnections = 2

#Setting realdelete = yes will Really Delete email from the server.
#Otherwise "deleting" a message will just remove any labels and
#retain the message in the All Mail folder.
realdelete = no




Note that with IMAP, your messages in '[Gmail]/All Mail' will be
delivered to a path with spaces which notmuch handles fine, but you will
need a patch

  <1258771074-25997-1-git-send-email-jed@59A2.org>

for start-process-shell-command, e.g. to apply patches from within emacs via

  | git am



* Sending messages

To send messages from Emacs via Gmail, put something like this in your ~/.emacs

(setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)) ; Must be set BEFORE loading smtpmail
      smtpmail-auth-credentials (expand-file-name "~/.authinfo")
      smtpmail-default-smtp-server "smtp.gmail.com"
      smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-smtp-service 587
      smtpmail-debug-info t ; change to nil once it works
      smtpmail-debug-verb t)
(require 'smtpmail)
(setq message-send-mail-function 'smtpmail-send-it)
(require 'starttls)


you can inline authentication, but especially if you keep ~/.emacs under
version control, you should put it separately (chmod 600).

~/.authinfo:

machine smtp.gmail.com login yourname@gmail.com password Pa55W0rd port 587


* Git
Git + Gmail users can use git send-email by putting this in your
.gitconfig

[sendemail]
        smtpserver = smtp.gmail.com
        smtpserverport = 587
        smtpencryption = tls
        smtpuser = yourname@gmail.com
        smtppass = Pa55W0rd



I hope this helps.

Jed

Thread: