Recevoir une notification de non-distribution
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Afin de recevoir des notifications de non-distribution d'e-mails, vous devez configurer l'application pour activer les notifications de non-distribution et gérer les notifications entrantes dans l'application.
Configurer l'application pour les notifications de non-distribution d'e-mails
Par défaut, les applications ne reçoivent pas de notifications de non-distribution pour les e-mails qui n'ont pas pu être distribués. Pour activer le service de notification de non-distribution entrante, vous devez modifier les fichiers de configuration appengine-web.xml
et web.xml
de l'application.
Modifiez appengine-web.xml
en ajoutant une section inbound-services
pour activer le service de non-distribution entrante :
Modifiez web.xml
en mappant l'URL de non-distribution /_ah/bounce
à votre servlet de gestion de non-distribution, comme suit :
Gérer les notifications de non-distribution
L'API JavaMail inclut la classe BounceNotificationParser, utilisée pour analyser les notifications de non-distribution entrantes, comme indiqué ci-dessous :
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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 }"]]