Two days ago I tried to send an email using my Gmail account via Apple Mail (IMAP) which included a quite large attachment (21 MBytes – I know, I know I shouldn’t use email for transferring such large files… anyway…). Not surprisingly, the operation failed (I assumed the Gmail SMTP server rejected such a big attachment) and so I ended up sending an email with a link to where the file could be downloaded (as I should have done in the first place).
So far, so good. However, two days later I started noticing that Apple Mail was failing to connect via IMAP to my Gmail account, asking for the Gmail account password at all times, and rejecting it also at all times (although I was able to login to the Gmail account without any problem via the browser).
So, it started to look like I was experiencing some more tricky problem, which after some googling brought me to the conclusion that I was Getting bit by the Gmail “exceeded IMAP bandwidth limits” bug.
In summary, it seems that for some reason Apple Mail, after failing to send the email with the big attachment keeps it around in the local machine in a Apple Mail folder named “Recovered Mail (Gmail Account Name)”, where a really high number of copies of the offending email are kept, probably because it kept trying to sync it with Gmail, and therefore largely exceeding the Gmail bandwidth for IMAP accesses, and locking the account for IMAP accesses.
So, here is the way to duplicate the problem (not that you want to do that, but just for diagnosing the problem and to understand how it may be caused) and a solution provided in the above weblink (and in one of the comments by “Nick”):
“(1) I sent an email with some attachments in Mail.app.
(2) A day or two later, my IMAP accounts for that Gmail address (the ones in Mail.app and on my iPhone) stopped working and reported the error: “Account exceeded bandwidth limits. (Failure)”
(3) In my Mail.app, there was a new mailbox called “Recovered Files” that contained hundreds of copies of the email that I had sent in step (1). This mailbox was taking up gigabytes of space on my computer. Even if I deleted the mail box, it would reappear and start re-populating with the same message once Mail.app was able to establish a connection to the Gmail IMAP servers.
Here is the solution to the problem:
(1) If you encounter the “Account exceeded bandwidth limits. (Failure)” error, then quit Mail.app and leave it closed (or just disable your Gmail IMAP account if you use Mail.app for other accounts as well) for 24 hours so that Google will reset your IMAP bandwidth limit. At this point, if you have Gmail set up with your iPhone or other IMAP clients, it should work there.
[BTW, it seems that there is a place to unlock your Gmail account: https://www.google.com/accounts/UnlockCaptcha ]
(2) Delete the hidden folder “.OfflineCache” at the following path: “~/Library/Mail/IMAPemail@example.com@imap.domain.tld/.OfflineCache”* (step-by-step instructions included at end of post in case you don’t know how to do this)
(3) Delete the “Recovered Files” Mailbox folder at “~/Library/Mail/Mailboxes/Recovered Messages ([Gmail Account Name]).mbox”
(4) Open Mail.app and try to connect to your Gmail account — it should now work.
This definitely worked for me — it seems like Mail.app somehow gets in a wacky state where it thinks it needs to download the same message hundreds of times, which causes the account to exceed its bandwidth limits. Deleting the cache seems to resolve these problems without causing any other adverse effects. Huge thanks to “engibeer” at http://www.google.com/support/forum/p/gmail/thread?tid=4395706bba19fb05 for coming up with the hard part of the solution!
* Step-by-step instructions for deleting the hidden folder:
(1) Open Terminal.app (located at Applications->Utilities->Terminal.app)
(2) Type in “cd ~/Library/Mail/IMAP-” (without quotes) and then press the tab key. It should auto-complete to something of the form “cd ~/Library/Mail/IMAPfirstname.lastname@example.org@imap.domain.tld”. If it auto-completes to something much shorter, you probably have multiple IMAP accounts in your Mail.app — press tab again to see a list of all the matches, type enough characters to disambiguate your Gmail account from the other ones, and then press tab to auto-complete. Once you have the full command, press return.
(3) Type in “rm -r .OfflineCache” and press return.”