m.login('example@gmail.com', 'testPassword')
m.select()
typ, data = m.search(None, 'ALL')
typ, data = m.search(None, '(SMALLER %d) (LARGER %d)' % (MAXSIZE * 1000, 
    MINSIZE * 1000))
for num in data[0].split():
    typ, data = m.fetch(num, '(RFC822)')
print('Message %s\n%s\n' % (num, len(data[0][1])))
m.close()
m.logout()
How to delete the biggest emails from my gmail using a python script?