Skip to content
relix edited this page Apr 13, 2011 · 2 revisions

Installing GmailCC

Tutorial

Requirements

  • A Gmail or Google Apps account (with IMAP enabled)
  • boost-filesystem and boost-program-options (tested with 1.35 and 1.39)
  • libc-client2007b
  • An internetconnection

Make sure you enable IMAP support in your Gmail account: go to Settings, select “Forwarding and POP/IMAP”, enable “Enable IMAP”.

Build it

Make sure you’ve got the required packages installed (this is for a debian-type system):

$ sudo apt-get install git-core build-essential libc-client2007b libc-client2007b-dev libboost-filesystem1.35.0 libboost-filesystem1.35-dev libboost-program-options1.35.0 libboost-program-options1.35-dev

Clone the git repo on github:

$ git clone git://github.com/relix/gmailcc.git

Move to the directory “bin” and start make:

$ cd gmailcc/bin && make

Run it:

./gmailcc -?

To see available commands.

./gmailcc -u username -p password -d /tmp/Maildir

If you want to see debug messages and so on, change the loglevel:

./gmailcc -u username -p password -d /tmp/Maildir --loglevel 0

If a file named “database” is found in your Maildir, then Gmailcc finished without any errors.

Config files

You can also use config-files instead of passing all parameters through the command-line. You can pass a config-file using the —config parameter, or you can just place a configfile at ~/.gmailcc.conf or /etc/gmailcc.conf (they are checked in that order, whichever is detected first is used).

An example:


#
  1. Configfile for Gmail Carbon Copy
    #
    maildir = ~/.maildir
    username = bratt
    password = br5tt4ev5h

Fedora/Red Hat

For a red hat/fedora system the c-client packages are called “libc-client.i586” and “libc-client-devel”. Since these files are saved in differint places than in Debian, you’ll have to manually change the #include in the source code from “c-client/c-client.h” to “imap/c-client.h”.

How it works

Gmailcc uses the IMAP server service feature of Gmail to download the mails and labels. The first time around it downloads all the mails from the mailbox [Gmail]/All Mails, including headers and body. This special mailbox contains every mail in your account, excluding those in Trash and Spam. These are saved in the corresponding Maildir subfolder.

Next gmailcc checks every other mailbox made available by Gmail, with each mailbox corresponding to a Label in Gmail. For every mail in a mailbox, gmailcc downloads only the headers. Using the unique message-id of every mail, gmailcc finds the matching mail inside [Gmail]/All mails. It then creates a link inside the mailbox’ subfolder to the source-file inside [Gmail]/All mails.

After gmailcc is done, the [Gmail]/All mails folder contains a file for every mail in your account, while all other subfolders contain a link to the corresponding file inside [Gmail]/All mails, saving space.

On the next run, gmailcc only downloads new mails, and checks for deleted mails and changes in the status of mails (e.g. the “read” status).

FAQ

Q: I’m getting all kinds of c-client warnings, like:

  • Junk in start of group: …
  • End of group encountered when not in group

A: While we’re not exactly sure yet what they mean, they’re absolutely harmless and do not affect the process of backing up your mails. We think some mails have a header that includes a line which is not kosher according to the MIME standard, so our IMAP client’s MIME parsers gets a hiccup whenever it encounters one.