change receiver field type
This commit is contained in:
+9
-14
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user