change receiver field type

This commit is contained in:
2023-09-09 16:07:08 +02:00
parent 2bc22b637d
commit 4d0076e625
2 changed files with 10 additions and 15 deletions
+9 -14
View File
@@ -9,19 +9,10 @@ import (
type Email struct {
Path string
Sender string `json:"sender"`
Receivers []string `json:"receivers"`
Subject string `json:"subject"`
Content string `json:"content"`
}
func NewEmail(sender string, receivers []string, subject, content string) Email {
return Email{
Sender: sender,
Receivers: receivers,
Subject: subject,
Content: content,
}
Sender string `json:"sender"`
Receivers string `json:"receivers"`
Subject string `json:"subject"`
Content string `json:"content"`
}
func FromJSON(path string) (Email, error) {
@@ -39,10 +30,14 @@ func FromJSON(path string) (Email, error) {
return mail, nil
}
func (e Email) GetReceivers() []string {
return strings.Split(e.Receivers, ",")
}
func (e Email) Generate() []byte {
mail := fmt.Sprintf(
"To: %s\nFrom: %s\nContent-Type: text/html;charset=utf-8\nSubject: %s\n\n%s",
strings.Join(e.Receivers, ","),
e.Receivers,
e.Sender,
e.Subject,
e.Content,