-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathoptions.go
84 lines (71 loc) · 1.52 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
package email
import "time"
// Option func type
type Option func(s *Sender)
// SMTP sets SMTP client
func SMTP(smtp SMTPClient) Option {
return func(s *Sender) {
s.smtpClient = smtp
}
}
// Log sets the logger for the email package
func Log(l Logger) Option {
return func(s *Sender) {
s.logger = l
}
}
// Port sets SMTP port
func Port(port int) Option {
return func(s *Sender) {
s.port = port
}
}
// ContentType sets content type of the email
func ContentType(contentType string) Option {
return func(s *Sender) {
s.contentType = contentType
}
}
// Charset sets content charset of the email
func Charset(charset string) Option {
return func(s *Sender) {
s.contentCharset = charset
}
}
// TLS enables TLS support
func TLS(enabled bool) Option {
return func(s *Sender) {
s.tls = enabled
}
}
// STARTTLS enables STARTTLS support
func STARTTLS(enabled bool) Option {
return func(s *Sender) {
s.starttls = enabled
}
}
// InsecureSkipVerify skips certificate verification
func InsecureSkipVerify(enabled bool) Option {
return func(s *Sender) {
s.insecureSkipVerify = enabled
}
}
// Auth sets smtp username and password
func Auth(smtpUserName, smtpPasswd string) Option {
return func(s *Sender) {
s.smtpUserName = smtpUserName
s.smtpPassword = smtpPasswd
}
}
// LoginAuth sets LOGIN auth method
func LoginAuth() Option {
return func(s *Sender) {
s.authMethod = authMethodLogin
}
}
// TimeOut sets smtp timeout
func TimeOut(timeOut time.Duration) Option {
return func(s *Sender) {
s.timeOut = timeOut
}
}