emails.go 816 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package models
  2. type SendEmailCommand struct {
  3. To []string
  4. From string
  5. Subject string
  6. Body string
  7. Type string
  8. Massive bool
  9. Info string
  10. }
  11. type SendResetPasswordEmailCommand struct {
  12. User *User
  13. }
  14. // create mail content
  15. func (m *SendEmailCommand) Content() string {
  16. // set mail type
  17. contentType := "text/plain; charset=UTF-8"
  18. if m.Type == "html" {
  19. contentType = "text/html; charset=UTF-8"
  20. }
  21. // create mail content
  22. content := "From: " + m.From + "\r\nSubject: " + m.Subject + "\r\nContent-Type: " + contentType + "\r\n\r\n" + m.Body
  23. return content
  24. }
  25. // Create html mail command
  26. func NewSendEmailCommand(To []string, From, Subject, Body string) SendEmailCommand {
  27. return SendEmailCommand{
  28. To: To,
  29. From: From,
  30. Subject: Subject,
  31. Body: Body,
  32. Type: "html",
  33. }
  34. }