当前位置: 首页>>代码示例>>Golang>>正文


Golang mail.Send函数代码示例

本文整理汇总了Golang中google/golang.org/appengine/mail.Send函数的典型用法代码示例。如果您正苦于以下问题:Golang Send函数的具体用法?Golang Send怎么用?Golang Send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Send函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SendAlerts

func SendAlerts(ctx context.Context, stocksForAlert []PortfolioStock) {
	if len(stocksForAlert) == 0 {
		log.Debugf(ctx, "SendAlerts: Alert stocks are empty")
		return
	}
	//group by user emails to send a consolidated email
	groupedStockAlerts := make(map[string][]PortfolioStock)
	for _, alert := range stocksForAlert {
		userPortfolioStocks := groupedStockAlerts[alert.Email]
		userPortfolioStocks = append(userPortfolioStocks, alert)
		groupedStockAlerts[alert.Email] = userPortfolioStocks
	}
	log.Debugf(ctx, "Will send alerts for ", Jsonify(groupedStockAlerts))
	for email, alerts := range groupedStockAlerts {
		msg := &mail.Message{
			Sender:  "NewTechFellas Stock Alerts <[email protected]>",
			To:      []string{email},
			Subject: "Newtechfellas stock alerts for your stocks - " + DateString(),
			Body:    getStocksAlertMailBody(alerts),
		}
		if err := mail.Send(ctx, msg); err != nil {
			log.Debugf(ctx, "Couldn't send email: %v", err)
		}
	}

	for _, portfolioStock := range stocksForAlert {
		portfolioStock.AlertSentTime = time.Now()
		//Save stocksForAlert to update last alert sent time
		CreateOrUpdate(ctx, &portfolioStock, portfolioStock.kind(), portfolioStock.stringId(), 0)
	}
}
开发者ID:newtechfellas,项目名称:StockAlerts,代码行数:31,代码来源:scheduler.go

示例2: emailMentions

func emailMentions(ctx context.Context, tweet *Tweet) {
	u := user.Current(ctx)
	var words []string
	words = strings.Fields(tweet.Message)
	for _, value := range words {
		if strings.HasPrefix(value, "@") {
			username := value[1:]
			profile, err := getProfileByUsername(ctx, username)
			if err != nil {
				// they don't have a profile, so skip it
				continue
			}
			msg := &mail.Message{
				Sender:  u.Email,
				To:      []string{profile.Username + " <" + profile.Email + ">"},
				Subject: "You were mentioned in a tweet",
				Body:    tweet.Message + " from " + tweet.Username + " - " + humanize.Time(tweet.Time),
			}
			if err := mail.Send(ctx, msg); err != nil {
				log.Errorf(ctx, "Alas, my user, the email failed to sendeth: %v", err)
				continue
			}

		}
	}
}
开发者ID:RamzesSoft,项目名称:GolangTraining,代码行数:26,代码来源:routes.go

示例3: emailSend

func emailSend(w http.ResponseWriter, r *http.Request, m map[string]string) {

	c := appengine.NewContext(r)
	//addr := r.FormValue("email")

	if _, ok := m["subject"]; !ok {
		m["subject"] = "empty subject line"
	}

	email_thread_id := []string{"3223"}

	msg := &ae_mail.Message{
		//Sender:  "Peter Buchmann <[email protected]",
		//		Sender: "[email protected]",
		Sender: "[email protected]",
		//To:	   []string{addr},
		To: []string{"[email protected]"},

		Subject: m["subject"],
		Body:    "some_body some_body2",
		Headers: go_mail.Header{"References": email_thread_id},
	}
	err := ae_mail.Send(c, msg)
	loghttp.E(w, r, err, false, "could not send the email")

}
开发者ID:aarzilli,项目名称:tools,代码行数:26,代码来源:email_receive.go

示例4: handleOOBAction

func handleOOBAction(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	resp, err := gitkitClient.GenerateOOBCode(c, r)
	if err != nil {
		aelog.Errorf(c, "Failed to get an OOB code: %s", err)
		w.Write([]byte(gitkit.ErrorResponse(err)))
		return
	}
	msg := &mail.Message{
		Sender: "FavWeekday Support <[email protected]>",
	}
	switch resp.Action {
	case gitkit.OOBActionResetPassword:
		msg.Subject = "Reset your FavWeekday account password"
		msg.HTMLBody = fmt.Sprintf(emailTemplateResetPassword, resp.Email, resp.OOBCodeURL.String())
		msg.To = []string{resp.Email}
	case gitkit.OOBActionChangeEmail:
		msg.Subject = "FavWeekday account email address change confirmation"
		msg.HTMLBody = fmt.Sprintf(emailTemplateChangeEmail, resp.Email, resp.NewEmail, resp.OOBCodeURL.String())
		msg.To = []string{resp.NewEmail}
	case gitkit.OOBActionVerifyEmail:
		msg.Subject = "FavWeekday account registration confirmation"
		msg.HTMLBody = fmt.Sprintf(emailTemplateVerifyEmail, resp.OOBCodeURL.String())
		msg.To = []string{resp.Email}
	}
	if err := mail.Send(c, msg); err != nil {
		aelog.Errorf(c, "Failed to send %s message to user %s: %s", resp.Action, resp.Email, err)
		w.Write([]byte(gitkit.ErrorResponse(err)))
		return
	}
	w.Write([]byte(gitkit.SuccessResponse()))
}
开发者ID:vasistbhargav,项目名称:identity-toolkit-go,代码行数:32,代码来源:favweekday.go

示例5: SendEmailToAllUsers

func SendEmailToAllUsers(r *http.Request, subject string) int {
	ctx := req2ctx(r)
	cdb := complaintdb.NewDB(ctx)

	if cps, err := cdb.GetAllProfiles(); err != nil {
		cdb.Errorf("SendEmailToAllUsers/GetAllProfiles: %v", err)
		return 0

	} else {
		buf := new(bytes.Buffer)
		params := map[string]interface{}{}
		if err := templates.ExecuteTemplate(buf, "email-update", params); err != nil {
			return 0
		}

		n := 0
		for _, cp := range cps {
			msg := &mail.Message{
				Sender:   kSenderEmail,
				ReplyTo:  kSenderEmail,
				To:       []string{cp.EmailAddress},
				Subject:  subject,
				HTMLBody: buf.String(),
			}
			if err := mail.Send(cdb.Ctx(), msg); err != nil {
				cdb.Errorf("Could not send useremail to <%s>: %v", cp.EmailAddress, err)
			}
			n++
		}
		return n
	}
}
开发者ID:skypies,项目名称:complaints,代码行数:32,代码来源:email.go

示例6: sendMail

func sendMail(ctx context.Context, mentionProfile *Profile) error {
	msg := &mail.Message{
		Sender:  "<[email protected]>",
		To:      []string{mentionProfile.Email},
		Subject: "Someone mentioned you!",
		Body:    fmt.Sprintf("Someone mentioned you!"),
	}
	return mail.Send(ctx, msg)
}
开发者ID:RobertoSuarez,项目名称:GolangTraining,代码行数:9,代码来源:data.go

示例7: sendVerificationCodeEmail

func sendVerificationCodeEmail(ctx context.Context, user User) {
	msg := &mail.Message{
		Sender:  "NewTechFellas Stock Alerts Admin <[email protected]>",
		To:      []string{user.Email},
		Subject: "Newtechfellas stock alerts verify user",
		Body:    fmt.Sprintf("Your confirmation code is %v", user.VerificationCode),
	}
	if err := mail.Send(ctx, msg); err != nil {
		log.Debugf(ctx, "Couldn't send email: %v", err)
	}
}
开发者ID:newtechfellas,项目名称:StockAlerts,代码行数:11,代码来源:userhandlerfuncs.go

示例8: SendEmailToAdmin

func SendEmailToAdmin(c context.Context, subject, htmlbody string) {
	msg := &mail.Message{
		Sender:   kSenderEmail, // cap.Profile.EmailAddress,
		To:       []string{kAdminEmail},
		Subject:  subject,
		HTMLBody: htmlbody,
	}

	if err := mail.Send(c, msg); err != nil {
		log.Errorf(c, "Could not send adminemail to <%s>: %v", kAdminEmail, err)
	}
}
开发者ID:skypies,项目名称:complaints,代码行数:12,代码来源:overnight-emails.go

示例9: RequestConfirmation

func (sub Subscription) RequestConfirmation(ctx context.Context) error {
	buf := new(bytes.Buffer)
	if err := subscription.Execute(buf, sub); err != nil {
		return err
	}
	return appmail.Send(ctx, &appmail.Message{
		Sender:  "Lorenz Leutgeb <[email protected]>",
		To:      []string{sub.Address.String()},
		Subject: "Hello from Coduno",
		Body:    buf.String(),
	})
}
开发者ID:pbochis,项目名称:api,代码行数:12,代码来源:sub.go

示例10: followedEmail

func followedEmail(w http.ResponseWriter, r *http.Request, email string) {
	ctx := appengine.NewContext(r)
	msg := &mail.Message{
		Sender:  "TwitClone Support <[email protected]>",
		To:      []string{email},
		Subject: "You are being followed",
		Body:    fmt.Sprintf(confirmMessage),
	}
	if err := mail.Send(ctx, msg); err != nil {
		log.Errorf(ctx, "Couldn't send email: %v", err)
	}
}
开发者ID:RaviTezu,项目名称:GolangTraining,代码行数:12,代码来源:email.go

示例11: sendEmail

func sendEmail(email string, c context.Context) {
	msg := &mail.Message{
		Sender:  "[email protected]",
		To:      []string{email},
		Subject: "Agradecimento",
		Body:    "Muito obrigada, farás muitos rostinhos sorrirem!",
	}
	if err := mail.Send(c, msg); err != nil {
		log.Errorf(c, "Couldn't send email to %s: %v", email, err)
	} else {
		log.Infof(c, "Sent email to: %s", email, err)
	}
}
开发者ID:BearchInc,项目名称:fbcanvas,代码行数:13,代码来源:hellofbcanvas.go

示例12: sendReminderEmail

func sendReminderEmail(ctx context.Context,
	email string,
	description string,
	dueDate time.Time) bool {
	msg := &mail.Message{
		Sender:  "Tada <[email protected]>",
		To:      []string{email},
		Subject: fmt.Sprintf("[Tada reminder] %s", description),
		Body: fmt.Sprintf(`This is a friendly reminder about your task: \n
                       %s \n
                       (due %s)\n`, description, dueDate),
	}
	return (mail.Send(ctx, msg) == nil)
}
开发者ID:catamorphism,项目名称:tada,代码行数:14,代码来源:email-sender.go

示例13: confirm

func confirm(w http.ResponseWriter, r *http.Request) {
	ctx := appengine.NewContext(r)
	addr := r.FormValue("email")
	url := createConfirmationURL(r)
	msg := &mail.Message{
		Sender:  "Example.com Support <[email protected]>",
		To:      []string{addr},
		Subject: "Confirm your registration",
		Body:    fmt.Sprintf(confirmMessage, url),
	}
	if err := mail.Send(ctx, msg); err != nil {
		log.Errorf(ctx, "Couldn't send email: %v", err)
	}
}
开发者ID:wuman,项目名称:golang-samples,代码行数:14,代码来源:mail.go

示例14: sendEmail

// sendEmail with the AppEngine API.
func sendEmail(r *http.Request, from, to, subject, body string) {
	// Use AppEngine to send our thank you cards
	c := appengine.NewContext(r)
	msg := &mail.Message{
		Sender:  from,
		To:      []string{to},
		Subject: subject,
		Body:    body,
	}

	if err := mail.Send(c, msg); err != nil {
		log.Printf("[ERROR] Could not send email: %v\n", err)
	}
}
开发者ID:BI,项目名称:truetandem-gsa,代码行数:15,代码来源:gaeMail.go

示例15: handleIndex

func handleIndex(res http.ResponseWriter, req *http.Request) {
	ctx := appengine.NewContext(req)
	u := user.Current(ctx)

	msg := &mail.Message{
		Sender:  u.Email,
		To:      []string{"Caleb Doxsey <[email protected]>"},
		Subject: "See you tonight",
		Body:    "Don't forget our plans. Hark, 'til later.",
	}
	if err := mail.Send(ctx, msg); err != nil {
		log.Errorf(ctx, "Alas, my user, the email failed to sendeth: %v", err)
	}
}
开发者ID:magj2006,项目名称:bootcamp-examples,代码行数:14,代码来源:main.go


注:本文中的google/golang.org/appengine/mail.Send函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。