Silently broken Gmail

At work, we have google apps, which comes with several gigs of gmail storage. For email, though, we use outlook server with a low quota. Rather than deleting email, I “archive” to gmail via IMAP.

One day, though, gmail IMAP silently stopped syncing. I could login, but no mail was being transfered. I tried everything — synchronizing accounts, rebuilding the mailbox, but nothing worked. I was hoping to enable some more verbose logging, when I came across an old article from eriklabs.com about Mail.app Logging.

After learning the magic incantation, I started up Mail.app to log all operations on port 993 (the SSL port that gmail IMAP uses).  A message in the logs immediately stood out:

5.1 BAD [ALERT] Message too large. http://mail.google.com/support/bin/answer.py?answer=8770

The prior message logged the timestamp of the offending email, which was over 25MB in size (the max size for Gmail).  Unfortunately, Mail.app had created a large number of copies of this email (over 1,000) and placed them in the “Recovered Items” folder.

Even after deleting all of these “recovered item” copies, Mail kept making new one.  I tracked down a copy of this file in the .OfflineBackups directory. After removing the file that gmail rejects (see http://automatica.com.au/2010/01/mail-app-and-its-offline-cache/ — I chose the file with the large file size in that directory), I was finally able to resync with gmail!

Unfortunately, mail.app was not happy that I removed a file from .OfflineBackups, and it refused to process the rest of the files in that directory.  I wrote the following python script to convert the unprocessed files in .OfflineBackups into a single .mbox file suitable for import into Mail.app.

Thankfully, in the end, everything is back to normal.

This entry was posted in Apple, Programming. Bookmark the permalink.

One Response to Silently broken Gmail

  1. Joel says:

    Wow. I have searched long and hard regarding this exact same error message. You are the first to correctly diagnose it and fix it. Believe me, there are many others struggling through this issue.

    My problem is that I’m not sufficiently versed in coding to attempt this fix. Is it possible there is a simpler method? Or, conversely, would you be willing to write out the instructions like you were talking to a 3rd grader? :)

    My MBP is updated in all regards, OS and Mail App included.

Leave a Reply