There's a basic problem combining Lion's Mail with GMail: if you need to keep the web interface working in a sensible manner and you use the server-side filtering and labels, then you're kind of screwed.

Either you go with the defaults Mail sets up and you lose access to everything that isn't in your inbox, or you remove the IMAP prefix setting and you get doubles of everything.

There is a way around it, but it's probably not a great idea for the non-tech people out there. You need to use offlineimap and an IMAP server on your local machine.

I use Homebrew for random open sauce applications. If you want to treat this post as a recipe, I suggest installing that. It's dead easy, just make sure you have Xcode installed, then run the one-liner they provide in their install instructions.

To install offlineimap, run (as yourself) "brew install offlineimap". I'm using Dovecot as my IMAP server, to install that run "brew install dovecot".

You next need to configure Dovecot. Go into /usr/local/etc, copy dovecot-example.conf to dovecot.conf. I changed "protocols" to "imap", "ssl" to "no", "login_user" to "_dovecot" (as this already exists), and "mail_location" to "milder:~/Maildir".

Then go into /etc/pam.d and copy "login" to "dovecot" so Dovecot can authenticate you.

Finally, do the last two steps (3 and 4) you get from "brew info dovecot" to set up and enable the IMAP service.

At this point I suggest configuring Mail to talk to your local server. Give it your GMail address and your local password, it should fail to connect to GMail (you do use different passwords, yes?), just keep on going through with it failing and it will eventually give you a dialog where you can set the username to your local username and the host to "localhost". It should then connect and find nothing.

You can confirm it connected by looking in ~/Maildir, you should now see the usual stuff you'd find in an empty maildir, e.g., "cur", "new", and "tmp" directories.

If you haven't got this much working, you need to debug it and figure out why not before going any further!

Now you want to get offlineimap to suck mail from GMail and stick it in your local IMAP folders. Drop something not entirely unlike this in ~/.offlineimaprc:

accounts = GMail
ui = Noninteractive.Quiet

[Account GMail]
localrepository = LocalImap
remoterepository = Remote
autorefresh = 10
quick = 5

[Repository LocalImap]
type = IMAP
remotehost = localhost
remoteuser = me
remotepass = password
maxconnections = 2
ssl = no

[Repository Remote]
type = IMAP
ssl = yes
remotehost =
remoteuser =
remotepass = gmailpassword
holdconnectionopen = yes
maxconections = 1

# pick one of the below:
# (for a single server)
nametrans = lambda foldername: re.sub('^INBOX', 'INBOX', foldername)
folderfilter = lambda foldername: not'(^\[Google Mail\])', foldername)

Then do a first run to sync it all and make sure everything's happy by running "offlineimap -u TTY.TTYUI". This may well take a very long time if you've got a fair bit of mail. That's okay, just let it run and you'll be fine.

Once it finishes syncing for the first time, follow the instructions Homebrew gave you when it finished installing offlineimap to create a launchd item. This will make sure offlineimap starts up every time you log in.

One small quirk I noticed is that offlineimap gets the timestamps on some of the maildir files wrong and Mail uses that rather than the header contents to get the received date. You can work around this after Mail does its first sync by quitting Mail, then deleting the files "Envelope Index*" in ~/Library/Mail/V2/MailData. Restart Mail, it'll think it has to import your mailbox, which just makes it reindex the cache, and then you're golden!


Abort, Rephrase, Ignore?

October 2011

2 345678


RSS Atom

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags