Exemplo n.º 1
0
func SendEmail(ct ContactType, subject string, body string) (err error) {
	var tos []string
	receivers, err := ct.GetReceivers()
	if err != nil {
		return err
	}
	if len(receivers) < 1 {
		err = errors.New("No recipients for selected contact type.")
		return err
	}
	for _, r := range receivers {
		tos = append(tos, r.Email)
	}
	//set up template
	t := template.New("emailTemplate")
	t, err = t.Parse(emailTemplate)
	if err != nil {
		return err
	}
	var msg bytes.Buffer
	context := &SmtpTemplateData{
		tos,
		subject,
		body,
	}
	err = t.Execute(&msg, context)
	if err != nil {
		return err
	}

	err = email.Send(tos, subject, msg.String(), false)
	return err
}
Exemplo n.º 2
0
func (cu *CustomerUser) SendRegistrationRequestEmail() error {
	//TODO
	tos := []string{"*****@*****.**"}
	subject := "A new Customer User wishes to be active"
	body := `<p>A new account with this e-mail address has been registered.</p>
                <hr />
                <span>The username is: <strong>` + cu.Email + `</strong></span><br />`
	return email.Send(tos, subject, body, true)
}
Exemplo n.º 3
0
func ResetPassword(rw http.ResponseWriter, r *http.Request, enc encoding.Encoder) string {
	var err error

	email := r.FormValue("email")
	custID := r.FormValue("customerID")
	site := r.FormValue("site")

	if email == "" {
		err = errors.New("No email address provided")
		apierror.GenerateError("No email address provided", err, rw, r)
		return ""
	}
	if custID == "" {
		err = errors.New("Customer ID cannot be blank")
		apierror.GenerateError("Customer ID cannot be blank", err, rw, r)
		return ""
	}

	var user customer.CustomerUser
	user.Email = email
	user.CustID, err = strconv.Atoi(custID)
	if err != nil {
		apierror.GenerateError("Trouble parsing cust ID", err, rw, r)
		return ""
	}

	resp, err := user.ResetPass()
	if err != nil || resp == "" {
		apierror.GenerateError("Trouble resetting user password", err, rw, r)
		return ""
	}

	//email
	subject := "Your Password Has Been Reset"
	body := `<p>Here is your new password for the ` + site + ` site.</p> 
	<p>Password: ` + resp + `</p><p> If you did not request this password, please contact <a href="mailto:[email protected]">Web Support</a></p>
	<p>Thanks, </p>
	<p>The Ecommerce Developer Team</P>`
	err = emailHelper.Send([]string{email}, subject, body, true)
	if err != nil {
		apierror.GenerateError("Trouble emailing new user password", err, rw, r)
		return ""
	}

	return encoding.Must(enc.Encode("success"))
}
Exemplo n.º 4
0
func (cu *CustomerUser) SendRegistrationEmail() error {
	var brandStr string
	for i, b := range cu.Brands {
		if i > 0 {
			brandStr += "/"
		}
		brandStr += b.Name
	}
	tos := []string{cu.Email}
	subject := "Thank you for registering with " + brandStr + "!"
	body := `<p>A new account with this e-mail address has been registered.</p>
                <hr />
                <span>The username is: <strong>` + cu.Email + `</strong></span><br />
                <span>The password is: <strong>` + cu.Password + `</strong></span><br />
                <hr /><br />
                <p>Since you did not know your CURT Customer ID number, you will not have access to the 
                entire dealer area until we can validate who you are. You can however in the meantime add Web Properties.</p>
                <p style='font-size:11px'>If you feel this was a mistake please contact us.</p>`
	return email.Send(tos, subject, body, true)
}