aboutsummaryrefslogtreecommitdiffstats
path: root/smtp.go
diff options
context:
space:
mode:
Diffstat (limited to 'smtp.go')
-rw-r--r--smtp.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/smtp.go b/smtp.go
index 5e178f2..ed6bffe 100644
--- a/smtp.go
+++ b/smtp.go
@@ -18,17 +18,16 @@ func (s *Server) dialSMTP() (*smtp.Client, error) {
if err != nil {
return nil, fmt.Errorf("failed to connect to SMTPS server: %v", err)
}
+ } else if !s.smtp.insecure {
+ c, err = smtp.DialStartTLS(s.smtp.host, nil)
+ if err != nil {
+ return nil, fmt.Errorf("failed to connect to SMTP server: %v", err)
+ }
} else {
c, err = smtp.Dial(s.smtp.host)
if err != nil {
return nil, fmt.Errorf("failed to connect to SMTP server: %v", err)
}
- if !s.smtp.insecure {
- if err := c.StartTLS(nil); err != nil {
- c.Close()
- return nil, fmt.Errorf("STARTTLS failed: %v", err)
- }
- }
}
return c, err