func alertAdmins(c context.Context, key *datastore.Key, entity Lockable, reason string) error { sender := "locker@" + appengine.AppID(c) + ".appspot.com" msg := &mail.Message{ Sender: sender, Subject: reason, Body: fmt.Sprintf("key: %s, entity: %#v", key.String(), entity), } return mail.SendToAdmins(c, msg) }
func emailHandler(w http.ResponseWriter, r *http.Request) { ctx := appengine.NewContext(r) keys, err := datastore.NewQuery("Submission").KeysOnly().GetAll(ctx, nil) if err != nil { serveErr(ctx, err, w) return } if len(keys) == 0 { return } msg := mail.Message{ Subject: "GopherPods", Sender: os.Getenv("EMAIL"), Body: fmt.Sprintf("There are %d submissions", len(keys)), } if err := mail.SendToAdmins(ctx, &msg); err != nil { serveErr(ctx, err, w) return } }