forked from domodwyer/mailyak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetters.go
111 lines (98 loc) · 2.46 KB
/
setters.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 mailyak
// To sets a list of recipient addresses.
//
// You can pass one or more addresses to this method, all of which are viewable to the recipients.
//
// mail.To("[email protected]", "[email protected]")
//
// or pass a slice of strings:
//
// tos := []string{
// "[email protected]",
// "[email protected]"
// }
//
// mail.To(tos...)
func (m *MailYak) To(addrs ...string) {
m.toAddrs = []string{}
for _, addr := range addrs {
trimmed := m.trimRegex.ReplaceAllString(addr, "")
if trimmed == "" {
continue
}
m.toAddrs = append(m.toAddrs, trimmed)
}
}
// Bcc sets a list of blind carbon copy (BCC) addresses.
//
// You can pass one or more addresses to this method, none of which are viewable to the recipients.
//
// mail.Bcc("[email protected]", "[email protected]")
//
// or pass a slice of strings:
//
// bccs := []string{
// "[email protected]",
// "[email protected]"
// }
//
// mail.Bcc(bccs...)
func (m *MailYak) Bcc(addrs ...string) {
m.bccAddrs = []string{}
for _, addr := range addrs {
trimmed := m.trimRegex.ReplaceAllString(addr, "")
if trimmed == "" {
continue
}
m.bccAddrs = append(m.bccAddrs, trimmed)
}
}
// Cc sets a list of carbon copy (CC) addresses.
//
// You can pass one or more addresses to this method, which are viewable to the other recipients.
//
// mail.Cc("[email protected]", "[email protected]")
//
// or pass a slice of strings:
//
// ccs := []string{
// "[email protected]",
// "[email protected]"
// }
//
// mail.Cc(ccs...)
func (m *MailYak) Cc(addrs ...string) {
m.ccAddrs = []string{}
for _, addr := range addrs {
trimmed := m.trimRegex.ReplaceAllString(addr, "")
if trimmed == "" {
continue
}
m.ccAddrs = append(m.ccAddrs, trimmed)
}
}
// From sets the sender email address.
//
// Users should also consider setting FromName().
func (m *MailYak) From(addr string) {
m.fromAddr = m.trimRegex.ReplaceAllString(addr, "")
}
// FromName sets the sender name.
//
// If set, emails typically display as being from:
//
// From Name <[email protected]>
//
func (m *MailYak) FromName(name string) {
m.fromName = m.trimRegex.ReplaceAllString(name, "")
}
// ReplyTo sets the Reply-To email address.
//
// Setting a ReplyTo address is optional.
func (m *MailYak) ReplyTo(addr string) {
m.replyTo = m.trimRegex.ReplaceAllString(addr, "")
}
// Subject sets the email subject line.
func (m *MailYak) Subject(sub string) {
m.subject = m.trimRegex.ReplaceAllString(sub, "")
}