Example #1
0
File: mail.go Project: vito/drone
// Sends a build failure email to the user.
func SendFailure(repo, to string, data interface{}) error {
	msg := Message{}
	msg.Subject = "[FAILURE] " + repo
	msg.To = to

	var buf bytes.Buffer
	err := template.ExecuteTemplate(&buf, "failure.html", &data)
	if err != nil {
		log.Print(err)
		return err
	}
	msg.Body = buf.String()

	return Send(&msg)
}
Example #2
0
File: mail.go Project: vito/drone
// Sends an email to the User's email address
// with Password reset information.
func SendPassword(to string, data interface{}) error {
	msg := Message{}
	msg.Subject = "[drone.io] Password Reset"
	msg.To = to

	var buf bytes.Buffer
	err := template.ExecuteTemplate(&buf, "reset_password.html", &data)
	if err != nil {
		log.Print(err)
		return err
	}
	msg.Body = buf.String()

	return Send(&msg)
}
Example #3
0
File: mail.go Project: vito/drone
// Sends an invitation to join a Team
func SendInvitation(team, to string, data interface{}) error {
	msg := Message{}
	msg.Subject = "Invited to join " + team
	msg.To = to

	var buf bytes.Buffer
	err := template.ExecuteTemplate(&buf, "invitation.html", &data)
	if err != nil {
		log.Print(err)
		return err
	}
	msg.Body = buf.String()

	return Send(&msg)
}
Example #4
0
File: mail.go Project: vito/drone
// Sends a activation email to the User.
func SendActivation(to string, data interface{}) error {
	msg := Message{}
	msg.Subject = "[drone.io] Account Activation"
	msg.To = to

	var buf bytes.Buffer
	err := template.ExecuteTemplate(&buf, "activation.html", &data)
	if err != nil {
		log.Print(err)
		return err
	}
	msg.Body = buf.String()

	return Send(&msg)
}
Example #5
0
// Sends a build failure email to the user.
func SendFailure(repo, sha, to string, data interface{}) error {
	msg := Message{}
	msg.Subject = fmt.Sprintf("[%s] FAILURE building %s", repo, sha)
	msg.To = to

	var buf bytes.Buffer
	err := template.ExecuteTemplate(&buf, "failure.html", &data)
	if err != nil {
		log.Print(err)
		return err
	}
	msg.Body = buf.String()

	return Send(&msg)
}
Example #6
0
// Renders the 403 template for the specified data type
// and write the output to the http.ResponseWriter.
func RenderForbidden(w http.ResponseWriter) error {
	w.Header().Add("Content-Type", "text/html; charset=utf-8")
	w.WriteHeader(http.StatusNotFound)
	return template.ExecuteTemplate(w, "403.amber", nil)
}
Example #7
0
// Renders the named template for the specified data type
// and write the output to the http.ResponseWriter.
func RenderTemplate(w http.ResponseWriter, name string, data interface{}) error {
	w.Header().Add("Content-Type", "text/html; charset=utf-8")
	return template.ExecuteTemplate(w, name, data)
}