-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
111 lines (95 loc) · 2.39 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package newman
// MessageOption is a function that sets a field on an EmailMessage
type MessageOption func(*EmailMessage)
// WithFrom sets the from email address
func WithFrom(from string) MessageOption {
return func(m *EmailMessage) {
m.From = from
}
}
// WithTo sets the to email address
func WithTo(to []string) MessageOption {
return func(m *EmailMessage) {
m.To = to
}
}
// WithSubject sets the subject of the email
func WithSubject(subject string) MessageOption {
return func(m *EmailMessage) {
m.Subject = subject
}
}
// WithBcc sets the bcc email address
func WithBcc(bcc []string) MessageOption {
return func(m *EmailMessage) {
m.Bcc = bcc
}
}
// WithCc sets the cc email address
func WithCc(cc []string) MessageOption {
return func(m *EmailMessage) {
m.Cc = cc
}
}
// WithReplyTo sets the reply to email address
func WithReplyTo(replyTo string) MessageOption {
return func(m *EmailMessage) {
m.ReplyTo = replyTo
}
}
// WithHTML sets the html content of the email
func WithHTML(html string) MessageOption {
return func(m *EmailMessage) {
m.HTML = html
}
}
// WithText sets the text content of the email
func WithText(text string) MessageOption {
return func(m *EmailMessage) {
m.Text = text
}
}
// WithTag adds a tag to the email
func WithTag(tag Tag) MessageOption {
return func(m *EmailMessage) {
m.Tags = append(m.Tags, tag)
}
}
// WithTags sets the tags of the email
func WithTags(tags []Tag) MessageOption {
return func(m *EmailMessage) {
m.Tags = tags
}
}
// WithAttachment adds an attachment to the email
func WithAttachment(attachment *Attachment) MessageOption {
return func(m *EmailMessage) {
m.Attachments = append(m.Attachments, attachment)
}
}
// WithAttachments sets the attachments of the email
func WithAttachments(attachments []*Attachment) MessageOption {
return func(m *EmailMessage) {
m.Attachments = attachments
}
}
// WithHeader adds a header to the email
func WithHeader(key, value string) MessageOption {
return func(m *EmailMessage) {
m.Headers[key] = value
}
}
// WithHeaders sets the headers of the email
func WithHeaders(headers map[string]string) MessageOption {
return func(m *EmailMessage) {
m.Headers = headers
}
}
// WithHeaderMap adds a map of headers to the email
func WithHeaderMap(headers map[string]string) MessageOption {
return func(m *EmailMessage) {
for key, value := range headers {
m.Headers[key] = value
}
}
}