Python 2.7 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Python 2.7
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Python
2.7 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Python.
Stay organized with collections
Save and categorize content based on your preferences.
google.appengine.ext.webapp.mail_handlers module
Summary
Handler library for inbound Mail API.
Contains handlers to help with receiving mail and mail bounces.
- InboundMailHandler:
-
Provides a helper method for easily setting up email receivers.
- BounceNotificationHandler:
-
Provides a helper method for easily setting up a bounce notification
receiver. Will parse HTTP request to extract the bounce notification.
Contents
- class google.appengine.ext.webapp.mail_handlers.BounceNotification(post_vars)source
-
Bases: object
Encapsulates a bounce notification received by the application.
- class google.appengine.ext.webapp.mail_handlers.BounceNotificationHandlersource
-
Bases: google.appengine.ext.webapp._webapp25.RequestHandler
Base class for bounce notification handlers.
Example:
# Sub-class overrides receive method.
class BounceLogger(BounceNotificationHandler):
def receive(self, bounce_notification):
logging.info('Received bounce from ' %
bounce_notification.notification_from)
# Map bounce handler to application
application = webapp.WSGIApplication([
BounceLogger.mapping(),
])
- classmethod mapping()source
Convenience method to map handler class to application.
ReturnsMapping from bounce URL to bounce notification handler class.
- post()source
-
Transforms POST body to bounce request.
- receive(bounce_notification)source
- class google.appengine.ext.webapp.mail_handlers.InboundMailHandlersource
-
Bases: google.appengine.ext.webapp._webapp25.RequestHandler
Base class for inbound mail handlers.
Example:
# Sub-class overrides receive method.
class HelloReceiver(InboundMailHandler):
def receive(self, mail_message):
logging.info('Received greeting from %s: %s' % (mail_message.sender,
mail_message.body))
# Map mail handler to appliction.
application = webapp.WSGIApplication([
HelloReceiver.mapping(),
])
- classmethod mapping()source
Convenience method to map handler class to application.
ReturnsMapping from email URL to inbound mail handler class.
- post()source
-
Transforms body to email request.
- receive(mail_message)source
Receive an email message.
Override this method to implement an email receiver.
Parametersmail_message – InboundEmailMessage instance representing received
email.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThis module provides handler classes, \u003ccode\u003eInboundMailHandler\u003c/code\u003e and \u003ccode\u003eBounceNotificationHandler\u003c/code\u003e, to facilitate the receiving of emails and bounce notifications in the Google App Engine environment.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eInboundMailHandler\u003c/code\u003e serves as a base class for creating custom email receivers, and by overriding the \u003ccode\u003ereceive\u003c/code\u003e method, developers can define actions for incoming emails.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBounceNotificationHandler\u003c/code\u003e is designed for handling bounce notifications, parsing HTTP requests to extract relevant details, also using a \u003ccode\u003ereceive\u003c/code\u003e method to implement the specific logic needed.\u003c/p\u003e\n"],["\u003cp\u003eBoth handler classes provide a \u003ccode\u003emapping()\u003c/code\u003e method, which is a convenient way to map handler classes to the application.\u003c/p\u003e\n"]]],[],null,["# google.appengine.ext.webapp.mail_handlers module\n================================================\n\nSummary\n-------\n\nHandler library for inbound Mail API.\n\nContains handlers to help with receiving mail and mail bounces.\n\nInboundMailHandler:\n\n: Provides a helper method for easily setting up email receivers.\n\nBounceNotificationHandler:\n\n: Provides a helper method for easily setting up a bounce notification\n receiver. Will parse HTTP request to extract the bounce notification.\n\nContents\n--------\n\n*class* google.appengine.ext.webapp.mail_handlers.BounceNotification(post_vars)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#BounceNotification)\n\n: Bases: object\n\n Encapsulates a bounce notification received by the application. \n\n notification\n : \n\n original\n : \n\n original_raw_message\n: \n\n*class* google.appengine.ext.webapp.mail_handlers.BounceNotificationHandler[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#BounceNotificationHandler)\n\n: Bases: google.appengine.ext.webapp._webapp25.RequestHandler\n\n Base class for bounce notification handlers.\n\n Example: \n\n # Sub-class overrides receive method.\n class BounceLogger(BounceNotificationHandler):\n\n def receive(self, bounce_notification):\n logging.info('Received bounce from ' %\n bounce_notification.notification_from)\n\n\n # Map bounce handler to application\n application = webapp.WSGIApplication([\n BounceLogger.mapping(),\n ])\n\n *classmethod* mapping()[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#BounceNotificationHandler.mapping)\n\n : Convenience method to map handler class to application.\n\n Returns\n\n Mapping from bounce URL to bounce notification handler class. \n\n post()[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#BounceNotificationHandler.post)\n\n : Transforms POST body to bounce request.\n\n receive(bounce_notification)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#BounceNotificationHandler.receive)\n: \n\n*class* google.appengine.ext.webapp.mail_handlers.InboundMailHandler[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#InboundMailHandler)\n\n: Bases: google.appengine.ext.webapp._webapp25.RequestHandler\n\n Base class for inbound mail handlers.\n\n Example: \n\n # Sub-class overrides receive method.\n class HelloReceiver(InboundMailHandler):\n\n def receive(self, mail_message):\n logging.info('Received greeting from %s: %s' % (mail_message.sender,\n mail_message.body))\n\n\n # Map mail handler to appliction.\n application = webapp.WSGIApplication([\n HelloReceiver.mapping(),\n ])\n\n *classmethod* mapping()[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#InboundMailHandler.mapping)\n\n : Convenience method to map handler class to application.\n\n Returns\n\n Mapping from email URL to inbound mail handler class. \n\n post()[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#InboundMailHandler.post)\n\n : Transforms body to email request.\n\n receive(mail_message)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/ext/webapp/mail_handlers#InboundMailHandler.receive)\n\n : Receive an email message.\n\n Override this method to implement an email receiver.\n Parameters\n\n mail_message -- InboundEmailMessage instance representing received\n email."]]