func sendContactMail(c *webcontact.Contact, rcpts []string) (int, error) { subject := c.MailSubject() body, err := c.MailBody() if err != nil { return http.StatusInternalServerError, err } mail := email.NewContact(c.Email, subject, body) if err := mail.Do(rcpts); err != nil { return http.StatusInternalServerError, err } return http.StatusOK, nil }
func TestContactCreate(t *testing.T) { c := newContact() subject := c.MailSubject() body, err := c.MailBody() if err != nil { t.Fatal(err) } mail := email.NewContact(c.Email, subject, body) if mail.Subject != "[NLgids] Contact van \"Miek Gieben\"" { t.Fatal("wrong email Subject") } if mail.From != "" { // Should be empty, we put these value when to do mail.Do() t.Fatalf("wrong email From: %s", mail.From) } if len(mail.Cc) != 0 { t.Fatalf("wrong email Cc: %d", len(mail.Cc)) } if err := mail.Do([]string{"*****@*****.**"}); err != nil { t.Fatalf("can't send mail %s: ", err) } }