Java 8 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Java 8
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Java
8 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Java.
Receiving Bounce Notification
Stay organized with collections
Save and categorize content based on your preferences.
To receive email bounce notifications, you need to configure your app to
enable bounce notification and you need to handle the incoming notification in
your app.
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.xml
by adding an inbound-services
section to enable the
incoming bounce service:
Modify web.xml
by mapping the bounce URL /_ah/bounce
to your bounce
handling servlet, as follows:
Handling Bounce Notifications
The JavaMail API includes the
BounceNotificationParser class,
which you use to parse incoming bounce notifications, as shown here:
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-09-04 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-09-04 UTC."],[[["\u003cp\u003eTo enable email bounce notifications, you must configure your application to receive them and handle them within your app.\u003c/p\u003e\n"],["\u003cp\u003eEnable the incoming bounce notification service by adding the \u003ccode\u003email_bounce\u003c/code\u003e service within the \u003ccode\u003einbound-services\u003c/code\u003e section of your \u003ccode\u003eappengine-web.xml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eMap the bounce URL \u003ccode\u003e/_ah/bounce\u003c/code\u003e to your bounce handling servlet within your \u003ccode\u003eweb.xml\u003c/code\u003e file to direct bounce notifications appropriately.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003eBounceNotificationParser\u003c/code\u003e class from the JavaMail API to parse incoming bounce notifications in your application.\u003c/p\u003e\n"]]],[],null,["# Receiving Bounce Notification\n\nTo receive email bounce notifications, you need to configure your app to\nenable bounce notification and you need to handle the incoming notification in\nyour app.\n\n\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| java-gen2\n|\n| /services/access). If you are updating to the App Engine Java 11/17 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/java-differences) to learn about your migration options for legacy bundled services.\n\n\u003cbr /\u003e\n\nConfiguring your application for email bounce notification\n----------------------------------------------------------\n\nBy default, applications do not receive bounce notifications for email that\ncould not be delivered. To enable the incoming bounce notification service, you\nmust modify your application `appengine-web.xml` and `web.xml` configuration\nfiles.\n\nModify `appengine-web.xml`by adding an `inbound-services` section to enable the\nincoming bounce service: \n\n \u003cinbound-services\u003e\n \u003c!-- Used to handle incoming mail. --\u003e\n \u003cservice\u003email\u003c/service\u003e\n \u003c!-- Used to handle bounced mail notifications. --\u003e\n \u003cservice\u003email_bounce\u003c/service\u003e\n \u003c/inbound-services\u003e\n\nModify `web.xml` by mapping the bounce URL `/_ah/bounce` to your bounce\nhandling servlet, as follows: \n\n \u003cservlet\u003e\n \u003cservlet-name\u003ebouncehandler\u003c/servlet-name\u003e\n \u003cservlet-class\u003ecom.example.appengine.mail.BounceHandlerServlet\u003c/servlet-class\u003e\n \u003c/servlet\u003e\n \u003cservlet-mapping\u003e\n \u003cservlet-name\u003ebouncehandler\u003c/servlet-name\u003e\n \u003curl-pattern\u003e/_ah/bounce\u003c/url-pattern\u003e\n \u003c/servlet-mapping\u003e\n \u003csecurity-constraint\u003e\n \u003cweb-resource-collection\u003e\n \u003cweb-resource-name\u003ebounce\u003c/web-resource-name\u003e\n \u003curl-pattern\u003e/_ah/bounce\u003c/url-pattern\u003e\n \u003c/web-resource-collection\u003e\n \u003cauth-constraint\u003e\n \u003crole-name\u003eadmin\u003c/role-name\u003e\n \u003c/auth-constraint\u003e\n \u003c/security-constraint\u003e\n\nHandling Bounce Notifications\n-----------------------------\n\nThe JavaMail API includes the\n[BounceNotificationParser class](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/mail/BounceNotificationParser),\nwhich you use to parse incoming bounce notifications, as shown here: \n\n import com.google.appengine.api.mail.https://cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.mail.BounceNotification.html;\n import com.google.appengine.api.mail.https://cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.mail.ee10.BounceNotificationParser.html;\n\n import java.io.IOException;\n import java.util.logging.Logger;\n import javax.mail.MessagingException;\n import javax.servlet.http.HttpServlet;\n import javax.servlet.http.HttpServletRequest;\n import javax.servlet.http.HttpServletResponse;\n\n public class BounceHandlerServlet extends HttpServlet {\n\n private static final Logger log = Logger.getLogger(BounceHandlerServlet.class.getName());\n\n @Override\n public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {\n try {\n https://cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.mail.BounceNotification.html bounce = https://cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.mail.ee10.BounceNotificationParser.html.parse(req);\n log.warning(\"Bounced email notification.\");\n // The following data is available in a BounceNotification object\n // bounce.getOriginal().getFrom() \n // bounce.getOriginal().getTo() \n // bounce.getOriginal().getSubject() \n // bounce.getOriginal().getText() \n // bounce.getNotification().getFrom() \n // bounce.getNotification().getTo() \n // bounce.getNotification().getSubject() \n // bounce.getNotification().getText() \n // ...\n } catch (MessagingException e) {\n // ...\n }\n }\n }"]]