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") } }
func constructRFC5322(email, name string) string { m := new(mail.Address) m.Name = name m.Address = email return m.String() }