You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
828 B
36 lines
828 B
2 years ago
|
package postman
|
||
|
|
||
|
// Почтовое сообщения предназначенное для отправки
|
||
|
type Message struct {
|
||
|
to []string
|
||
|
subject string
|
||
|
body string
|
||
|
contentType string
|
||
|
attachments []Attachment
|
||
|
}
|
||
|
|
||
|
func NewMessage(subject string, body string) Message {
|
||
|
return Message{
|
||
|
to: []string{},
|
||
|
subject: subject,
|
||
|
contentType: "text/plain;charset=utf8",
|
||
|
attachments: []Attachment{},
|
||
|
body: body,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Пополнение списка получателей
|
||
|
func (m *Message) AppendRecipient(recipient string) error {
|
||
|
m.to = append(m.to, recipient)
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// Пополнение списка вложений
|
||
|
func (m *Message) AppendAttachment(file string) error {
|
||
|
a := NewAttachment(file)
|
||
|
m.attachments = append(m.attachments, a)
|
||
|
|
||
|
return nil
|
||
|
}
|