This reverts commit 8966452d11.
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
816a30397d
Коммит
a6694058a7
@@ -7,13 +7,14 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"mime"
|
"mime"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/gomail.v2"
|
"gopkg.in/gomail.v2"
|
||||||
|
|
||||||
|
"net/http"
|
||||||
|
|
||||||
l4g "github.com/alecthomas/log4go"
|
l4g "github.com/alecthomas/log4go"
|
||||||
"github.com/mattermost/html2text"
|
"github.com/mattermost/html2text"
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
@@ -47,20 +48,6 @@ func connectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) {
|
|||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove once this bug is fixed: https://github.com/golang/go/issues/22166
|
|
||||||
type plainAuthOverTLSConn struct {
|
|
||||||
smtp.Auth
|
|
||||||
}
|
|
||||||
|
|
||||||
func PlainAuthOverTLSConn(identity, username, password, host string) smtp.Auth {
|
|
||||||
return &plainAuthOverTLSConn{smtp.PlainAuth(identity, username, password, host)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *plainAuthOverTLSConn) Start(server *smtp.ServerInfo) (string, []byte, error) {
|
|
||||||
server.TLS = true
|
|
||||||
return a.Auth.Start(server)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.AppError) {
|
func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.AppError) {
|
||||||
c, err := smtp.NewClient(conn, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
|
c, err := smtp.NewClient(conn, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -86,12 +73,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *config.EmailSettings.EnableSMTPAuth {
|
if *config.EmailSettings.EnableSMTPAuth {
|
||||||
var auth smtp.Auth
|
auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
|
||||||
if _, ok := conn.(*tls.Conn); ok {
|
|
||||||
auth = PlainAuthOverTLSConn("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
|
|
||||||
} else {
|
|
||||||
auth = smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = c.Auth(auth); err != nil {
|
if err = c.Auth(auth); err != nil {
|
||||||
return nil, model.NewAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return nil, model.NewAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user