Receber notificações de rejeição
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Para receber notificações de rejeição de e-mail, configure o aplicativo para ativá-las e processe a notificação de entrada
nele.
Como configurar seu aplicativo para notificação de rejeição de e-mail
Por padrão, os aplicativos não recebem notificações de rejeição de e-mail que
não pôde ser entregue. Para ativar o serviço de notificação de rejeição de entrada, modifique
os arquivos de configuração appengine-web.xml
e web.xml
do
aplicativo.
Modifique appengine-web.xml
adicionando uma seção inbound-services
para ativar o serviço de rejeição de entrada:
Modifique web.xml
mapeando o URL de rejeição /_ah/bounce
para seu servlet de processamento de rejeição da seguinte maneira:
Como processar notificações de rejeição
A API JavaMail inclui a classe BounceNotificationParser para analisar as notificações de rejeição de entrada, como mostrado aqui:
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-09-04 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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 }"]]