'Writes a new message, with the specified uid.
See folder/Base for detail. Note that savemessage() does not
check against dryrun settings, so you need to ensure that
savemessage is never called in a dryrun mode.'

def savemessage(self, uid, content, flags, rtime):

    if (not self.synclabels):
        return super(GmailMaildirFolder, self).savemessage(uid, content, flags, rtime)
    labels = set()
    for hstr in self.getmessageheaderlist(content, self.labelsheader):
        labels.update(imaputil.labels_from_header(self.labelsheader, hstr))
    ret = super(GmailMaildirFolder, self).savemessage(uid, content, flags, rtime)
    filename = self.messagelist[uid]['filename']
    filepath = os.path.join(self.getfullname(), filename)
    self.messagelist[uid]['mtime'] = int(os.stat(filepath).st_mtime)
    self.messagelist[uid]['labels'] = labels
    return ret
