Now on GitHub: gmail-biggestfiles
I generally tend to write short scripts for a one time task. Gmail-biggestfiles was born in that same vein. Then the other day, a colleague was commenting on how he wanted to find the biggest files in his GMail account and remove them, since he was running out of space.
Thus, I put this up on GitHub. He said it was "too slow", and so I refactored it to use imap_sort rather than imap_fetch_overview. This is why sharing code via GitHub is profoundly useful in my eyes, quick feedback and interations.
Hopefully someone finds it useful as well. It still can be a bit slow on large mail boxes, but it's offloading all of the sorting to the IMAP (Google) server now.
You can find the code on GitHub, feel free to fork it and make it faster if you feel the need.
Note: it's required that you have imap extensions installed alongside PHP, and IMAP access turned on in your GMail account