From 6ccccaa373d3c7944a262b4cd885a8ed793f0f6f Mon Sep 17 00:00:00 2001 From: Piotr Kozimor Date: Wed, 8 Sep 2021 12:35:11 +0200 Subject: [PATCH] Initialize mailer only if enabled --- userapi/userapi.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/userapi/userapi.go b/userapi/userapi.go index 31e46800a..b620d3ec4 100644 --- a/userapi/userapi.go +++ b/userapi/userapi.go @@ -47,9 +47,12 @@ func NewInternalAPI( if err != nil { logrus.WithError(err).Panicf("failed to connect to threepid db") } - mailer, err := mail.NewMailer(cfg) - if err != nil { - logrus.WithError(err).Panicf("failed to crate Mailer") + var mailer mail.Mailer + if cfg.Email.Enabled { + mailer, err = mail.NewMailer(cfg) + if err != nil { + logrus.WithError(err).Panicf("failed to crate Mailer") + } } return &internal.UserInternalAPI{ AccountDB: accountDB,