diff options
author | =Corey Hulen <corey@hulen.com> | 2015-06-16 23:05:37 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-06-16 23:05:37 -0800 |
commit | 4cfa1da8b4eeafb97b69c214ab84c70231461a28 (patch) | |
tree | 472070e95309bbd8d54b97b504458db1a01f895a /utils/mail.go | |
parent | c9bd02cea56d5c7b13133e6a09dbfd830cf3a79b (diff) | |
download | chat-4cfa1da8b4eeafb97b69c214ab84c70231461a28.tar.gz chat-4cfa1da8b4eeafb97b69c214ab84c70231461a28.tar.bz2 chat-4cfa1da8b4eeafb97b69c214ab84c70231461a28.zip |
Fixing build
Diffstat (limited to 'utils/mail.go')
-rw-r--r-- | utils/mail.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/utils/mail.go b/utils/mail.go index 645dcae24..bf1cc9d46 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -40,23 +40,27 @@ func SendMail(to, subject, body string) *model.AppError { auth := smtp.PlainAuth("", Cfg.EmailSettings.SMTPUsername, Cfg.EmailSettings.SMTPPassword, host) + var conn net.Conn + var err error + if Cfg.EmailSettings.UseTLS { tlsconfig := &tls.Config{ InsecureSkipVerify: true, ServerName: host, } - conn, err := tls.Dial("tcp", Cfg.EmailSettings.SMTPServer, tlsconfig) + conn, err = tls.Dial("tcp", Cfg.EmailSettings.SMTPServer, tlsconfig) if err != nil { return model.NewAppError("SendMail", "Failed to open TLS connection", err.Error()) } - defer conn.Close() + } else { + conn, err = net.Dial("tcp", Cfg.EmailSettings.SMTPServer) + if err != nil { + return model.NewAppError("SendMail", "Failed to open connection", err.Error()) + } } - conn, err := net.Dial("tcp", Cfg.EmailSettings.SMTPServer) - if err != nil { - return model.NewAppError("SendMail", "Failed to open connection", err.Error()) - } + defer conn.Close() c, err := smtp.NewClient(conn, host) if err != nil { |