Storing Gmail labels

chris coleman christocoleman at
Tue Oct 2 23:44:41 BST 2012

On Tue, Oct 2, 2012 at 12:49 PM, chris coleman wrote:
> On Tue, Oct 2, 2012 at 2:33 AM, Eygene Ryabinkin <rea-fbsd at>
> wrote:
>> Tue, Oct 02, 2012 at 10:53:11AM +0200, Rainer M Krug wrote:
>>> Hash: SHA1
>>> On 02/10/12 10:34, Eygene Ryabinkin wrote:
>>> > Mon, Oct 01, 2012 at 09:44:46PM -0700, Zain Memon wrote:
>>> >> Can I get OfflineIMAP to fetch and store my Gmail labels without
>>> >> having multiple copies of
>>> >> the same message?
>>> >
>>> > If I am not terribly mistaken, current implementation of GMail
>>> > folder storage does not allow for this.
>>> Well - you could use the
>>> api
>>> (particularly
>>> to get the tags for downloaded messages, if I am not completely
>>> mistaken.
>> I meant the implementation of GMail support in OfflineIMAP.  Sorry
>> for not being clear.
>> --
>> Eygene Ryabinkin                                        ,,,^..^,,,
>> [ Life's unfair - but root password helps!          | ]
>> [ 82FE 06BC D497 C0DE 49EC  4FF0 16AF 9EAE 8152 ECFB | ]
> I'm considering creating a patch for storing Gmail labels for
> type=Gmail. For the Maildir format, where could I store the label data
> for each message? I'm not super familiar with the Maildir format but
> it seems to me that labels should be handled similarly to flags, but I
> don't think it's a good idea to store labels in the filename of each
> message. Does the Maildir format allow for mutable data to be stored
> in the file itself?
> Hi Zain,
> You should get the extra info from gmail, and then store it in headers
> inside the message.
> The headers are: X-GM-MSGID, X-GM-THRID, X-GM-LABELS, in addition to
> existing XLIST.
> The user will need to use a mailreader (Thunderbird is one) that has an
> extension available to support those gmail specific message headers IN THE
> MESSAGE not on the gmail server.
> There is some more detail / code here, but note, it's code that talks to
> gmail's servers to ask for the extra info "live", not code that reads to
> extra info from the message headers...:
> Chris

The reason I was hesitant to store X-GM-LABELS as a header in the
message is because it is mutable, similar to the flags. I could change
labels for a message on the server and I would expect OfflineIMAP to
sync that to my local copy; but it's my understanding that Maildir file
contents are supposed to be immutable.

Hi Zain,

If the Maildir file contents are supposed to be immutable, then you have to decide how you're going to handle these gmail extensions to the imap protocol.

One way - write a plugin/extension to your mailreader (Thunderbird is an easy example) to query gmail "live" for those labels, thread ids, msg ids, and xlist, and make the messages display differently by taking that info into account.

Second way - copy those labels down so they're stored in a static form on the local maildir - possibly in a sqlite database for fast read/updates - PLUS a plugin for the mailreader to let the user view/modify those extended gmail tags - and re-upload it back to gmail servers during offlineimap's sync procedure...  This allows for true disconncted offline use..

Third way - write an extension for one of the popular mailservers (dovecot, cyrus, etc) to implement these gmail extended imap features - and just replicate between gmail's imap server and your local imap server.  Obviously this skips using the Maildir and just talks imap protocol between gmail's imap server and your local server... A bit heavier in terms of memory and cpu requirements but probably the cleanest solution with the least amount of coding needed on the OfflineImap side.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the OfflineIMAP-project mailing list