title: How to detect attachment file size for inbound message?
body: <p>How could I check the size of attached file prior to processing it?
  I would like to receive messages with attached files in jpg or png format only less than 1 Mb.</p>
  
  <p>The processing is manual:</p>
  
  <pre><code>class EmailHandler(webapp2.RequestHandler):
      def post(self):
          msg = email.message_from_string(self.request.body) # http://docs.python.org/2/library/email.parser.html
          for part in msg.walk():
              if part.get_content_type() == 'application/octet-stream':
                  # part.get_payload() 
  </code></pre>
  
  <p>I can not understand if receiving of big files utilizes some limits (<a href="https://developers.google.com/appengine/docs/python/mail/#Python_Quotas_and_limits" rel="nofollow">Mail Quota details</a>). If so, then I would like to reject mails with big files in such a way that quota is not decreased, if possible. Secondly, I would like to handle properly over quota limits (>10 Mb) and reply back to the user that attachment is too big. </p>