Another round of attempts at getting my email to do what I want has left me without success on the alpine+uw-imapd+offlineimap+gmail front, but I have now managed to compile Eduardo Chappa’s infamous (due to licensing issues) maildir patch into alpine. After figuring out some configuration difficulties, I am using that enhanced alpine directly on the offlineimap repository.
To summarise, I have my beloved, efficient alpine interface with access to a local copy of all of my Gmail mail, available to me whether or not I am online. Folders (other than my inbox) in alpine correspond to Gmail tags. The program offlineimap does a two-way synchronization of Gmail with my (or each) local copy of mail, so I can use Gmail’s web interface (or any other imap client talking to it) or alpine on my local machine to sort and label mail and it will all have the same effect everywhere once I’m back online and offlineimap has had a chance to run.
In principle, I can have such local repositories sync’ed with offlineimap on multiple computers. (I cannot see a problem with that, anyway, and I have two offlineimap’s running now).
In the mean time, by the way, I have learned that the Gmail interface itself is quite efficient when you learn all the keystrokes and have got Gmail’s offline feature working (requires 64 bit Google Gears, not supported). So I can now move back from that to alpine, but will not suffer as much as I used to when I want/need to use Gmail directly.
# Neat apt feature to install all compilation dependencies for alpine without installing alpine:
sudo apt-get build-dep alpine
# from just above the alpine-2.00 (or whatever) folder you downloaded, and with the maildir patch local:
patch -p0 < maildir.patch
# Compile alpine: (from just inside the alpine-2.00 (or etc) folder):
sudo make install
My gmail username is “MyName”. I set up offlineimap to put my stuff in ~/imap/gmailMyName. That is, within that folder are all my mail folders (gmail tags) plus “INBOX”, each containing a “cur”, a “new”, and a “tmp”. The latter format is a feature of the “maildir” directory/file format which offlineimap uses. Thus:
apt-get install offlineimap
Now (after running alpine once to create .pinerc) I put the following lines in my .pinerc file. (These features can be set up using alpine’s configuration menus too, of course). Thanks to Eduardo Chappa both for his instructions (see the link above), and for his kind personal help setting this up:
maildir-location=imap/gmailMyName/INBOXfolder-collections=gmailMaildir #md/imap/gmailMyName/inbox-path=#md/inboxdefault-fcc=[Gmail].Sent Mailpostponed-folder=[Gmail].Drafts
There are other sites providing example offlineimap+gmail setups, and the offlineimap site explains the following parameters. Here are some key lines (actually, sufficient as a complete set) from my .offlineimaprc file. Note that I have included “All Mail” in the do-not-sync list. It may be a good trick to start out with this setting, and then later to allow All Mail to be synced as well. So far it seems that the offlineimap repository takes up a fair bit more space locally than it does on Gmail’s servers, so if you’ve been good about tagging messages, you may want never to have a local copy of “All Mail”.
accounts = myNameGMAIL
localrepository = gmailLocal
remoterepository = gmailRemote
type = Maildir
localfolders = /home/cpbl/imap/gmailMyName
type = Gmail
remoteuser = myName@gmail.com
realdelete = no
folderfilter = lambda foldername: foldername not in [ ‘[Gmail]/Trash’,'[Gmail]/Spam’,'[Gmail]/All Mail’,]
So when that is done, simply run “offlineimap” and wait for it to sync up. You can start using alpine immediately, ie before the first sync is complete. Alpine should start up showing your Gmail inbox, and pressing “l” should show you all your tags.
I have yet to see a good description of how offlineimap treats message threads or how alpine will interact with gmail. What happens if I delete an attachment from a message in alpine, and then save it to a folder? What happens if I save one message of a thread in one folder and another of the same thread in a different folder? If I want to have two tags on a message, do I save it to a different folder and then remove the local delete mark? Does that double the disk space usage for that message in offlineimap?
It would be nice to have some local (fake smtp?) server running so that I could send my messages from alpine instantly and they would be shuttled off to my favourite real smtp server when I was next online, or just in the background…
Update 25 Nov 2009: offlineimap keeps dying on doing certain copies, I think when alpine is running, for various reasons. So I have set cron to run it every couple of minutes instead of using offlineimap’s own recheck feature. ie, install with
apt-get install gnome-schedule
and choose (i.e., run) “Scheduled tasks” from the system tools menu; set it to run offlineimap as often as you like.
Update 18 March 2010: I suppose I’ve not been able to get the “quick” mode of offlineimap to run nicely, so instead of calling offlineimap every few minutes, I call the following script every few minutes (ie set it to execute regularly using gnome-schedule):
#!/bin/bash curl -u MyName:MyNamePassword --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if /<name>/; print "$2\n" if /<(title|name)>(.*)<\/\1>/;' > /home/cpbl/tmp/newGmail touch /home/cpbl/tmp/newGmail touch /home/cpbl/tmp/oldGmail cmp -s /home/cpbl/tmp/oldGmail /home/cpbl/tmp/newGmail > /dev/null if [ $? -eq 1 ]; then offlineimap -u Noninteractive.Quiet else echo is not different fi cp /home/cpbl/tmp/newGmail /home/cpbl/tmp/oldGmail
That is, this does a quick check with Gmail to see whether anything is new, and only then does it call offlineimap.
Update 2012 / January: I’ve a newer post that describes an upgraded method for a very similar outcome: How-to: Alpine and maildir (and offlineimap (and GMail)) — no more maildir patches.