Enter getmail. (No, not the Windows app of the same name.) It even has an amusing and long FAQ about why you shouldn't use fetchmail, which begins:
Short answer: … well, the short answer is mostly unprintable. The long answer is … well, long: [...]
Anyway, here's the recipe.
apt-get install getmail4
mkdir ~/.getmail
- Edit ~/.getmail/getmailrc, and put in something like:
[retriever] type = SimplePOP3SSLRetriever server = pop.gmail.com username = gmail username [destination] # this can be changed to Maildir, etc. RTFM. type = Mboxrd path = ~/.getmail/inbox [options] # this makes it pick up where it left off # instead of downloading everything each time. read_all = False
touch ~/.getmail/inbox
- run
getmail
. It'll prompt you for a password.
Three bits of weirdness to be aware of:
- gmail tracks the last date you've downloaded from so subsequent getmails will get different counts of messages. If you want to start over, go to Settings→Forwarding and Pop there's a "Status" option which lets you reset the date.
- It appears to only download a subset of your messages at a time. So reset the POP date once, then run
getmail
a few times. getmail
seems to eat a lot of CPU for reasons that are not apparent to me.strace
indicates it'sstat
ing the same Python modules over and over... ah, software.