func sendEmail(ctx context.Context, cfg *Config, build *cbpb.Build) error {
	msg, err := BuildEmail(cfg, build)
	if err != nil {
		return fmt.Errorf("building email: %v", err)
	}

	addr := fmt.Sprintf("%s:%d", cfg.emailHostname, cfg.emailPort)
	var auth smtp.Auth
	if cfg.emailUsername != "" {
		auth = smtp.PlainAuth("", cfg.emailUsername, cfg.emailPassword, cfg.emailHostname)
	}

	log.Printf("Sending email to %v", strings.Join(cfg.emailRecipientsAddrs(), ","))
	return smtp.SendMail(addr, auth, cfg.emailFrom.Address, cfg.emailRecipientsAddrs(), msg)
}
// sendEmail sends an email message describing build per cfg.
// cfg.checkEmail must be called first to check that email should actually be sent.
sendEmail sends an email message describing build per cfg.
cfg.checkEmail must be called first to check that email should actually be sent.
// sendEmail sends an email message describing build per cfg . // cfg . checkEmail must be called first to check that email should actually be sent .
func sendEmail(ctx context.Context, cfg *Config, build *cbpb.Build) error {
	msg, err := BuildEmail(cfg, build)
	if err != nil {
		return fmt.Errorf("building email: %v", err)
	}
	addr := fmt.Sprintf("%s:%d", cfg.emailHostname, cfg.emailPort)
	var auth smtp.Auth
	if cfg.emailUsername != "" {
		auth = smtp.PlainAuth("", cfg.emailUsername, cfg.emailPassword, cfg.emailHostname)
	}
	log.Printf("Sending email to %v", strings.Join(cfg.emailRecipientsAddrs(), ","))
	return smtp.SendMail(addr, auth, cfg.emailFrom.Address, cfg.emailRecipientsAddrs(), msg)
}
func sendEmail ( ctx context . Context , cfg * Config , build * cbpb . Build ) error { msg , err := BuildEmail ( cfg , build ) if err != nil { return fmt . Errorf ( " " , err ) } addr := fmt . Sprintf ( " " , cfg . emailHostname , cfg . emailPort ) var auth smtp . Auth if cfg . emailUsername != " " { auth = smtp . PlainAuth ( " " , cfg . emailUsername , cfg . emailPassword , cfg . emailHostname ) } log . Printf ( " " , strings . Join ( cfg . emailRecipientsAddrs ( ) , " " ) ) return smtp . SendMail ( addr , auth , cfg . emailFrom . Address , cfg . emailRecipientsAddrs ( ) , msg ) }
sendEmail sends an email message describing build per cfg.
sendEmail sends an email message describing build per cfg .