Skip to content

Commit f6c76e8

Browse files
author
Dean Karn
authored
Merge pull request #20 from Chiiruno/master
email handler: Add setters
2 parents c65d19d + 082b2d3 commit f6c76e8

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

handlers/email/email.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,36 @@ func (email *Email) SetFormatFunc(fn FormatFunc) {
104104
email.formatFunc = fn
105105
}
106106

107+
// SetHost sets Email's host
108+
func (email *Email) SetHost(host string) {
109+
email.host = host
110+
}
111+
112+
// SetPort sets Email's port
113+
func (email *Email) SetPort(port int) {
114+
email.port = port
115+
}
116+
117+
// SetUsername sets Email's username
118+
func (email *Email) SetUsername(username string) {
119+
email.username = username
120+
}
121+
122+
// SetPassword sets Email's password
123+
func (email *Email) SetPassword(password string) {
124+
email.password = password
125+
}
126+
127+
// SetFrom sets Email's email address to send from
128+
func (email *Email) SetFrom(from string) {
129+
email.from = from
130+
}
131+
132+
// SetTo sets Email's email address(es) to send to
133+
func (email *Email) SetTo(to []string) {
134+
email.to = to
135+
}
136+
107137
func defaultFormatFunc(email *Email) Formatter {
108138
b := new(bytes.Buffer)
109139

handlers/email/email_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ func TestEmailHandler(t *testing.T) {
103103
email := New("localhost", 3041, "", "", "[email protected]", []string{"[email protected]"})
104104
email.SetTimestampFormat("MST")
105105
email.SetTemplate(defaultTemplate)
106+
email.SetHost("localhost")
107+
email.SetPort(3041)
108+
email.SetUsername("")
109+
email.SetPassword("")
110+
email.SetFrom("[email protected]")
111+
email.SetTo([]string{"[email protected]"})
106112
// email.SetFormatFunc(testFormatFunc)
107113
log.AddHandler(email, log.InfoLevel, log.DebugLevel)
108114

0 commit comments

Comments
 (0)