From 19c05fffcb1860b2dcf17989b40ca16ed259fdea Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 6 Jan 2018 18:35:36 +0100 Subject: dashboard/app: receive and log email bounces --- dashboard/app/app.yaml | 3 ++- dashboard/app/reporting_email.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dashboard/app/app.yaml b/dashboard/app/app.yaml index 7b7715de6..13885ef37 100644 --- a/dashboard/app/app.yaml +++ b/dashboard/app/app.yaml @@ -5,6 +5,7 @@ api_version: go1 inbound_services: - mail +- mail_bounce handlers: - url: /favicon.ico @@ -25,6 +26,6 @@ handlers: script: _go_app login: admin secure: always -- url: /_ah/mail/.+ +- url: /_ah/(mail/.+|bounce) script: _go_app login: admin diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go index 62cef1f2e..fddd14298 100644 --- a/dashboard/app/reporting_email.go +++ b/dashboard/app/reporting_email.go @@ -7,6 +7,7 @@ import ( "bytes" "encoding/json" "fmt" + "io/ioutil" "net/http" "net/mail" "strings" @@ -25,6 +26,7 @@ import ( func init() { http.HandleFunc("/email_poll", handleEmailPoll) http.HandleFunc("/_ah/mail/", handleIncomingMail) + http.HandleFunc("/_ah/bounce", handleEmailBounce) mailingLists = make(map[string]bool) for _, cfg := range config.Namespaces { @@ -333,6 +335,17 @@ func incomingMail(c context.Context, r *http.Request) error { return nil } +func handleEmailBounce(w http.ResponseWriter, r *http.Request) { + c := appengine.NewContext(r) + log.Errorf(c, "email bounced") + body, err := ioutil.ReadAll(r.Body) + if err != nil { + log.Errorf(c, "failed to read body: %v", err) + return + } + log.Infof(c, "%s", body) +} + func loadBugInfo(c context.Context, msg *email.Email) (bug *Bug, bugReporting *BugReporting, reporting *Reporting) { if msg.BugID == "" { if msg.Command == "" { -- cgit mrf-deployment