Gmail and mutt
I like mutt. Of all the mail clients I've used over the years, it
sucks the least. It works well with my mail server.
Despite having my own domain and mail server, I still use gmail for
certain things; things I don't mind being retained for 3 years after I
delete them, or more specifically, things I want retained for 3 years
after I delete them.
I don't like the gmail web interface. I find checking my gmail to be
annoying because of this. I remembered gmail offering POP and IMAP.
I figured I could use that to get my gmail. Shouldn't be too hard right?
A quick search of Mr. Yahoo and Mr. Google gave me two good starting
points: Lifehacker.com
and MattCutts.com.
I read the sites and the getmail man page and figured out what I needed
to do. First I enabled IMAP for my gmail account. Next, I created the
.getmail directory in my home directory then created a getmailrc file
there. I want all gmail mail to be delivered to a specific mbox file
without going through my normal mail delivery channels. The contents of
the getmailrc file are quite simple:
[retriever]
type = SimpleIMAPSSLRetriever
server = imap.gmail.com
username = username@gmail.com
password = usernamespasswordgoeshere
mailboxes = ("inbox",)
[destination]
type = Mboxrd
path = /usr/home/mforde/Mail/GMAIL
The retriever section defines how getmail will retrieve the mail. In
this case it uses IMAP over SSL to connect to imap.gmail.com. The
mailboxes setting can be used to specify only certain gmail labels to
retrieve, but I want anything in the inbox.
The destination section tells getmail what to do with the mail once it
has grabbed it from gmail. This configuration dumps it into an mbox file
I've named GMAIL.
I chose IMAP over POP because of the slightly-less-than-documented
"feature" of gmail only allowing 99 messages at a time over POP.
So to get the initial batch of 7000+ emails, I ran
> getmail -vvv -l
to get verbose output and to leave messages on the gmail server. When
that was done I pointed mutt at the GMAIL mbox and like magic, there was
my gmail, organized nicely in my terminal.
Now, I want to check to get the latest mail fairly often, and I don't
want to download messages already copied over. To accomplish this, I
added a crontab to run every 10 minutes and invoke
getmail -l -n -q
This tells getmail to leave copies on the server, only get new messages
it hasn't already retrieved, and be quiet about it.
This has worked out well for me. If you're interested in setting up
something like this, I highly recommend reading the article at
matcutts.com.
That article also links to several sample getmailrc files.
[/unix]
[permanent link]