Skip to content
ludoch edited this page Apr 15, 2026 · 1 revision

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 incoming notifications.

Configuring your application for email bounce notification

By default, applications do not receive bounce notifications for email that could not be delivered. To enable the incoming bounce notification service, you must modify your application appengine-web.xml and web.xml configuration files.

Modify appengine-web.xmlby adding an inbound-services section to enable the incoming bounce service:

View appengine-web.xml on GitHub (region: handle_incoming_mail)

Modify web.xml by mapping the bounce URL /_ah/bounce to your bounce handling servlet, as follows:

View web.xml on GitHub (region: bounced_mail_servlet)

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:

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

Handling bounce notifications

The JavaMail API includes the BounceNotificationParser class, which you use to parse incoming bounce notifications, as shown here:

View BounceHandlerServlet.java on GitHub (region: bounce_handler_servlet)

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

The bounce notification will be sent to your app as a POST request to /_ah/bounce. Information about the bounce will be form-encoded in the body of the request.

A bounce notification is an automated message from an email system that there's been a problem with message delivery. In your app, you'll need to create bounce handler code to receive and process these notifications.

To see examples of how to handle bounce notifications with PHP, download the code samples.

Learn more about the migration considerations for the Mail API in the Accessing legacy bundled services for PHP guide.

A bounce notification is an automated message from an email system that there's been a problem with message delivery. In your app, you'll need to create bounce handler code to receive and process these 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.

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

Learn more about the migration considerations for Mail API in the Mail handlers guide.

Clone this wiki locally