email_test.go 882 B

12345678910111213141516171819202122232425262728293031323334
  1. package email
  2. import (
  3. "net/smtp"
  4. "testing"
  5. )
  6. func TestEmail(*testing.T) {
  7. e := NewEmail()
  8. e.From = "Jordan Wright <test@example.com>"
  9. e.To = []string{"test@example.com"}
  10. e.Bcc = []string{"test_bcc@example.com"}
  11. e.Cc = []string{"test_cc@example.com"}
  12. e.Subject = "Awesome Subject"
  13. e.Text = "Text Body is, of course, supported!"
  14. e.HTML = "<h1>Fancy Html is supported, too!</h1>"
  15. }
  16. func ExampleGmail() {
  17. e := NewEmail()
  18. e.From = "Jordan Wright <test@gmail.com>"
  19. e.To = []string{"test@example.com"}
  20. e.Bcc = []string{"test_bcc@example.com"}
  21. e.Cc = []string{"test_cc@example.com"}
  22. e.Subject = "Awesome Subject"
  23. e.Text = "Text Body is, of course, supported!"
  24. e.HTML = "<h1>Fancy Html is supported, too!</h1>"
  25. e.Send("smtp.gmail.com:587", smtp.PlainAuth("", e.From, "password123", "smtp.gmail.com"))
  26. }
  27. func ExampleAttach() {
  28. e := NewEmail()
  29. e.Attach("test.txt")
  30. }