From 79a0d3dac4914e158608129f6b8c53ce80baa62f Mon Sep 17 00:00:00 2001 From: lkyuchukov <45465568+lkyuchukov@users.noreply.github.com> Date: Fri, 29 Apr 2022 12:15:24 +0300 Subject: [PATCH] Don't log error when SendEmailNotifications is set to false (#20007) Co-authored-by: Mattermod --- app/server.go | 7 +++++-- shared/mail/mail.go | 4 ---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/server.go b/app/server.go index 1126ff13c0..d0091ae94f 100644 --- a/app/server.go +++ b/app/server.go @@ -1196,8 +1196,11 @@ func (s *Server) Start() error { if err := s.Store.Status().ResetAll(); err != nil { mlog.Error("Error to reset the server status.", mlog.Err(err)) } - if err := mail.TestConnection(s.MailServiceConfig()); err != nil { - mlog.Error("Mail server connection test is failed", mlog.Err(err)) + + if s.MailServiceConfig().SendEmailNotifications { + if err := mail.TestConnection(s.MailServiceConfig()); err != nil { + mlog.Error("Mail server connection test failed", mlog.Err(err)) + } } err := s.FileBackend().TestConnection() diff --git a/shared/mail/mail.go b/shared/mail/mail.go index 8ca1db48bf..f30d10eb1a 100644 --- a/shared/mail/mail.go +++ b/shared/mail/mail.go @@ -208,10 +208,6 @@ func NewSMTPClient(ctx context.Context, conn net.Conn, config *SMTPConfig) (*smt } func TestConnection(config *SMTPConfig) error { - if !config.SendEmailNotifications { - return errors.New("SendEmailNotifications is not true") - } - conn, err := ConnectToSMTPServer(config) if err != nil { return errors.Wrap(err, "unable to connect")