diff --git a/config/config.json b/config/config.json index 0c7144f1ae..316e9de014 100644 --- a/config/config.json +++ b/config/config.json @@ -129,6 +129,7 @@ "FeedbackName": "", "FeedbackEmail": "test@example.com", "FeedbackOrganization": "", + "EnableSMTPAuth": false, "SMTPUsername": "", "SMTPPassword": "", "SMTPServer": "dockerhost", @@ -299,4 +300,4 @@ "RunJobs": true, "RunScheduler": true } -} \ No newline at end of file +} diff --git a/model/config.go b/model/config.go index a1af591854..02af644779 100644 --- a/model/config.go +++ b/model/config.go @@ -262,6 +262,7 @@ type EmailSettings struct { FeedbackName string FeedbackEmail string FeedbackOrganization *string + EnableSMTPAuth *bool SMTPUsername string SMTPPassword string SMTPServer string @@ -785,6 +786,19 @@ func (o *Config) SetDefaults() { *o.EmailSettings.EmailBatchingInterval = EMAIL_BATCHING_INTERVAL } + if o.EmailSettings.EnableSMTPAuth == nil { + o.EmailSettings.EnableSMTPAuth = new(bool) + if o.EmailSettings.ConnectionSecurity == CONN_SECURITY_NONE { + *o.EmailSettings.EnableSMTPAuth = false + } else { + *o.EmailSettings.EnableSMTPAuth = true + } + } + + if o.EmailSettings.ConnectionSecurity == CONN_SECURITY_PLAIN { + o.EmailSettings.ConnectionSecurity = CONN_SECURITY_NONE + } + if o.EmailSettings.SkipServerCertificateVerification == nil { o.EmailSettings.SkipServerCertificateVerification = new(bool) *o.EmailSettings.SkipServerCertificateVerification = false diff --git a/utils/mail.go b/utils/mail.go index 4b31024246..41011d67e9 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -6,13 +6,14 @@ package utils import ( "crypto/tls" "fmt" - l4g "github.com/alecthomas/log4go" - "github.com/mattermost/platform/model" "mime" "net" "net/mail" "net/smtp" "time" + + l4g "github.com/alecthomas/log4go" + "github.com/mattermost/platform/model" ) func encodeRFC2047Word(s string) string { @@ -59,22 +60,17 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap } } - auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort) - if config.EmailSettings.ConnectionSecurity == model.CONN_SECURITY_TLS { - if err = c.Auth(auth); err != nil { - return nil, model.NewLocAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error()) - } - } else if config.EmailSettings.ConnectionSecurity == model.CONN_SECURITY_STARTTLS { + if config.EmailSettings.ConnectionSecurity == model.CONN_SECURITY_STARTTLS { tlsconfig := &tls.Config{ InsecureSkipVerify: *config.EmailSettings.SkipServerCertificateVerification, ServerName: config.EmailSettings.SMTPServer, } c.StartTLS(tlsconfig) - if err = c.Auth(auth); err != nil { - return nil, model.NewLocAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error()) - } - } else if config.EmailSettings.ConnectionSecurity == model.CONN_SECURITY_PLAIN { - // note: go library only supports PLAIN auth over non-tls connections + } + + if *config.EmailSettings.EnableSMTPAuth { + auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort) + if err = c.Auth(auth); err != nil { return nil, model.NewLocAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error()) } diff --git a/webapp/components/admin_console/connection_security_dropdown_setting.jsx b/webapp/components/admin_console/connection_security_dropdown_setting.jsx index 3a8e5f7fea..b7b283be19 100644 --- a/webapp/components/admin_console/connection_security_dropdown_setting.jsx +++ b/webapp/components/admin_console/connection_security_dropdown_setting.jsx @@ -26,23 +26,6 @@ const SECTION_NONE = ( ); -const SECTION_PLAIN = ( -