Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Receiving Bounce Notification

In order to receive email bounce notifications, you need to configure your app to enable email notification and you need to create a handler to handle those notifications.

Configuring Your App to Receive Bounce Notifications

There are two parts to the configuration. First, you need to enable notification. Second, you need to set the mapping between /_ah/bounce and your bounce handler, so App Engine knows where to POST the notification data. To configure your app to receive bounced email notifications:

  1. Add the following to your app.yaml file to enable notification:
    inbound_services:
    - mail_bounce
  2. Also in app.yaml , declare a mapping between /_ah/bounce and the bounce notification handler in your code, for example:
    - url: /_ah/bounce
      script: handle_bounced_email.app
      login: admin

Handling Bounce Notifications

In your app, you'll need to supply bounce handler code to receive and process the notifications.

One way to write a bounce handler is to use the BounceNotificationHandler convenience class. If you go this route, you'll need to override its receive() method, which is called with an argument of the BounceNotification class. Whether you use the BounceNotificationHandler convenience class or not, you do need to use BounceNotification to parse the bounce notifications.

Both BounceNotificationHandler and BounceNotification are in the google.appengine.ext.webapp.mail_handlers package.

Here is a sample bounce handler that uses the BounceNotificationHandler convenience class:

import logging
import webapp
from google.appengine.ext.webapp.mail_handlers import BounceNotification
from google.appengine.ext.webapp.mail_handlers import BounceNotificationHandler

class LogBounceHandler(BounceNotificationHandler):
  def receive(self, bounce_message):
    logging.info('Received bounce post ... [%s]', str(self.request))
    logging.info('Bounce original: %s' + str(bounce_message.original))
    logging.info('Bounce notification: %s' + str(bounce_message.notification))

Here is a sample bounce handler that does not use BounceNotificationHandler :

class BounceHandler(webapp.RequestHandler):
  def post(self):
    bounce = BounceNotification(self.request.POST)
    logging.info('Bounce original: %s' + str(bounce.original))
    logging.info('Bounce notification: %s' + str(bounce.notification))

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.