Exemple #1
0
func InsertHandler(w http.ResponseWriter, r *http.Request) {
	var newSubscriber mail.Address
	newSubscriber.Name = r.FormValue("Name")
	newSubscriber.Address = r.FormValue("Email-id")
	if newSubscriber.Address == "" {
		fmt.Fprintf(w, "Sorry the email field cannot be left empty")
	} else if isPresent(newSubscriber.Address) == true {
		fmt.Fprintf(w, "Sorry the email address is already taken")
	} else {
		AddSubscriber(newSubscriber)
		fmt.Fprintf(w, "You have succesfully subscribed")
	}
}
Exemple #2
0
// generate hash, either with email address or OpenID
func (v *Libravatar) genHash(email *mail.Address, openid *url.URL) string {
	if email != nil {
		email.Address = strings.ToLower(strings.TrimSpace(email.Address))
		sum := md5.Sum([]byte(email.Address))
		return fmt.Sprintf("%x", sum)
	} else if openid != nil {
		openid.Scheme = strings.ToLower(openid.Scheme)
		openid.Host = strings.ToLower(openid.Host)
		sum := sha256.Sum256([]byte(openid.String()))
		return fmt.Sprintf("%x", sum)
	}
	// panic, because this should not be reachable
	panic("Neither Email or OpenID set")
}
Exemple #3
0
func constructRFC5322(email, name string) string {
	m := new(mail.Address)
	m.Name = name
	m.Address = email
	return m.String()
}